Ubuntu 22.04 Template ubuntu-2204-jammy
Open a shell on the Proxmox host.
First install libguestfs-tools so we have virt-customize, then download the image then uninstall open-vm-tools and install qemu-guest-agent.
apt install libguestfs-tools
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
virt-customize -a jammy-server-cloudimg-amd64.img --uninstall open-vm-tools
virt-customize -a jammy-server-cloudimg-amd64.img --install qemu-guest-agent --truncate /etc/machine-id
Create the VM that will become a template.
I’m using vmid 2204 since this is Ubuntu 22.04.
Import the image from the last step. Using default Proxmox storage local-lvm, change accordingly if you added storage. Change –net0 to your environment.
To use a vlan: –net0 virtio,bridge=vmbr1,tag=10
Attach the imported disk to the VM.
Add the Cloud-Init drive.
Set the boot disk.
Create the serial interface as the display.
qm create 2204 --memory 4096 --core 4 --name ubuntu-2204-jammy --net0 virtio,bridge=vmbr1 --tablet 0 --ostype l26 --agent 1,fstrim_cloned_disks=1
qm importdisk 2204 jammy-server-cloudimg-amd64.img local-lvm
qm set 2204 --scsihw virtio-scsi-single --virtio0 local-lvm:vm-2204-disk-0
qm set 2204 --ide2 local-lvm:cloudinit
qm set 2204 --boot c --bootdisk virtio0
qm set 2204 --serial0 socket --vga serial0
Edit Cloud-Init for you
User, Password, DNS servers if not using DHCP, IP Config to set static or DHCP, etc…
Then hit the Regenerate Image button
Now create the template.
qm template 2204
Ubuntu 24.04 Template ubuntu-2404-noble
apt install libguestfs-tools
wget https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img
virt-customize -a noble-server-cloudimg-amd64.img --uninstall open-vm-tools
virt-customize -a noble-server-cloudimg-amd64.img --install qemu-guest-agent --truncate /etc/machine-id
qm create 2404 --memory 4096 --core 4 --name ubuntu-2404-noble --net0 virtio,bridge=vmbr1 --tablet 0 --ostype l26 --agent 1,fstrim_cloned_disks=1
qm importdisk 2404 noble-server-cloudimg-amd64.img local-lvm
qm set 2404 --scsihw virtio-scsi-single --virtio0 local-lvm:vm-2404-disk-0
qm set 2404 --ide2 local-lvm:cloudinit
qm set 2404 --boot c --bootdisk virtio0
qm set 2404 --serial0 socket --vga serial0
Edit Cloud-Init for you
User, Password, DNS servers if not using DHCP, IP Config to set static or DHCP, etc…
Then hit the Regenerate Image button.
qm template 2404
Create a VM from template
Right click the template and select Clone and adjust the following:
Name:
Mode: - Select Full Clone. Takes a little longer to spin up but will not be linked to the template. Link is good for testing then burning.
Hit Clone
Once it finishes building select the VM and edit Hardware.
Select Hard Disk > Disk Action > Resize in the header and enter how much you want to add to grow the disk out.
Edit the Network Device and set the VLAN if needed.
Select Cloud-Init and set the DNS servers(comma separated) then set IP Config. Once set hit the Regenerate Image button above.
If you don’t resize the disk, it will run out of space before you log into it and you’ll need to start over.
Start the VM, give it a couple minutes to boot then it will run updates. It will give a login prompt but it’s not finished. Takes about 5min tops.
Finished when it gives in the last few lines the uptime.
If you do not want it to run updates on every reboot, go into Hardware and remove the Cloudinit Drive and reboot by right clicking the VM.
Don’t forget to add it to backups and set it in HA if needed.
All set.
Setting the display as serial allows you ssh into the Proxmox host and hop into a console for that vm.
Use ‘qm list’ to get a list of VMs.
Then console in to the one you want with ‘qm terminal <VMID>’.