Introduction
VM templates in Proxmox provide a powerful way to standardize and accelerate virtual machine deployments. Instead of manually configuring each new VM from scratch, you can create a template once and clone it as many times as needed, ensuring consistency across your infrastructure.
Common use cases for VM templates:
- Rapid deployment of multiple identical servers
- Testing environments that need to be quickly provisioned and destroyed
- CI/CD pipeline workers that require consistent configurations
- Development environments for team members
- Staging environments that mirror production
A template is essentially a read-only VM configuration that serves as a blueprint. Once converted to a template, the VM cannot be started or modified directly, ensuring the template remains pristine for cloning operations.
Prerequisites
Before creating a VM template, ensure you have:
- Proxmox VE installed and accessible (tested with 6.x, 7.x, 8.x)
- An existing VM that you want to convert to a template
- Administrative access to the Proxmox web interface
- Basic familiarity with Proxmox VM management
Recommended before templating:
- Remove machine-specific data (SSH host keys, logs, temporary files)
- Update the OS and install common software packages
- Configure cloud-init if planning to automate deployments
- Test the VM thoroughly to ensure it works as expected
Part 1: Prepare the Source VM
Before converting a VM to a template, it’s important to prepare it properly to ensure clean clones.
1. Clean Up the Source VM
SSH into the VM and remove machine-specific data:
# Remove SSH host keys (regenerated on first boot of clone)
sudo rm -f /etc/ssh/ssh_host_*
# Clear machine ID
sudo truncate -s 0 /etc/machine-id
# Clear command history
history -c
cat /dev/null > ~/.bash_history
# Remove temporary files
sudo rm -rf /tmp/*
sudo rm -rf /var/tmp/*
# Clear logs (optional but recommended)
sudo truncate -s 0 /var/log/wtmp
sudo truncate -s 0 /var/log/btmp
sudo find /var/log -type f -name "*.log" -exec truncate -s 0 {} \;
2. Update and Configure Software
# Update all packages to latest versions
sudo apt update && sudo apt upgrade -y
# Install commonly needed tools
sudo apt install -y qemu-guest-agent cloud-init
# Enable QEMU guest agent (allows Proxmox to query VM info)
sudo systemctl enable qemu-guest-agent
sudo systemctl start qemu-guest-agent
3. Shutdown the VM
Once preparation is complete, shut down the VM cleanly:
sudo shutdown -h now
Or from the Proxmox shell:
qm shutdown <vmid>
⚠️ Important: Never convert a running VM to a template. Always shut down first to avoid corruption.
Part 2: Create the Template
Now that the VM is prepared and shut down, you can create a template using the Proxmox web interface or command line.
Method A: Using Proxmox Web Interface (Recommended)
Log into Proxmox web interface (https://your-proxmox-ip:8006)
Navigate to the VM you want to convert in the left sidebar
Verify VM is stopped - Status should show “stopped”
Right-click the VM and select
Convert to Template
Confirm the conversion - Click “Yes” in the confirmation dialog
Verify template creation - The VM icon will change to a template icon (looks like a document)
Note: This operation is irreversible via the GUI. The VM is now a template and cannot be started directly.
Method B: Using Proxmox Command Line
SSH into the Proxmox host and run:
# Convert VM with ID 9000 to template
qm template 9000
Example output:
Converted VM 9000 to template
Part 3: Clone the Template
Now that you have a template, you can create new VMs by cloning it.
Using Proxmox Web Interface
Right-click the template in the sidebar
Select
Clone
Configure clone settings:
- Target Node: Select which Proxmox node to create the clone on
- VM ID: Assign a unique ID (e.g., 101, 102, 103)
- Name: Enter a descriptive name (e.g.,
web-server-01) - Mode: Choose clone type:
- Full Clone: Independent copy (recommended for production)
- Linked Clone: Depends on template (faster, uses less space, good for testing)
- Target Storage: Select where to store the new VM’s disk
Click
Cloneto create the new VMStart the cloned VM - The new VM can now be started and configured
Using Command Line
# Full clone from template 9000 to new VM 101
qm clone 9000 101 --name web-server-01 --full
# Linked clone (faster, smaller)
qm clone 9000 102 --name test-server-01
# Clone to specific storage
qm clone 9000 103 --name db-server-01 --full --storage local-lvm
Expected output:
create full clone of drive scsi0 (local-lvm:vm-9000-disk-0)
Formatting '/var/lib/vz/images/101/vm-101-disk-0.qcow2', fmt=qcow2 size=34359738368
transferred: 0 bytes remaining: 34359738368 bytes total: 34359738368 bytes progression: 0.00 %
...
transferred: 34359738368 bytes remaining: 0 bytes total: 34359738368 bytes progression: 100.00 %
Part 4: Post-Clone Configuration
After cloning, you’ll need to customize the new VM to make it unique.
1. Start the Cloned VM
# From Proxmox shell
qm start 101
# Or use the GUI: Select VM -> Start button
2. Regenerate Machine-Specific Data
SSH into the new VM and regenerate SSH host keys:
# Regenerate SSH host keys
sudo dpkg-reconfigure openssh-server
# Generate new machine ID
sudo systemd-machine-id-setup
# Verify new machine ID was created
cat /etc/machine-id
3. Configure Network Settings
If using static IPs (recommended for servers):
# Edit netplan configuration
sudo nano /etc/netplan/00-installer-config.yaml
Example static IP configuration:
network:
version: 2
ethernets:
ens18:
addresses:
- 192.168.1.101/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
Apply the configuration:
sudo netplan apply
4. Update Hostname
# Set new hostname
sudo hostnamectl set-hostname web-server-01
# Update /etc/hosts
sudo nano /etc/hosts
# Change old hostname to new one
Converting a Template Back to a VM
If you need to modify a template, you must first convert it back to a regular VM.
⚠️ Warning: This is irreversible via GUI. Consider cloning the template instead of converting it.
Using Command Line Only
# Convert template 9000 back to a regular VM
qm set 9000 --template 0
Better approach: Clone the template, modify the clone, then create a new template:
# Clone template to temporary VM
qm clone 9000 999 --name temp-template-update --full
# Start and modify VM 999
qm start 999
# Make your changes via SSH...
# Shutdown and convert to new template
qm shutdown 999
qm template 999
# Delete old template (optional)
qm destroy 9000
Best Practices
Template Organization
Naming Convention:
- Use descriptive names:
ubuntu-22.04-template,debian-12-minimal-template - Include OS version and purpose:
rocky-9-webserver-template - Add date for versioning:
ubuntu-22.04-template-2024-12
Storage Considerations:
- Store templates on fast, redundant storage
- Use SSD storage for templates that will be cloned frequently
- Keep templates small (remove unnecessary packages and data)
Template Maintenance
Regular Updates:
# Quarterly update workflow
# 1. Clone template to temporary VM
qm clone 9000 999 --name template-update --full
qm start 999
# 2. SSH in and update packages
ssh user@temp-vm
sudo apt update && sudo apt dist-upgrade -y
# 3. Clean up and shutdown
# (run cleanup commands from Part 1)
sudo shutdown -h now
# 4. Create new template version
qm template 999
# 5. Test the new template by cloning it
qm clone 999 1000 --name test-clone --full
# Test thoroughly...
# 6. Rename for version tracking
qm set 999 --name ubuntu-22.04-template-2024-12
Multiple Template Strategy
Create specialized templates for different use cases:
- Minimal Template: Basic OS only (fastest to clone)
- Web Server Template: OS + Nginx/Apache + common tools
- Database Template: OS + PostgreSQL/MySQL + backup tools
- Development Template: OS + dev tools + IDE + compilers
Example template inventory:
9000: ubuntu-22.04-minimal-template
9001: ubuntu-22.04-webserver-template
9002: ubuntu-22.04-database-template
9003: debian-12-docker-template
Troubleshooting
Template Won’t Clone
Symptoms:
Error: storage 'local-lvm' does not support snapshots
Solution: Use full clone instead of linked clone
qm clone 9000 101 --full
Cloned VM Has Same IP/Hostname
Cause: Network configuration not updated after cloning
Solution: Update network config and hostname (see Part 4)
Template Uses Too Much Space
Solution: Clean up unnecessary files before templating
# Remove package cache
sudo apt clean
# Remove old kernels
sudo apt autoremove --purge
# Clear systemd journal
sudo journalctl --vacuum-time=1d
Can’t Start Template
Cause: Templates cannot be started directly (this is by design)
Solution: Clone the template first, then start the clone
Next Steps
Now that you have a working template, you can:
- Automate cloning with Terraform (see related post: “How to Automate Proxmox with Terraform”)
- Configure cloud-init for automatic VM customization (see related post: “How to Create a Cloud-Init Template”)
- Create multiple templates for different server types
- Set up a template update schedule to keep templates current
Related Guides
- How to Automate Proxmox VM Creation with Terraform
- How to Create a Cloud-Init Template VM in Proxmox
- How to Resize an Ubuntu VM Disk in Proxmox
Last updated: November 2025