Cloud-Init VM Template Creation
Create a new VM that will become the template
:::info The steps below are performed with Ubuntu Server, but they can be adapted for any distro. :::
- Give the VM and ID of
900or something high that will make it appear lower in the VM listing so it’s not co-mingled with your other non-template VMs - Name the VM template based on the distro used -
ubuntu-2504-templateor similar - and click Next - On the OS tab, select Do not use any media since we will be using a cloud image and click Next
- On the System tab, select the Qemu Agent checkbox so that it will already be enabled if you install the Qemu Agent to future VMs and it’s one less thing to do - click Next to proceed to the Disks tab
- Delete the default scsi0 disk as we will be importing a .qcow disk file later in the process and click Next
- Leave the CPU settings at their default 1 core 1 thread specifications and click Next
- Decrease the memory to 1024 MiB (1 GiB) and click Next
- On the Network tab, if you have multiple networks available, select the correct one in the Bridge dropdown - if you only have the single default network, leave it at
vmbr0and click Next - Confirm that everything looks accurate on the Confirm tab - be sure the Start after created checkbox is NOT selected - and click Finish to complete the creation of the template VM
Modify the template VM’s settings via the web GUI
- Click on the Hardware tab for the template VM and the click Add → CloudInit Drive
- Select the appropriate storage location and click Add
- Click on the Cloud-Init tab for the template VM
- Click the User setting and click the Edit button - add the user account you would like to be created by default on the template (
jeff, in this case) which will also be present on any of the copies of the VM you spin up and click OK to save the value - Click on the Password setting and click the Edit button - set the desired password for the default user account and click OK to save the value
- Set the Upgrade packages value based on your preferences -
Yesis the default and desired value - Click the IP Config settings and click Edit to modify them - select the DHCP radio button for IPv4 to ensure network connectivity when a new clone of the template is created
Modify the template VM’s settings via Proxmox command line
- Use a terminal/SSH client to connect to the Proxmox host via SSH, or alternatively you can click the Console button in the web GUI to open a web-based terminal - a terminal/SSH client is preferable so that commands can be copied and pasted as needed
- Open your terminal/SSH client and connect to the Proxmox host via SSH by entering
ssh username@hostnameorIPaddress(which would bessh root@ms01.homein this case) and press Enter to connect - If you do not have an SSH key configured, you will be prompted to enter the password for the username entered in the previous step, which would be
rootin this case - do so and press Enter again to log in - Enter the following command to download the target version of the OS:
# Ubuntu 25.04 Minimal Cloud Image
wget https://cloud-images.ubuntu.com/minimal/releases/plucky/release/ubuntu-25.04-minimal-cloudimg-amd64.img
- Next run the following command to add a serial console to the template VM - without it you will not see anything in the terminal when the VMs are powerd on:
qm set 900 --serial0 socket --vga serial0
- Rename the .img file to a .qcow2 file extension:
mv ubuntu-25.04-minimal-cloudimg-amd64.img ubuntu-25.04.qcow2
- Resize the downloaded cloud image to 32 GiB in size:
qemu-img resize ubuntu-25.04.qcow2 32G
- Import the disk image into Proxmox:
qm importdisk 900 ubuntu-25.04.qcow2 local-lvm
- Once the disk has been imported into Proxmox, go back to the web GUI and select the template VM and then the Hardware tab - there will be a new disk named Unused Disk 0
- Click on Unused Disk 0 and click Edit
- If the physical disk being used to store the image/drive is an SSD, select the Discard checkbox, and then select the Advanced checkbox and select the SSD emulation checkbox as well.
- Click Add to use the disk with the template VM
More configuration in the web GUI
- Click on the Options tab for the template VM
- Click the Boot Order and note that the disk we just imported/created is not listed in the options
- Click the Edit button to modify the boot order
- Select the checkbox next to the
scsi0disk to enable it, and drag it to position 2 in the boot order below the disk listed most likely aside2with descriptionnone,media=cdromsince you may want to boot from a .iso file at some point in the future - Click OK to save the changes
- You may or may not want to set the Start at boot value to Yes if you want all copies of the template to boot automatically - I am opting to leave this set to No and will manually modify the setting on a per-VM basis once they have been created
- Once things are set up properly, right-click on the template VM’s name and click Convert to template to convert it from a VM to a template
:::danger Be sure that everything is configured properly as there is no way to modify things after the VM has been converted to a template - you will need to go through the previous steps to create a new VM to convert to a template with the correct settings :::
Using the template to create new VMs
- Right-click the VM template and click Clone
- Give the VM an ID and appropriate name, and set the Mode to Full Clone - Linked Clone can be used to save some disk space if desired
- Click Clone to spin up the new VM
- Once the cloning process has completed, the new VM can be booted for the first time
- View the console during the boot up process, and be sure to wait until the Cloud-Init process has fully finished so that your default user account is provisioned properly
- You may need to press Enter or another key to see if the VM is ready to be logged into - it may take some time if updates are configured to run as part of the provisioning process (in this case they are) and it is usually ready after the SSH key information is displayed
- Enter the username and password you configured in the Cloud-Init portion of the process and, if everything worked properly, you will be logged in successfully