Cloud Init in Proxmox
How to use Cloud Init in Proxmox to spin up fast and effieicent VM's using Ubuntu 24.04 LTS Noble
Express IT Tech Tips
4/25/20242 min read
What does Cloud-init do?
Cloud-init is the industry standard for customizing guest operating systems on virtual infrastructure platforms such as Proxmox PVE.
This customization stage occurs during the first boot of the guest operating system, where an initialization agent (such as cloud-init) looks for a so-called "cloud-config" data source (usually just a YAML file transparently served from a reserved IP class or locally attached ISO image), and applies the various settings specified within said cloud config (e.g. creating a new user).
Cloud-init settings on Proxmox PVE
The Proxmox PVE API allows users to set specific properties within the cloud config to be used during the initial run of Cloud-init within the guest OSes on first boot, such as:
- Specifying a new username/password/SSH keys which will get automatically created.
- Specifying IPv4/6 configurations to be applied within the guest OS.
- Some additional options, such as performing automatic package manager updates on Linux guests, static networking settings, and more.
Template Prerequisites
In order for the Cloud-init instance options to be applied, the VM image being booted must have a pre-installed agent which is able to read the the cloud config data format.
Linux templates
On Linux guests, the so-called nocloud data source is used to pass the cloud config to the guest OS, so the Cloud-init installation within the VM image being booted must be configured to use it.
In most situations, using pre-baked Linux "golden images" (such as the upstream Canonical Ubuntu Server images) should work out of the box, though some additional pre-customization (such as installing the qemu-guest-agent) might be required for better compatibility with PVE.
Use in Proxmox
Steps
- SSH Into the Main Node you are working on or navigate to shell
- Run the following command to pull down the cloud image you will require for access to cloud images see here https://cloud-images.ubuntu.com
wget https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img
That will pull down the release just replace the url with the one you require in my example here im using 24.04 LTS release the KVM images are the ideal candidate here
next up will be create a Virtual machines in the CLI to use in the example below I am setting a VM ID of 8000 but you can use any that arent in use its wise not to pick a series thats in your normal array
```
qm create 7000 --memory 2048 --core 2 --name ubuntu-cloud --net0 virtio,bridge=vmbr0
```
Above i have provided 2GB of Memory 2 Cores and set the Network Bridge to vmbr0 this is a safe bet at this stage and can be changed later
next up we need to navigate to where that iso was downloaded
```
cd /var/lib/vz/template/iso/
```
then import that disk
```
qm importdisk 7000 noble-server-cloudimg-amd64.img local-lvm
```
then attach the new disk
```
qm set 7000 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-7000-disk-0
```
set to cloud init
```
qm set 7000 --ide2 local-lvm:cloudinit
```
make it bootable
```
qm set 7000 --boot c --bootdisk scsi0
```
add the serial console
```
qm set 7000 --serial0 socket --vga serial0
```
