Building Cloud Images for Proxmox
[Updated] Updting this for 2025, including Noble as the image (24.04) and adding some other missing bits..
I needed to create a few Ubuntu VMs for a Kubernetes cluster for testing, and I wanted to make the process as simple as possible using Proxmox and some minimal automation. Here’s what I’ve done:
First, Download the base image:
wget https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img
To be able to run the commands below, you need to install libguestfs-tools on proxmox. An apt-update and apt install libguestfs-tools is all that is needed.
Then, tweak the image. Since I’m using my apt-cacher-ng proxy here, I’ve set the proxy for all VMs. You can remove it or adjust it as needed. If you want to remove it, simply remove the append-line option. Additionally, I’m installing qemu-guest-agent here. You can add any additional items at this point if desired.
virt-customize -a noble-server-cloudimg-amd64.img --install qemu-guest-agent --append-line '/etc/apt/apt.conf.d/00proxy:Acquire::http { Proxy "http://10.244.71.182:3142"; };'
That command does the following:
– installes the QEMU Guest Agent
– adds the proxy script to apt config
NOTE: If you are runing ProxMox 9, you will need to install dhcpcd first. So, apt update and apt install dhcpcd, then run the above commands.
Sysprepping the image resets it to the default stage. If you don’t perform this step, and you clone the machine multiple times, all the clones will have the same machine ID and IP address. [Note: This isn’t working fully for me. See below for the changes I made to the machine ID.]
virt-sysprep -a noble-server-cloudimg-amd64.img
Create the template. I used ID 9000 and assigned a name. You can modify this. Additionally, I’ve tagged mine with VLAN 72 (my Kubernetes VLAN). Feel free to change or remove this tag as needed. Furthermore, I set the disk size to add 50GB. Please replace any references to “godboxv2-tank” with your storage name.
qm create 9000 --name “ubuntu-2404-cloudinit-template" --memory 4096 --cores 2 --net0 virtio,bridge=vmbr0,tag=72
qm importdisk 9000 noble-server-cloudimg-amd64.img godboxv2-tank
qm set 9000 --scsihw virtio-scsi-pci --scsi0 godboxv2-tank:vm-9000-disk-0
qm set 9000 --boot c --bootdisk scsi0
qm disk resize 9000 scsi0 +50G
qm set 9000 --ide2 godboxv2-tank:cloudinit
qm set 9000 --serial0 socket --vga serial0
qm set 9000 --agent enabled=1
qm template 9000
This does the following:
– creates a new VM with id 9000 and sets the name, memory ad core count. It also sets the network card, and in my case the VLAN (remove ,tag=72 if you do not need a VLAN)
– imports the disk to the VM and puts it in the storage path. You will need to change your path here.
– sets the VM to use that disk as a SCSI drive
– sets the disk to be bootable
– sets the size of the disk to +50Gb of what it was originally… important as the disk is only a couple gig and you will run out of space quite quickly…
– sets up cloud init for the VM as an IDE CD drive.
– sets serial output for the VM
– Tells Proxmox the Agent is installed
– set the VM as a template.
Next, clone the template into a new VM.
qm clone 9000 2001 --name k8s-01
qm set 2001 --sshkey godboxv3.pub
qm set 2001 --memory 4096
qm set 2001 --ciuser tiernano
qm set 2001 --ipconfig0 ip=dhcp
Here we are creating a new VM with ID 2001, setting the SSH key, setting the memory and user, and telling the machine to get its IP from DHCP.
Change tiernano and godboxv3.pub to your settings. Modify the names and memory as necessary.
As mentioned earlier, I’m still encountering the issue of IP addresses being shared. To resolve this, log into the boxes and execute the following command:
echo -n > /etc/machine-id
rm /var/lib/dbus/machine-id
ln -s /etc/machine-id /var/lib/dbus/machine-id
Reboot the computer, and the problem should be resolved.
---
This site is hosted on my own ASN on AS204994. More details about that over there. I also use Vultr for transit services and HostUs for LIR Services. Check them out. You can also check some of the gear I use on a daily basis over on kit.co/tiernano. Looking for a Backup Option? Check out Backblaze and get a month free.