Latest news from 5wire Networks

How to prepare Alpine Linux image with Cloud-Init ready for Proxmox

Alpine Linux is a distribution designed to be small, simple, and secure. We recently added this to Operating System lineup for our Linux Cloud Servers.

The Cloud Images available on the Alpine Linux website are for AWS, NoCloud, Azure, GCP, and OCI. You could convert the NoCloud image, but we thought it would be easier to use the latest VIRTUAL image from the Alpine Linux website. At the time of writing this article, we used version 3.19.1.

Step 1: Create a VM on Proxmox

  1. Create a VM on Proxmox, 1 Core, 512MB RAM, 1GB Disk Space is plenty
  2. Attach a CD/DVD ROM with SCSI to mount your .iso 

Step 2: Download Alpine Linux and mount to your CD/DVD ROM

  1. Download the VIRTUAL image from the Alpine Linux website
  2. Mount the ISO to the VM that you created

Step 3: Boot & Configure

  1. Boot the VM from the CD/DVD ROM, head to the Console in Proxmox
  2. Alpine Linux will load up. This is now running from your disk ISO

Step 4: Install & Setup Alpine Linux

You will see the login screen, the username is root, no password to access.

Run the command to start the installation and follow the steps to install Alpine Linux onto the 1GB Disk. Make sure to configure the network at this stage.


Next, before you do anything else. Unmount the CD/DVD ROM ISO and reboot the VM. 

Step 5: Configure Alpine Linux

Before you proceed, make sure that you have unmounted the CD/DVD ROM iso and rebooted. Otherwise, you will end up setting everything up on the ISO, and when you reboot – all your effort will disappear.

Our preferred editor is nano

apk add nano

Next, you need to make sure all of the repositories are available to download the relevant packages for cloud-init to download:

nano /etc/apk/repositories

If there is a # in front of any of the repositories, remove this and save the changes.

Run an update

apk update

Install all of the relevant packages to handle cloud-init

apk add gcc linux-headers py3-pip musl-dev python3-dev e2fsprogs e2fsprogs-extra cloud-init \ libblockdev lsblk parted sfdisk sgdisk lvm2 device-mapper \ doas eudev mount openssh-server-pam sudo py3-pyserial and py3-netifaces

[Optional] You may want to install qemu-guest-agent at this stage

apk add qemu-guest-agent

Step 6: Configure SSH Config

The first file you will need to edit is /etc/ssh/sshd_config

Change the following so the sshd_config shows:

PermitRootLogin Yes

PasswordAuthentication yes

Step 7: Configure Cloud.cfg 

The next file you will need to edit is /etc/cloud/cloud.cfg

disable_root false

ssh_pwauth: true

lock_passwd: false

Step 8: Remove the network configuration

Remove the network configuration under /etc/network/interfaces

Step 9: Prepare Ready Cloud Init

The image is now ready.

From this point, you cannot reboot the VM as it is setup in a template. If you reboot the VM, it will run cloud-init on first boot and will break things. 


Step 10: Lock down root access

Before you shutdown, lockdown the template for root 

passwd -l root

Step 11: Shutdown and convert to template

  1. Power down the VM
  2. In Proxmox, convert the VM to a template


Life time discount when you purchase your first order. Applies to Web Hosting, Reseller Hosting, and Cloud Servers.

Free Domain included on yearly Web Hosting plans.

Use code WEBOFF at the checkout!

Terms and Conditions apply. Voucher code is only valid for new customers.