Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save OsoianMarcel/df507980c0cbb38ec13b6be1ede9161f to your computer and use it in GitHub Desktop.
Save OsoianMarcel/df507980c0cbb38ec13b6be1ede9161f to your computer and use it in GitHub Desktop.
Proxmox VM Template Creation Script for Ubuntu 25 Cloud Image
# This creates a reusable VM template that can be cloned for quick deployments.
# Create a new VM with ID 900 and basic configuration
qm create 900 \
--name 'ubuntu-server-25-cloud' \
--memory 2048 \
--cores 2 \
--net0 virtio,bridge=vmbr0
# Import the cloud image disk into the local-lvm storage
# Replace "plucky-server-cloudimg-amd64.img" with your actual cloud image file.
qm importdisk 900 /var/lib/vz/template/iso/plucky-server-cloudimg-amd64.img local-lvm
# Attach the imported disk as a SCSI drive and enable SSD emulation
qm set 900 --scsihw virtio-scsi-pci \
--scsi0 local-lvm:vm-900-disk-0,ssd=1
# Resize the disk by an additional 10GB
qm disk resize 900 scsi0 +10G
# Configure the VM to boot from the SCSI disk
qm set 900 \
--boot c \
--bootdisk scsi0
# Add a Cloud-Init drive for configuration
qm set 900 --ide2 local-lvm:cloudinit
# Enable serial console and use it as the display
qm set 900 \
--serial0 socket \
--vga serial0
# Set the operating system type to Linux 2.6/3.x/4.x/5.x (generic)
qm set 900 --ostype l26
# Enable DHCP networking on the first interface
qm set 900 --ipconfig0 ip=dhcp
# Set default Cloud-Init credentials
# The --cipassword should be replaced with a secure password or consider using SSH keys.
qm set 900 \
--ciuser ubuntu \
--cipassword 'qwerty'
# Convert the VM to a template
qm template 900
# Post-Cloning Recommendation
# After cloning this template, log in to the VM and install the QEMU Guest Agent to enable enhanced VM management features (e.g., IP reporting, graceful shutdown, etc.):
# sudo apt install -y qemu-guest-agent
# Then, in the Proxmox web UI, go to the cloned VM’s Options tab and set QEMU Guest Agent: Enabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment