Proxmox Ubuntu VM Template Setup Guide - Cloud-Init Integration
This guide walks you through creating a reusable Ubuntu VM template in Proxmox using cloud-init. This approach allows for rapid deployment of VMs with automatic configuration, making it perfect for scaling infrastructure quickly.
Prerequisites
- Proxmox VE installed and configured
- Access to the Proxmox web interface and shell
- At least 1GB RAM and 10GB storage available per VM
- Internet connection for downloading Ubuntu cloud image
Step 1: Create the Base VM
-
Create new VM
- Click “Create VM” in the Proxmox interface
- Configure the VM with the following settings:
- VM ID: Choose an available ID (e.g., 900)
- Name:
ubuntu-2404-template
- Resource Pool: (optional)
-
OS Configuration
- Guest OS: Linux
- Version: 6.x - 2.6 Kernel
- Do not use any media: ✅ Enabled
-
System Settings
- BIOS: Default (SeaBIOS)
- Machine: Default (i440fx)
- SCSI Controller: VirtIO SCSI single
- Qemu Agent: ✅ Enabled
-
Hard Disk Configuration
- Skip this step - delete any disk that was created
- We’ll add the cloud image disk later
-
CPU Configuration
- Sockets: 1
- Cores: 1 (can be increased when cloning)
- Type: x86-64-v2-AES (modern CPU features)
-
Memory Configuration
- Memory: 1024 MB (can be increased when cloning)
-
Network Configuration
- Bridge: vmbr0 (or your configured bridge)
- Model: VirtIO (paravirtualized network driver)
- Firewall: ✅ Enabled (optional but recommended)
Step 2: Configure Cloud-Init
-
Add Cloud-Init drive
- Navigate to the Hardware tab of your newly created VM
- Click Add → CloudInit Drive
- Select your preferred storage location
- Click Add
-
Configure Cloud-Init settings
- Go to the Cloud-Init tab in your VM
- Configure the following essential settings:
- User: Set your desired username (e.g.,
ubuntu
) - Password: Set a secure password
- SSH Public Key: Paste your SSH public key (optional)
- DNS domain: Optional (e.g.,
local
) - DNS servers: Optional (e.g.,
8.8.8.8 1.1.1.1
)
- User: Set your desired username (e.g.,
-
Network Configuration
- Set IP Config to DHCP
-
Regenerate Cloud-Init image
- Click Regenerate Image to apply your configuration
- This creates the cloud-init configuration disk
Step 3: Download and Import Ubuntu Cloud Image
-
Access Proxmox shell
- Click on your Proxmox node in the left panel
- Navigate to Shell or SSH into your Proxmox host
-
Download Ubuntu cloud image
Terminal window # Download Ubuntu 24.04 LTS minimal cloud imagewget https://cloud-images.ubuntu.com/minimal/releases/noble/release/ubuntu-24.04-minimal-cloudimg-amd64.img -
Resize the image
Terminal window # Resize to 32GB (adjust as needed)qemu-img resize ubuntu-24.04-minimal-cloudimg-amd64.img 32G -
Add serial console for cloud-init output
Terminal window # Replace VM-ID with your VM ID (e.g., 900)qm set VM-ID --serial0 socket --vga serial0 -
Import the image to your VM
Terminal window # Replace VM-ID with your VM ID (e.g., 900)# Replace 'local-lvm' with your storage if differentqm disk import VM-ID ubuntu-24.04-minimal-cloudimg-amd64.img local-lvm -
Attach the imported disk
- Return to the Proxmox web interface
- Go to your VM’s Hardware tab
- You’ll see an Unused Disk - double-click it to edit
- Configure the disk settings:
- Bus/Device: SCSI 0
- Cache: Default
- Discard: ✅ Enabled (if using SSD storage)
- SSD emulation: ✅ Enabled (if using SSD storage)
- Click Add to attach the disk
-
Clean up downloaded file
Terminal window # Remove the downloaded image file to save spacerm ubuntu-24.04-minimal-cloudimg-amd64.img
Step 4: Final Configuration and Template Creation
-
Configure boot order
- Go to Options tab in your VM
- Double-click Boot Order
- Ensure the imported disk is first in the boot order
- Enable the disk if it’s not already enabled
- Click OK
-
Configure additional options
- Start at boot: ✅ Enable if you want VMs to auto-start (optional)
-
Optional: Pre-configure the template with additional software
- If you want to customize the template before converting it, boot the VM
- Login using the cloud-init credentials you configured
- Install and configure additional software as needed:
Terminal window # Update package repositories and upgrade systemsudo apt update && sudo apt upgrade -y# Install SSH import utility for GitHub key managementsudo apt install -y ssh-import-idssh-import-id gh:YOUR-GITHUB-USERNAME# Install QEMU guest agent for better VM integrationsudo apt install -y qemu-guest-agentsudo systemctl enable --now qemu-guest-agent# Install commonly needed packagessudo apt install -y curl wget git vim htop# Clean up package cache and unnecessary packagessudo apt -y autoremove --purgesudo apt -y clean# Prepare template for cloning - clean cloud-init statesudo cloud-init clean -s -lsudo truncate -s 0 /etc/machine-idsudo truncate -s 0 /var/lib/dbus/machine-id# Clean potential DHCP leasessudo rm -f /var/lib/dhcp/*# Shutdown the VMsudo shutdown -h now -
Convert to template
- Right-click on your VM in the resource tree
- Select Convert to template
- Confirm the conversion
-
Verify template creation
- The VM should now show a template icon
- The template is ready for cloning
Step 5: Using Your Template
-
Clone the template
- Right-click on your template
- Select Clone
- Configure the clone:
- VM ID: New unique ID
- Name: Descriptive name for your new VM
- Mode: Full clone (recommended)
- Target Storage: Choose appropriate storage
-
Configure the cloned VM
- Hardware: Adjust CPU, memory, and disk size as needed
- Cloud-Init: Update user credentials, network config, SSH keys
- Options: Configure boot order, protection, etc.
-
Customize cloud-init for the clone
Terminal window # Example: Configure static IP# In the Cloud-Init tab, set IP Config to Manual:# IP: 192.168.1.100/24# Gateway: 192.168.1.1# DNS: 8.8.8.8 1.1.1.1 -
Start your new VM
- Start the VM
- Cloud-init will automatically configure the system on first boot
- SSH into the VM using the credentials you configured