Learn how to create an Ubuntu 24.04 Cloud-Init Template in Proxmox. Our Proxmox support team is ready to assist.
Create an Ubuntu 24.04 Cloud-Init Template in Proxmox
According to our Experts, a powerful way to streamline VM deployment on Proxmox VE is by creating a reusable Ubuntu 24.04 template with Cloud-Init support. This lets us launch new VMs quickly, pre-configured with user accounts, SSH keys, and network settings, all through the command line.
Today, we will explore creating a cloud-init-enabled Ubuntu 24.04 VM template using the Proxmox CLI and using it to spin up new virtual machines in just a few commands.
If you’re migrating from another hypervisor, you may want to check out how to migrate VirtualBox VMs to Proxmox before getting started.
An Overview:
Prerequisites
Before we begin, we need the following:
- Proxmox VE 7.x or newer
- Configured network bridge (e.g., `vmbr0` or `vmbr1`)
- Storage pool (e.g., `local-lvm` or `local-zfs`)
- Internet access on the Proxmox host
All commands should be run from the Proxmox shell, accessible via the `xterm.js` console in the web UI.
For advanced remote access options, consider enabling SPICE. Here’s a guide on how to access Proxmox VMs with SPICE.
Step 1. Download the Ubuntu 24.04 Cloud Image
In this example, we will use the official Ubuntu cloud image for version 24.04. Run the following command in the Proxmox shell to download it:
wget -P /var/lib/vz/template/iso/ https://cloud-images.ubuntu.com/daily/server/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img
To verify the download:
ls /var/lib/vz/template/iso/
We will now see the `.img` file listed.
Step 2. Create the Base VM
Let’s create a new VM that we can later convert into a template:
qm create 9000 --name "ubuntu-24.04-cloud-init-template" --memory 2048 --cores 2 --net0 virtio,bridge=vmbr0
Here:
- 9000 is a Unique ID for the VM. It is a good idea to pick a high number to avoid conflicts.
- –name is a descriptive VM name.
- –memory and –cores are basic hardware settings.
- –net0 is the network interface, using `virtio` with bridge `vmbr0`.
If you’re working on performance-sensitive workloads, you might also want to enable SSD emulation. Here’s a guide that explains how to enable SSD emulation in Proxmox for better disk performance.
Step 3. Import the Disk Image
Now, attach the Ubuntu image to the VM:
qm importdisk 9000 /var/lib/vz/template/iso/ubuntu-24.04-server-cloudimg-amd64.img local-lvm
Then, configure the imported disk as the primary boot device:
qm set 9000 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-9000-disk-0
qm set 9000 --boot c --bootdisk scsi0
Now, add a Cloud-Init disk:
qm set 9000 --ide2 local-lvm:cloudinit
Step 4. Configure Cloud-Init Parameters
Now, set the default network settings, username, and password:
qm set 9000 --ipconfig0 ip=dhcp
qm set 9000 --ciuser ubuntu --cipassword 'ourpassword'
Add the public SSH key for secure access (optional but recommended):
qm set 9000 --sshkey "$(cat ~/.ssh/id_rsa.pub)"
Remember to replace `’ourpassword’` and SSH key path as needed.
Step 5. Convert VM to a Template
With everything configured, convert the VM into a reusable template:
qm template 9000
Step 6. Clone the Template
Now, we can use this template to create new VMs instantly:
qm clone 9000 201 --name "new-ubuntu-vm"
We can also modify the VM’s hardware before starting it:
qm set 201 --memory 4096 --cores 4
And then start the VM:
qm start 201
If you’re working within a clustered Proxmox environment, keep in mind that services might occasionally need to be restarted for new templates to register properly. This guide covers how to restart cluster services in Proxmox safely.
Optional: Resize the Disk
By default, the VM disk will be around 3–4 GB. We can resize it if needed:
qm resize 201 scsi0 +10G
To make the new space usable inside the VM:
- Access the VM (via console or SSH).
- Switch to root:
sudo su
- Now, use `parted` to resize the partition:
parted /dev/sda
- Inside `parted`, resize the first partition:
resizepart 1 100%
- Then run `resize2fs` (or equivalent for your filesystem) to expand the file system:
resize2fs /dev/sda1
[Need assistance with a different issue? Our team is available 24/7.]
Conclusion
A cloud-init enabled Ubuntu 24.04 template in Proxmox VE is ideal for automated infrastructure, saving time and ensuring consistent configurations across our environment.
In short, our Support Engineers demonstrated how to create an Ubuntu 24.04 Cloud-Init Template in Proxmox.
0 Comments