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
- Create a VM on Proxmox, 1 Core, 512MB RAM, 1GB Disk Space is plenty
- Attach a CD/DVD ROM with SCSI to mount your .iso
Step 2: Download Alpine Linux and mount to your CD/DVD ROM
- Download the VIRTUAL image from the Alpine Linux website
- Mount the ISO to the VM that you created
Step 3: Boot & Configure
- Boot the VM from the CD/DVD ROM, head to the Console in Proxmox
- 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.
setup-alpine
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.
setup-cloud-init
Step 10: Lock down root access
Before you shutdown, lockdown the template for root
passwd -l root
Step 11: Shutdown and convert to template
- Power down the VM
- In Proxmox, convert the VM to a template
Start Your Reseller Hosting Journey with 5wire and Benefit from Our Cloud Server and Forex Servers. Partner with 5wire to offer your clients exceptional cloud server performance and secure forex servers through our reseller hosting programme.