Skip to main content

Ubuntu 22.04 Template with Cloud-Init

Creating a cloud-init template is relatively simple and straightforward to do. Essentially, you'll want to create your VM with base configurations, and then convert it to a template within Proxmox VE. Follow the steps below to create your own template with cloud-init.

Create your VM in Proxmox

image.png

  • Assign a VM ID, I keep my templates in the 900s range, and then give your VM a name
OS Settings

image.png

  • Select "Do not use any media"
    • We'll be adding cloud-init drive later on

System Settings

image.png

  • Select qemu agent
  • Keep everything else as default or change if you'd like
Disk Settings

image.png

  • Delete the disk, we'll add this later on
CPU Settings

image.png

You can keep this at default settings, or change depending on what your intentions are for this template. I plan to use this specific template for Kubernetes nodes, so I'll be using minimal requirement specs

Memory Settings

image.png

  • I kept this default at 2 GB for memory. You can always scale up your clones: keep in mind that this is just a base configuration
Network Settings

image.png

  • I kept my network settings the same, as I manage my homelab network with Static Leases and VLANS through OPNsense
  • After this step, confirm and create your VM
Hardware Settings

image.png

  • Select your VM and navigate to the Hardware tab
  • Select Add ---> CloudInit Drive
    • image.png

      • I selected local-zfs for my storage
Cloud-Init Settings

image.png

  • Navigate to Cloud-Init
  • Configure settings however you'd like your VMs to be created
  • I set username, password, upgrade packages, and IP to DHCP

Establish a terminal connection to your Proxmox VE so you can configure Cloud-Init further

image.png

You'll now want to download the cloud image you'd like to use for the VM with wget. You can find Cloud Images at the Ubuntu Cloud website and select any version of flavor of linux you'd like. I'll be using the Ubuntu Minimal 22.04 LTS (Jammy) image:

image.png

Select the release you'd like to use, or scroll all the way down and select release/ for the most current. In this folder, find the amd64.image and copy the download link.

image.png

In your terminal window for Proxmox, run the command below:

wget https://cloud-images.ubuntu.com/minimal/releases/jammy/release/ubuntu-22.04-minimal-cloudimg-amd64.img

After downloading, run the ls command to view the file name:

image.png

Since I've already created templates before, I have some files already in there. The file I just downloaded is ubuntu-22.04-minimal-cloudimg-amg64.img

Before moving forward, run the following command:

qm set 901 --serial0 socker --vga serial0
  • This is required so that your Proxmox VM console will show your VM output
  • 901 should be changed to whatever your VM ID is

Next you'll want to rename the file and change the file extension to .qcow2

Run the following command:

mv ubuntu-22.04-minimal-cloudimg-amg64.img ubuntu-min-2204server.qcow2

Set the disk size with the following command:

qemu-img resize ubuntu-min-2204server.qcow2 32G
  • This will set the base hard drive size to 32Gb. You can always change this later

Next, you'll want to run the following command to import ther drive to your VM in Proxmox:

qm importdisk 901 ubuntu-min-2204server.qcow2 local-zfs
  • Set 901 to your VM ID
  • Set local-zfs to your storage 
    • If you're not using zfs, yours is most likely local-lvm

Next, navigate in your Proxmox GUI to the Hardware section of your VM, and you'll find "unused disk 0" at the bottom. Select edit, and check the following boxes if you're using SSDs in your host machine:

image.png

image.png

The last step before starting the VM is to edit the Boot Order. You can do this by navigating to the Options tab within your VM. 

image.png

  • Edit it so that scsi0 is enabled and moved up to 2nd

With all your configurations set, right-click on the machine and select "Convert to Template". To test everything's worked correctly, right click on the template and select "Clone" then select "Full Clone" for the mode:

image.png

Start your machine and test that it's working as configured!