- Click Create VM to start
Make sure to not overestimated CPU and memory to avoid high resource usage and resource fighting between VM and Host
- Next step is importing cloud image file to Proxmox VE disk storage and use it as our VM boot disk
For this step, we need access into Proxmox host either by using SSH or via Console menu on Proxmox VE
Download cloud-image file and resize it to give more space for our VM
1 2 3
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img -O /tmp/ubuntu-22.04-cloud.img qemu-img resize /tmp/ubuntu-22.04-cloud.img 20G
Check our disk storage format
- If you use directory based storage like local directory or NFS, use qcow2 format when importing it to utilize the live snapshot feature.
- If you use block based storage lika ceph, lvm, or zfs, by default they will use RAW format.
pvesm statusto check what is your datastore format.
As you can see above we have zfspool for our disk storage so we will use RAW format.
Import cloud image file to disk storage
1 2 3 4 5
# For RAW format qm importdisk 1000 /tmp/ubuntu-22.04-cloud.img local-zfs_disks # For qcow2 format qm importdisk 1000 /tmp/ubuntu-22.04-cloud.img local-zfs_disks --format qcow2
We can check our disk images using command:
pvesm list local-zfs_disks
After successfully import the cloud image, it will shown as unused disk on our VM. Double click it to edit. Check discard to use thin provisioning and check SSD emulation for better performance if your disk storage is using SSD
Move to CloudInit menu, double click each variabel and give it the value you need. For example, below is my CloudInit value:
Variabels Values User ubuntu Password secretpassword DNS domain febryandana.xyz DNS servers 18.104.22.168 SSH public key root@labcx1 and root@fb-pve Upgrade packages Yes IP Config ip=dhcp
We need to configure some things before converting our VM into template. We cannot revert the VM after convert it to template so be careful.
Upgrade system packages
sudo -i apt update && apt upgrade -y
Install qemu-guest-agent and other packages that you need
apt install qemu-guest-agent net-tools tree
systemctl start qemu-guest-agent
cat /dev/null > /etc/machine-id cat /dev/null > /var/lib/dbus/machine-id
Clean CloudInit configuration
shutdown -h now
This action cannot be reverted. Make sure you have done all steps above before proceed
After VM creation is complete, start the VM and check if our template and CloudInit config running properly
Because we install
qemu-guest-agentearlier, we can also check our VM’s IP Address directly from Proxmox VE dashboard without needing to connect to VM console. This is good if we want to access the VM from SSH without needing to use Console.
And there we have it! An Ubuntu 22.04 server template for our next VM. With this template, we don’t need to dwell in OS installation everytime we want to create new VMs.
I hope you find this guide helpful and see you on another time.