I have showed how to create VM templates in my blog earlier – Creating VM Templates in Proxmox – SecBytes. In this blog, I will walk you through a quick guide on how to create the virtual machines from the templates. This blog is a generalised version for creating virtual machines from the templates, which I shall refer to in my upcoming blogs wherever I need to clone the virtual machines in my environment.
The only prerequisite here is to have a template ready for your `machine
Follow the below steps to create a virtual machine from the template
- Select the template, right click and then select ‘Clone’.
- Add the required details as mentioned below.
- VM ID: A unique numeric identifier for your VM
- Name: Name for your VM
- Mode: Full Clone (this creates an independent VM i.e. any changes to the template will not impact the VM)
- Once the above details are added, click on the ‘Clone’ button on the dialog box and wait for the cloning process to finish which can be seen in the ‘Tasks’ section on the lower bottom of the Proxmox manager screen. Once the cloning is done, the cloning task will show an ‘End Time’.
- Once, successfully cloned, you should now see your VM on the right-hand side ‘Server View’ of the screen. Click on the VM and navigate to ‘Hardware’ section as shown in the diagram below. Change the required hardware and then boot the virtual machine. Please note, when you resize your hard disk, it adds the space added by you to the hard disk. In case if you need to shrink the space, then follow the section below. You can remove the existing hard disk and add the new hard disk as per the steps given below. Your virtual machine should be initialized quickly in few minutes and your bare minimum Ubuntu server (or any other OS as per the template) is now up and running.
Steps to shrink hard disk space in the virtual machine (before initial boot)
In case you need to shrink the hard disk size, you can follow the below steps. The steps to download an Ubuntu cloud-init images is described in Creating VM Templates in Proxmox – SecBytes. Now if you have an Ubuntu minimal 24.04 server cloud-init image which you have resized to 64 GB and now need to be reduced to 32 GB, you can run the following command.
# cp ubuntu-24.04_64G.qcow2 ubuntu-24.04_32G.qcow2
# qemu-img resize --shrink ubuntu-24.04_32G.qcow2 32G
Image resized.
# qm importdisk <VM_ID> ubuntu-24.04_32G.qcow2 <VM_VOLUME_NAME>
importing disk 'ubuntu-24.04_32G.qcow2' to VM <VM_ID> ...
transferred 0.0 B of 32.0 GiB (0.00%)
transferred 331.0 MiB of 32.0 GiB (1.01%)
transferred 675.0 MiB of 32.0 GiB (2.06%)
transferred 1006.0 MiB of 32.0 GiB (3.07%)
transferred 1.3 GiB of 32.0 GiB (4.08%)
transferred 1.7 GiB of 32.0 GiB (5.20%)
.
.
.
transferred 30.8 GiB of 32.0 GiB (96.15%)
transferred 31.1 GiB of 32.0 GiB (97.16%)
transferred 31.4 GiB of 32.0 GiB (98.17%)
transferred 31.7 GiB of 32.0 GiB (99.18%)
transferred 32.0 GiB of 32.0 GiB (100.00%)
transferred 32.0 GiB of 32.0 GiB (100.00%)
unused0: successfully imported disk '<VM_VOLUME_NAME>:vm-<VM_ID>-disk-<DISK_ID>'