Proxmox VE – How to build an Ubuntu 22.04 Template (Updated Method)

Proxmox Virtual Environment is a powerful and easy to use virtualization platform with many features. Virtual machine templates help to minimize the amount of time spent building new instances, and in this video we’ll take a look at how you can utilize Ubuntu’s cloud images to automate the process of deploying new Linux instances.

YouTube player

Video-specific Links

Commands used in this video

Add a serial console to the reference VM

qm set <VM ID> --serial0 socket --vga serial0

Change the file extension of the image to .qcow2

mv ubuntu-22.04-minimal-cloudimg-amd64.img ubuntu-22.04.qcow2

Resize the downloaded cloud image

qemu-img resize ubuntu-22.04.qcow2 32G

Import the cloud image into Proxmox

qm importdisk 900 ubuntu-22.04.qcow2 local-lvm

Notable Replies

  1. One small issue. .img files are raw FS formats. .qcow2 file are different formats and you need your file to be formatted as such. If you run a file ubuntu-22.04.qcow2 you will most likely see that the file type is not actually qcow. The only way to fix that is to create the proxmox VM and add the ubuntu image as a raw file instead of qcow2, then under proxmox to “convert to qcow2.” That’s how it works when you are working with files on a NFS share, however, at the end you import the file to local-lvm. That means you are creating a logical volume and importing the partition data in LVM. So it’s not even qcow2 anyway, it is a raw fs image…

    Personally I never liked the proxmox LVM(-thin) option, I always deleted that and created a path or new volume under the same VG and mounted it locally, then sent the images there. Way easier to work with.

  2. I got around to watching the tutorial, just because I can always learn something, even when I am guessing I already know what’s being done there.

    The reason why the import fails with the .img file name is because KVM only supports .raw and .qcow2 disk image formats. So instead of renaming it .qcow2, try renaming it to .raw. This should allow you to import it and then if needed, convert it to qcow2 later. Funnily enough, when using either local ZFS or local LVM, I cannot select anything other than .raw files when creating a virtual disk. This is most likely because the FS takes care of the snapshot capabilities (both ZFS and LVM have built-in snapshot capabilities). If using a NFS share, I think the .qcow2 option gets enabled. Back at my old workplace, we were using NFS and converted all images from .raw to .qcow2. Funnily enough, the operation can be done live while the VM is running! And you can do it in both directions (from raw to qcow2 and from qcow2 to raw).

  3. I revisited this tutorial after Jay uploaded the ‘regular’ live-install video today, mostly because of the weird .qcow2 workaround. I did some tests to see what would happen if I just leave the file named .img (and if I would name it something else like .tmp) and both cases resulted in a broken image (SeaBIOS would just hang at triggering GRUB on the hard disk). I suspect that qemu-img resize detects the .qcow2 extension and maybe resizes the image in a way that doesn’t destroy it? (sounds really weird tbh, so might be something else).

    Anyway, I found another approach that is just as easy and less sketchy, which is to resize the disk after you add it to the VM (so after the qm importdisk step): qm resize <vm id> scsi0 32G.

    I was kind of worried this resulted in more work as I might had to enlarge the partitions and filesystems inside the VM, but they were automatically adjusted to the new size, awesome!

Continue the discussion at


Avatar for system Avatar for Jasdela Avatar for ThatGuyB