中文 English

Proxmox VE VM Creation and Ubuntu 26.04 Unattended Installation: A Practical Guide

Published: 2026-04-25
PVE Proxmox Ubuntu cloud-init unattended-installation virtualization

Proxmox VE VM Creation and Ubuntu 26.04 Unattended Installation: A Practical Guide

Creating virtual machines and installing operating systems are among the most fundamental and frequent tasks in server operations and maintenance. While traditional interactive installation via VNC or IPMI is intuitive, it is inefficient—especially when deploying multiple servers in batches. This article provides a detailed walkthrough of how to leverage Proxmox VE (PVE) combined with Cloud-init technology to achieve fully automated unattended installation of Ubuntu 26.04 Server.

Background and Requirements

As a DevOps engineer, I frequently need to rapidly provision virtual machines in test environments. Interactive installation via VNC is time-consuming and prone to human error leading to inconsistent configurations. Therefore, I sought to establish a standardized workflow for VM creation and OS installation that is:

This article documents the complete实践 (practice) process, including encountered issues and their solutions.

Environment Overview

The environment for this operation is a Proxmox VE 9.0 virtualization server running on a local area network. Key configuration details:

Note: All sensitive information including IP addresses and hostnames has been redacted in this article. Only technical details are provided for reader reference.

Solution Selection

Before starting, I evaluated three common automated installation approaches:

Option 1: PVE Native Cloud-init Support

Advantages:

Disadvantages:

Option 2: Terraform + PVE Provider

Advantages:

Disadvantages:

Option 3: PXE Network Boot

Advantages:

Disadvantages:

After considering the actual project requirements and tech stack, I selected Option 1: Using PVE’s native Cloud-init functionality combined with Ubuntu’s autoinstall technology for unattended installation.

Implementation Steps

Step 1: Prepare Ubuntu 26.04 Installation Image

First, obtain the Ubuntu 26.04 Server installation image. Ubuntu 26.04 is an upcoming LTS release (still in development at time of writing), and its server edition provides complete autoinstall support.

# Check ISO directory on PVE storage
ls -la /mnt/pve/dsm10-iso/template/iso/ | grep ubuntu

Common ISO naming conventions:

After uploading the downloaded ISO file to PVE’s ISO storage directory, you can begin creating the virtual machine.

Step 2: Create the Virtual Machine

There are two ways to create VMs on PVE: via Web UI or command line. For batch operations or scripting scenarios, the command line is more efficient.

First, let’s look at the reference VM (VM 4519) configuration:

# View reference VM configuration
qm config 4519

Key configuration items include:

Config Item Value Description
ostype l26 Linux kernel 2.6+
bios ovmf UEFI boot
cores 2 CPU core count
cpu x86-64-v2-AES CPU type
memory 4096 Memory size (MB)
scsi0 local-lvm:vm-4519-disk-1,size=20G Primary disk
efidisk0 local-lvm:vm-4519-disk-0,size=4M EFI partition
sata0 local-lvm:vm-4519-cloudinit Cloud-init volume
net0 virtio=xx:xx:xx:xx:xx:xx,bridge=vmbr0 Network config

Since PVE’s qm create command cannot directly specify disk volumes to associate (they must exist first), a workaround is using the qm clone command to clone from an existing VM.

# Clone reference VM
qm clone 4519 4526 --name "VM-Ubuntu26.04-20G" --full

This command will:

  1. Create new VM ID (4526)
  2. Clone all disks (EFI disk, system disk, Cloud-init volume)
  3. Copy base configuration (CPU, memory, network, etc.)

After cloning, modify the VM configuration for new requirements:

# Modify VM name and tags
qm set 4526 --name "VM-Ubuntu26.04-20G" --tags ubuntu26.04

# Configure Cloud-init user (username)
qm set 4526 --ciuser margrop

# Configure Cloud-init password (password: xc112vm)
qm set 4526 --cipassword xc112vm

# Mount Ubuntu 26.04 ISO as installation medium
qm set 4526 --ide2 /mnt/pve/dsm10-iso/template/iso/ubuntu-26.04-live-server-amd64.iso,media=cdrom

# Set boot order: ISO first for installation, then disk after
qm set 4526 --boot order="ide2;scsi0"

Note: Cloned VMs replicate all disk contents from the source VM. If the source VM has an OS installed, cloned disks will still contain the original system data. For fresh installations, ensure cloning from a blank system or use alternative methods to create blank disks.

Step 3: Configure Cloud-init for Unattended Installation

Ubuntu Server 20.04 and later support fully automated OS installation through autoinstall technology. Combined with Cloud-init, you can achieve:

First, create Cloud-init configuration files. Cloud-init uses YAML format, primarily including user-data (user configuration) and meta-data (instance metadata) files.

user-data Configuration Example:

#cloud-config
autoinstall:
  version: 1
  identity:
    hostname: ubuntu
    username: margrop
    password: $6$v/wBNKhSNqXsLSTw$6V6Um5Jot07v2LJGyRtFHlqDYgzzbQGn9...
  ssh:
    install-server: true
    allow-pw: true
  storage:
    layout:
      name: lvm
      guipart: use-existing
  packages:
    - openssh-server
    - qemu-guest-agent
    - vim
    - net-tools
    - curl
    - wget
  late-commands:
    - systemctl enable qemu-guest-agent

Configuration Items Explained:

Config Item Description
identity.hostname System hostname
identity.username Initial username
identity.password User password (SHA-512 encrypted)
ssh.install-server Install SSH server
ssh.allow-pw Allow password authentication
storage.layout.name Partition layout scheme, lvm for LVM
packages Additional packages to install
late-commands Commands to execute after installation

Generating encrypted password:

# Generate SHA-512 encrypted password using openssl
openssl passwd -6 xc112vm

meta-data Configuration:

instance-id: ubuntu26-4526
local-hostname: ubuntu

Step 4: Create Cloud-init ISO

Cloud-init needs to be passed to the installer via ISO medium. The ISO file must meet these requirements:

Creating Cloud-init ISO on macOS or Linux:

Method 1: Using genisoimage (Recommended)

# Execute on PVE or Linux server
genisoimage -o cloudinit-4526.iso \
  -V CIDATA \
  -J \
  -r \
  /path/to/cloud-init-files/

Method 2: Using hdiutil (macOS)

cd /path/to/cloud-init-files
hdiutil makehybrid -o autoinstall.iso . -iso -joliet

After creation, upload the ISO to PVE storage:

# Upload to PVE
scp cloudinit-4526.iso root@<PVE-IP>:/mnt/pve/dsm10-iso/template/iso/

Step 5: Configure VM Boot and Execute Installation

Add Cloud-init ISO as the VM’s second CD-ROM drive and adjust boot order:

# Add Cloud-init ISO as second CD-ROM (ide3)
qm set 4526 --ide3 /mnt/pve/dsm10-iso/template/iso/cloudinit-4526.iso,media=cdrom

# Set boot order: ISO -> Cloud-init -> Disk
qm set 4526 --boot order="ide2;ide3;scsi0"

# Start VM
qm start 4526

After starting, the Ubuntu installer will automatically detect the CIDATA volume and execute unattended installation. The entire process requires no manual intervention, taking approximately 5-15 minutes (depending on network speed and hardware configuration).

Common Issues and Solutions

Issue 1: Insufficient Disk Space After Cloning

Error Message:

Volume group "pve" has insufficient free space

Cause: PVE uses LVM-thin storage pool. Cloning requires allocating new logical volumes. If storage pool space is insufficient, creation will fail.

Solutions:

  1. Clean up unused VMs and old snapshots

    # Delete unnecessary VMs
    qm destroy <vmid>
    
    # Delete old snapshots
    qm delsnapshot <vmid> <snapshot-name>
    
  2. Expand LVM-thin storage pool

    # Add new physical volume
    pvcreate /dev/sdX
    
    # Extend volume group
    vgextend pve /dev/sdX
    
    # Extend logical volume
    lvextend -L +XXXG /dev/pve/data
    
  3. Consider using Thin Provisioning mode

Issue 2: Cloud-init ISO Not Recognized

Symptom: After VM boots from ISO, interactive installation screen still appears.

Causes:

  1. ISO volume label is not CIDATA
  2. Incorrect file structure
  3. Incorrect boot order settings

Solutions:

  1. Verify ISO volume label

    # Linux/PVE
    volid /dev/srX
    
    # macOS
    diskutil info /dev/diskX | grep "Volume Name"
    
  2. Check ISO content structure

    # Mount ISO and inspect
    mount -o loop cloudinit.iso /mnt
    ls -la /mnt
    
  3. Ensure correct boot order

    qm set <vmid> --boot order="ide2;ide3;scsi0"
    

Issue 3: Cannot SSH After Installation

Symptom: Installation completes normally but cannot connect via SSH after.

Possible Causes:

  1. SSH service not installed or not started
  2. Firewall blocking SSH connections
  3. Network configuration error (cannot obtain IP)
  4. Incorrect password format in configuration

Solutions:

  1. Ensure openssh-server is installed in Cloud-init configuration

    packages:
      - openssh-server
    ssh:
      install-server: true
      allow-pw: true
    
  2. Check VM console logs

    # View VM startup logs
    qm terminal <vmid>
    
  3. Verify password format in Cloud-init configuration

    # Regenerate password in correct format
    openssl passwd -6 <password>
    

Automation Script Wrapper

To facilitate future rapid VM creation, I encapsulated the entire process into a script:

#!/bin/bash
# create_vm.sh - PVE VM Quick Creation Script

set -e

VM_ID=${1:-}
VM_NAME=${2:-}
ISO_PATH=${3:-}
USER_NAME=${4:-}
USER_PASS=${5:-}

if [ -z "$VM_ID" ] || [ -z "$VM_NAME" ] || [ -z "$ISO_PATH" ]; then
    echo "Usage: $0 <vm-id> <vm-name> <iso-path> [user] [password]"
    exit 1
fi

USER_NAME=${USER_NAME:-margrop}
USER_PASS=${USER_PASS:-xc112vm}

# Clone reference VM (requires reference VM to be created and configured first)
qm clone 4519 ${VM_ID} --name "${VM_NAME}" --full

# Configure VM
qm set ${VM_ID} --ciuser ${USER_NAME}
qm set ${VM_ID} --cipassword ${USER_PASS}
qm set ${VM_ID} --ide2 ${ISO_PATH},media=cdrom
qm set ${VM_ID} --boot order="ide2;scsi0"

# Create Cloud-init ISO
# ... (Cloud-init configuration generation code)

# Start VM
qm start ${VM_ID}

echo "VM ${VM_ID} created and started successfully!"

Usage example:

./create_vm.sh 4527 "VM-Ubuntu26.04-Test" \
  /mnt/pve/dsm10-iso/template/iso/ubuntu-26.04-live-server-amd64.iso \
  margrop xc112vm

Conclusion and Future Work

Through this article’s实践, we successfully implemented a complete workflow for creating VMs on Proxmox VE and automating Ubuntu 26.04 Server installation. Key takeaways include:

  1. Understood PVE VM creation mechanisms: Command-line provides more flexible control over VM creation aspects

  2. Mastered Cloud-init and autoinstall integration: Core technology for Ubuntu unattended installation

  3. Learned troubleshooting for common issues: Including insufficient storage space, ISO recognition problems, etc.

Areas for future optimization:

I hope this article helps运维 engineers with similar requirements. If you have any questions or suggestions, please feel free to discuss in the comments.

References


First published on 2026-04-25