How to Create an Ubuntu 22.04 Cloud VM on Proxmox Using Cloud-Init


How to Create an Ubuntu 22.04 Cloud VM on Proxmox Using Cloud-Init

Ubuntu 22.04 (Jammy Jellyfish) is a popular server OS with long-term support, making it a solid choice for modern infrastructure. In this tutorial, we’ll walk through how to set up a cloud-init-enabled Ubuntu 22.04 virtual machine on Proxmox using the qm CLI.

We’ll cover how to:

  • Download and import the cloud image
  • Attach the image as a disk
  • Configure cloud-init for static IP, user, and password
  • Boot the VM and verify its status

🧰 Requirements

Ensure you have:

  • A running Proxmox VE node
  • A storage pool (e.g., local-lvm)
  • A network bridge (e.g., vmbr0)
  • Internet access for downloading the image

🖼️ Step 1: Download Ubuntu 22.04 Cloud Image

wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img -P /var/lib/vz/template/iso/

This downloads the Ubuntu 22.04 cloud image to the ISO template directory.


🆕 Step 2: Create the Virtual Machine

qm create 4002 --name ubuntu-vm --memory 2048 --cores 2 --net0 virtio,bridge=vmbr0
  • VM ID: 4002
  • VM Name: ubuntu-vm
  • Memory: 2 GB
  • Cores: 2
  • Bridge: vmbr0

💽 Step 3: Import the Disk Image

qm importdisk 4002 /var/lib/vz/template/iso/jammy-server-cloudimg-amd64.img local-lvm

This imports the .img file as a disk into the local-lvm storage.


🧩 Step 4: Attach and Resize the Disk

qm set 4002 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-4002-disk-0
qm resize 4002 scsi0 25G
  • Attaches the disk as a SCSI device
  • Resizes the disk to 25GB

☁️ Step 5: Add Cloud-Init Disk

qm set 4002 --ide2 local-lvm:cloudinit

Adds a Cloud-Init disk for injecting login credentials and network configs.


🌐 Step 6: Set IP Address and Credentials

qm set 4002 --ipconfig0 ip=103.0.113.55/24,gw=103.0.113.1
qm set 4002 --ciuser ubuntuuser --cipassword UbuntuPass22
qm set 4002 --searchdomain cloudhost.com
  • Static IP: 103.0.113.55
  • Gateway: 103.0.113.1
  • User: ubuntuuser with password
  • DNS search domain: cloudhost.com

🔧 Step 7: Configure Boot Order

qm set 4002 --boot c --bootdisk scsi0
qm set 4002 --onboot 1
qm set 4002 --boot order=scsi0

Ensures the VM boots from the disk and starts on host boot.


▶️ Step 8: Start the VM and Check Status

qm start 4002
qm status 4002

You’re all set! Your Ubuntu 22.04 VM is now up and running.


Wrap-Up

Creating Ubuntu VMs with cloud-init in Proxmox is a quick and repeatable process. You can easily build automated infrastructure this way, especially when combining it with tools like Ansible or Terraform.

Leave a Comment