Creating VM Templates with Cloud-Init
VM templates are pre-configured virtual machine images that serve as blueprints for rapid deployment. Unlike manually installing an operating system on each VM, templates allow you to clone fully configured systems in seconds. Cloud-init enables automated configuration of hostname, user accounts, SSH keys, and network settings during first boot.
Step-by-Step Process
Cloud-init is an industry-standard tool for initializing cloud instances. It runs on the first boot to configure the system based on metadata you provide, such as user credentials, SSH keys, and network settings.
1Create a Virtual Machine
Start by creating a new VM through the Proxmox web interface. Choose your desired Linux distribution ISO image (Ubuntu, Debian, CentOS, etc.). Configure the VM with appropriate CPU, memory, and disk size for your template needs.
2Remove ISO Attachment
After the VM is created but before converting to a template, detach the installation ISO from the VM's CD/DVD drive. This prevents the template from trying to boot from the ISO.
3Add Cloud-Init Drive
Navigate to the VM's hardware tab and add a Cloud-Init drive. This creates a special disk that stores cloud-init configuration data.
4Configure Cloud-Init Settings
Set up the default credentials and access methods for VMs cloned from this template:
- User: Define the default username for cloned VMs
- Password: Set a secure password (can be changed on individual clones)
- SSH Public Key: Paste your SSH public key for passwordless authentication
5Convert to Template
Right-click on the VM and select "Convert to Template". The VM icon will change to indicate it's now a template and can no longer be started directly.
6Clone the Template
To create a new VM from the template, right-click the template and select "Clone". Choose "Full Clone" for a completely independent copy, or "Linked Clone" for faster deployment with shared base disk (requires specific storage types like LVM-Thin or ZFS).
VM Template Workflow
Linux Containers (LXC)
Linux Containers (LXC) are lightweight virtualization solutions that share the host kernel while providing isolated userspace environments. Unlike full virtual machines that emulate hardware, containers have significantly lower overhead, faster startup times, and better resource efficiency. They're ideal for running multiple isolated services on the same host.
Understanding LXC Containers
Containers: Share the host kernel, faster startup (seconds), lower resource overhead, but limited to Linux guests only.
VMs: Full hardware emulation, can run any OS, complete isolation, but higher resource usage and slower startup.
Creating a Container Template
Step 1: Download Container Template
Container templates are pre-built minimal root filesystems for various Linux distributions.
Step 2: Create Container
1Click "Create CT"
- Node: Select the Proxmox host where the container will run
- CT ID: Unique identifier (e.g., 100, 101, 102...)
- Hostname: DNS hostname for the container (e.g., webserver01)
- Password: Root password for the container
- SSH Public Key: Optional but recommended for secure access
2Template Selection
3Root Disk Configuration
4CPU Allocation
5Memory Configuration
6Network Settings
Container Options
| Option | Description | Recommendation |
|---|---|---|
| Start at boot | Automatically start container when host boots | Enable for critical services |
| Unprivileged container | Runs with reduced privileges for better security | Always use unless app requires privileged mode |
| Shutdown order | Priority order during host shutdown | Set higher for database servers |
First Login and Hardening
After starting the container, you can log in through the Proxmox console using the root account and the password you set during creation.
Converting Containers to Templates
Creating reusable container templates ensures consistency across deployments and significantly speeds up provisioning. The key to a good template is removing all system-specific identifiers so each clone starts with a unique identity.
Why Remove SSH Keys and Machine IDs?
- SSH client warnings about changed host keys
- Potential man-in-the-middle attack vulnerabilities
- DHCP conflicts from duplicate machine IDs
Preparation Steps
Step 1: Update and Clean the System
Step 2: Delete SSH Host Keys
SSH host keys uniquely identify a machine. Removing them ensures each clone generates its own unique keys on first boot.
Step 3: Clear Machine ID
The machine ID is used by systemd, DHCP clients, and various system services to uniquely identify the host. Truncating (not deleting) this file allows systemd to regenerate a new unique ID on the first boot of each clone.
/var/lib/dbus/machine-id. If it exists and is not a symlink to
/etc/machine-id, truncate it as well.
Step 4: Power Off and Convert
In Proxmox web interface: Right-click container β Convert to Template
Cloning from Template
Right-click the template and select Clone β Full Clone. Give the clone a new CT ID and hostname.
Full Clone: Complete independent copy, no dependency on template, uses more storage.
Linked Clone: Uses template as base with copy-on-write, faster creation, less storage, but template cannot be deleted.
Post-Clone Configuration
After the first boot of your clone, you must regenerate SSH host keys since there's no Cloud-Init for LXC containers.
Regenerate SSH Host Keys
Additional Post-Clone Checklist
| Task | Command | Why? |
|---|---|---|
| Set hostname | hostnamectl set-hostname newname |
Identify the system on network |
| Configure static IP | Edit /etc/network/interfaces |
Prevent IP conflicts |
| Change passwords | passwd root; passwd username |
Security hardening |
| Update /etc/hosts | nano /etc/hosts |
Match new hostname |
Container Template Creation Workflow
Proxmox User Management
Proxmox supports multiple authentication realms, allowing you to choose where user credentials are stored and validated. Understanding these realms is crucial for implementing proper access control and security policies.
Authentication Realms Explained
| Realm | Type | Storage Location | Use Case |
|---|---|---|---|
| Linux PAM | pam | Host OS (/etc/passwd) | System administrators who need host shell access |
| Proxmox VE | pve | /etc/pve/user.cfg | Web UI-only users, API access, limited permissions |
| LDAP | ldap | External LDAP server | Enterprise environments with centralized auth |
| Active Directory | ad | Microsoft AD server | Windows-integrated environments |
| OpenID Connect | openid | External OIDC provider | Modern SSO integration (Google, Azure AD, etc.) |
PAM vs PVE Realm
- PAM Users: Real Linux users on the Proxmox host. Can SSH to the host and have shell access. Used for administrators.
- PVE Users: Exist only in Proxmox's internal database. Cannot SSH to host. Used for delegated VM management or API access.
Example: Creating a PVE User
Role-Based Access Control (RBAC)
Proxmox uses RBAC to assign permissions. A user's effective permissions are determined by their assigned roles on specific resources (VMs, storage, nodes, etc.).
Built-in Roles
| Role | Permissions | Typical Use |
|---|---|---|
| Administrator | Full control over everything | Infrastructure administrators |
| PVEAdmin | Manage VMs, containers, storage (no user management) | Operations team |
| PVEVMUser | Use and manage assigned VMs only | Developers, testers |
| PVEAuditor | Read-only access to all resources | Monitoring systems, auditors |
Example: Granting VM Access to a User
Backups vs Snapshots
Understanding the difference between backups and snapshots is critical for implementing an effective disaster recovery strategy. While both capture the state of a VM or container, they serve different purposes and have different characteristics.
Comparison Overview
| Feature | Snapshot | Backup |
|---|---|---|
| Speed | β Instant (seconds) | β Slow (minutes to hours) |
| Storage Location | Same storage as VM | Separate storage location |
| Survives Storage Failure | β No | β Yes |
| Captures RAM State | β Optional | β No |
| File Format | Delta on disk | Standalone archive (.tar.zst, .vma.zst) |
| Long-term Retention | β Not recommended | β Yes |
| Best For | Quick rollback before changes | Disaster recovery, migration |
When to Use Snapshots
- Before applying system updates or patches
- Before making configuration changes
- Before installing new software
- During development/testing (quick rollback)
When to Use Backups
- Scheduled daily/weekly protection
- Disaster recovery planning
- Long-term archival
- Migrating VMs to different hosts
- Compliance and audit requirements
Working with Snapshots
Creating a Snapshot
Restoring a Snapshot
Deleting Snapshots
Working with Backups
Backup Storage Configuration
Before creating backups, ensure you have a storage location configured for backup files:
Creating a Manual Backup
Backup Modes Explained
| Mode | Downtime | Consistency | Use Case |
|---|---|---|---|
| Snapshot | None (VM stays running) | May have inconsistencies in multi-disk setups | Default choice for most workloads |
| Suspend | Brief pause (seconds) | Good consistency | When you need better consistency without full shutdown |
| Stop | Full shutdown duration | Perfect consistency | Critical systems, databases (use maintenance window) |
Scheduling Automatic Backups
Manual backups are unreliable because humans forget. Automation is essential for proper data protection.
Backup Retention Policy
Instead of simply setting "Max Backups", modern Proxmox versions support granular retention:
| Setting | Recommended Value | Explanation |
|---|---|---|
| Keep Last | 3 | Always keep the 3 most recent backups |
| Keep Daily | 7 | Keep one backup per day for the last 7 days |
| Keep Weekly | 4 | Keep one backup per week for 4 weeks |
| Keep Monthly | 3 | Keep one backup per month for 3 months |
The 3-2-1 Backup Rule
Industry Standard Backup Strategy
Original + 2 backups
Local NAS + Cloud
Cloud or remote location
Backup Storage Options
Option 1: Proxmox Backup Server (PBS) β Recommended
- Deduplication: Drastically reduces storage usage across similar VMs
- Incremental backups: Only changed data is transferred
- Encryption: Built-in AES encryption
- Verification: Automatic integrity checks
- Fast restore: Mount backups as read-only volumes
Option 2: NAS (Network Attached Storage)
NAS devices like TrueNAS, Synology, or QNAP are popular for home labs and small businesses.
Option 3: USB Drive (Development/Testing Only)
Option 4: Cloud Storage (Offsite Copy)
Use tools like rclone to sync your backup directory to cloud providers (S3, Backblaze
B2, Google Drive, etc.) for offsite protection.
Restoring a Backup
Recommended Setup Summary
- Local backups to NAS via NFS (fast restores)
- Proxmox Backup Server on separate hardware (deduplication)
- Daily automated backups at 2 AM
- 7-day retention with monthly archives
- Weekly sync to cloud storage using rclone (offsite copy)
Comprehensive Backup Architecture
VMs & Containers
Fast Backups
Deduplicated
Offsite Copy
Integrating QNAP NAS for Backups
QNAP NAS devices provide excellent network storage for Proxmox backups. They support both NFS and SMB/CIFS protocols, with NFS being the preferred choice for Linux-based systems due to better performance and native compatibility.
Why QNAP NAS for Proxmox Backups?
- Dedicated storage: Separate hardware from your Proxmox host
- RAID protection: Built-in redundancy protects against disk failures
- Snapshots: QNAP's own snapshot feature adds another recovery layer
- Easy management: Web-based interface for configuration
- Expansion: Can easily add more drives as backup needs grow
Part 1: Configure NFS Share on QNAP
Step 1: Enable NFS Service
Step 2: Create Dedicated Backup Folder
Step 3: Configure NFS Permissions
- No squash: Preserves user IDs (UIDs). Required for Proxmox to write backups properly.
- Root squash: Maps root user to anonymous. Can cause permission errors.
- All squash: Maps all users to anonymous. Avoid for Proxmox backups.
Part 2: Add QNAP Share to Proxmox
Using NFS (Recommended)
Using SMB/CIFS (Alternative)
If you prefer SMB/CIFS or have mixed Windows/Linux environments:
Part 3: Configure Backup Job
Verification & Testing
Test Manual Backup
Verify on QNAP
Troubleshooting Common Issues
Issue: "Permission Denied" when backing up
- Check NFS permissions: must use "No squash"
- Verify Proxmox host IP is allowed in QNAP NFS settings
- Test manual connection:
showmount -e QNAP_IPfrom Proxmox shell
Issue: Export path not appearing in dropdown
- Manually type the export path: /proxmox-backups
- Verify NFS service is running on QNAP
- Check firewall rules on both Proxmox and QNAP
Best Practices for QNAP + Proxmox
- Create a dedicated QNAP user account specifically for Proxmox (never use admin account)
- Place QNAP and Proxmox on same VLAN for best performance
- Use Gigabit or 10GbE network for faster backup transfers
- Enable QNAP's snapshot feature on the backup volume for additional protection
- Set up QNAP email notifications for disk health alerts
- Consider enabling folder encryption on QNAP for sensitive VM backups
- Regularly test restore procedures to ensure backups are valid
QNAP NAS Integration Architecture
192.168.1.100
192.168.1.50
.vma.zst / .tar.zst
Proxmox Firewall Configuration
Proxmox includes a built-in firewall that operates at multiple levels: datacenter-wide, per-node, and per-VM/container. This layered approach provides granular control over network access while maintaining security.
Firewall Architecture Levels
Firewall Hierarchy
Global Rules
Host-level Rules
Individual Rules
| Level | Scope | Use Case |
|---|---|---|
| Datacenter | Applies to entire Proxmox cluster | Global security policies, common services |
| Node | Specific to one Proxmox host | Host management access (SSH, web UI) |
| VM/Container | Individual guest machine | Application-specific rules (web server, database) |
Emergency Recovery Access
If you lock yourself out by misconfiguring the firewall, use IPMI or KVM console access:
Initial Firewall Configuration
Step 1: Configure Rules BEFORE Enabling Firewall
Allow Web UI Access (Port 8006)
Allow SSH Access (Port 22)
Allow ICMP (Ping)
Step 2: Set Default Policy
Setting the input policy to DROP means all incoming traffic is blocked by default unless explicitly allowed by a rule. This is the most secure approach. Only traffic matching your ACCEPT rules will be permitted.
Step 3: Enable Firewall
Only after confirming all necessary rules are in place:
Per-VM/Container Firewall Rules
You can add specific rules for individual VMs or containers. For example, to allow HTTP/HTTPS to a web server VM:
Common Firewall Macros
| Macro | Port(s) | Protocol | Use Case |
|---|---|---|---|
| SSH | 22 | TCP | Secure shell access |
| HTTP | 80 | TCP | Web server (unencrypted) |
| HTTPS | 443 | TCP | Web server (encrypted) |
| Ping | - | ICMP | Network diagnostics |
| DNS | 53 | TCP/UDP | Name resolution |
| NTP | 123 | UDP | Time synchronization |
| MySQL | 3306 | TCP | Database server |
| PostgreSQL | 5432 | TCP | Database server |
Firewall Best Practices
- Always configure rules BEFORE enabling the firewall
- Use specific source IP ranges instead of allowing all (0.0.0.0/0)
- Keep IPMI or console access available as backup
- Document all firewall rules and their purposes
- Regularly audit and remove unused rules
- Use security groups for managing related VMs together
- Test changes in a lab environment first
- Enable logging for denied packets to troubleshoot issues
Firewall Logging
Enable logging to track firewall activity and troubleshoot connectivity issues:
Proxmox CLI Commands
While the Proxmox web interface is powerful, command-line tools provide faster access for experienced
administrators and enable automation through scripts. The primary tools are qm (QEMU
Manager for VMs) and pct (Proxmox Container Toolkit for LXC containers).
VM Management with qm
Basic VM Operations
Lists all virtual machines with their VMID, name, status, memory, and CPU allocation.
Starts VM with ID 101. The VM boots through its normal boot process.
Sends an ACPI shutdown signal to VM 101. The guest OS receives the signal and performs a graceful shutdown, similar to pressing the power button on a physical machine.
Gracefully reboots VM 101 by sending an ACPI reboot signal.
Performs a hard reset of VM 101. This is equivalent to pressing the reset button on a physical computer. Use only when a VM is unresponsive, as it can cause data corruption.
Immediately stops VM 101 without shutting down the guest OS. Equivalent to pulling the power plug. Use only in emergencies.
- shutdown: Graceful, safe, should be used normally
- reboot: Graceful restart, safe
- reset: Hard restart, can cause data loss
- stop: Hard shutdown, can cause data corruption
VM Configuration
Displays all configuration parameters for VM 101, including CPU, memory, disks, network interfaces, and boot options.
Enables automatic start of VM 101 when the Proxmox host boots. Use --onboot 0 to
disable.
Changes VM 101's RAM allocation to 2048 MB (2 GB). The VM must be shut down for this change to take effect.
Allocates 4 CPU cores to VM 101.
Changes the display name of VM 101 to "webserver01".
Advanced VM Operations
Creates a full clone of VM 101 as a new VM with ID 102.
Live-migrates VM 101 to another node called "pve2" in the cluster.
Container Management with pct
Basic Container Operations
Lists all containers with their CT ID, status, name, and resource allocation.
Starts container 104.
Gracefully shuts down container 104.
Restarts container 104.
Forcefully stops container 104.
Container Shell Access
Opens a root shell inside container 104. This is extremely useful for quick access without SSH.
Similar to docker exec -it. Type exit to leave the container shell.
pct enter works even if:
- The container has no SSH server installed
- Network configuration is broken
- You forgot the root password
Container Configuration
Displays all configuration options for container 104.
Enables auto-start on host boot for container 104.
Changes container 104's memory limit to 1024 MB.
Allocates 2 CPU cores to container 104.
Changes the hostname inside container 104.
Quick Reference Table
| Action | VM Command | Container Command |
|---|---|---|
| List all | qm list |
pct list |
| Start | qm start ID |
pct start ID |
| Graceful shutdown | qm shutdown ID |
pct shutdown ID |
| Force stop | qm stop ID |
pct stop ID |
| Reboot | qm reboot ID |
pct reboot ID |
| View config | qm config ID |
pct config ID |
| Change memory | qm set ID --memory MB |
pct set ID --memory MB |
| Auto-start on boot | qm set ID --onboot 1 |
pct set ID --onboot 1 |
| Shell access | N/A (use SSH or console) | pct enter ID |
Automation Examples
Bulk Start All VMs
Bulk Shutdown All Containers
List All Running VMs
Network Management & Segmentation
Proper network segmentation is crucial for security. By separating management traffic from VM traffic, you minimize the risk that a compromised VM can attack your Proxmox host or other infrastructure.
Why Separate Management and VM Networks?
- Isolation: Compromised VMs cannot directly access Proxmox management interface
- Attack Surface Reduction: Management interface not exposed to VM network
- Traffic Segmentation: Easier monitoring and troubleshooting
- Performance: Management traffic doesn't compete with VM workload traffic
Default Network Setup
By default, Proxmox creates a single Linux bridge (vmbr0) connected to your primary
network interface (e.g., enp5s0f0). Both management and VMs share this bridge.
Default Single Bridge Configuration
enp5s0f0
vmbr0
+ All VMs
Creating a Separate VM Network
Hardware Requirements
To properly separate networks, you need:
- Two physical network interfaces on your Proxmox host (or VLANs on a single interface)
- A managed switch that supports VLANs (for VLAN-based separation)
Step 1: Create Second Linux Bridge
Network Configuration Example
| Bridge | Physical Port | Network | Purpose |
|---|---|---|---|
| vmbr0 | enp5s0f0 | 192.168.1.0/24 | Proxmox management, SSH, web UI |
| vmbr1 | enp5s0f1 | 10.10.10.0/24 | VM and container traffic |
Step 2: Configure VMs to Use New Bridge
For new VMs:
For existing VMs:
VLAN-Based Segmentation
If you only have one physical network interface but a managed switch, you can use VLANs:
Segmented Network Architecture
192.168.1.0/24
vmbr0
10.10.10.0/24
vmbr1
VLAN 200
vmbr0.200
Firewall Rules for Network Segmentation
After segmenting networks, add firewall rules to enforce isolation:
Best Practices
- Use separate physical NICs for management and VM traffic when possible
- Place management network on a private subnet not accessible from the internet
- Use VLANs for additional segmentation (DMZ, production, development, etc.)
- Implement firewall rules to prevent VMs from accessing management interface
- Monitor network traffic for anomalies
- Document network topology and IP allocation
- Use static IPs for management interfaces
- Enable network bonding/teaming for redundancy
Shared Storage with TrueNAS
TrueNAS (formerly FreeNAS) is a powerful open-source network-attached storage (NAS) operating system based on FreeBSD. It provides enterprise-grade storage features like ZFS, snapshots, replication, and high availability. Integrating TrueNAS with Proxmox enables centralized storage for VMs, containers, backups, and ISO images.
Why Use TrueNAS with Proxmox?
- ZFS Filesystem: Advanced features like snapshots, compression, deduplication, and self-healing
- Centralized Storage: Multiple Proxmox nodes can share the same storage pool
- Data Protection: RAID-Z provides redundancy against disk failures
- Backup Target: Ideal for storing Proxmox backups
- Scalability: Easy to expand storage by adding more disks
- Snapshots: Quick point-in-time copies for additional protection
Creating a Dataset on TrueNAS
Step 1: Create Storage Pool
If you haven't already created a ZFS pool on TrueNAS:
Step 2: Create Dataset for Proxmox
Step 3: Configure Permissions
Sharing Storage via NFS
Step 1: Enable NFS Service
Step 2: Create NFS Share
Adding TrueNAS Storage to Proxmox
For VM/Container Storage
For Backups (Separate Dataset Recommended)
Create a second dataset specifically for backups:
Storage Types and Use Cases
| Content Type | Description | Use Case |
|---|---|---|
| Disk image | Virtual machine disk files | Store VM hard drives on TrueNAS |
| Container | LXC container root filesystems | Store containers on TrueNAS |
| VZDump backup file | Proxmox backup archives | Store backups on TrueNAS |
| ISO image | Installation media | Centralized ISO library |
| Container template | LXC templates | Shared template storage |
Using Shared Storage
Creating a VM on TrueNAS Storage
Migrating Existing VM to TrueNAS
TrueNAS Snapshots for Additional Protection
TrueNAS ZFS snapshots are independent of Proxmox snapshots and provide an additional recovery layer:
Schedule Automatic Snapshots
Performance Considerations
- Use 10 Gigabit Ethernet for better performance with multiple VMs
- Enable ZFS compression (LZ4) - minimal CPU overhead, significant space savings
- Add L2ARC (read cache) using SSD for frequently accessed data
- Add SLOG (write cache) using fast SSD for sync writes
- Disable unnecessary features like deduplication (high RAM usage)
- Use appropriate record size for your workload
TrueNAS + Proxmox Architecture
VMs & Containers
ZFS Storage Pool
VMs & Containers
Proxmox Clustering (Without High Availability)
A Proxmox cluster allows you to manage multiple Proxmox nodes from a single web interface, share resources, and migrate VMs between hosts. This section covers basic clustering without high availability featuresβHA requires at least 3 nodes and is covered in the next section.
What is a Proxmox Cluster?
- Unified Management: Manage all nodes from one web interface
- Live Migration: Move running VMs between nodes with zero downtime
- Resource Pooling: Shared storage enables flexible VM placement
- Centralized Configuration: User permissions, firewall rules, and settings sync across nodes
- Distributed Storage: Share storage backends like Ceph, NFS, or iSCSI across cluster
Prerequisites
- At least 2 Proxmox nodes (can be physical servers or VMs)
- Each node must have unique hostname and IP address
- All nodes must be on the same network or have reliable network connectivity
- Time synchronization (NTP) across all nodes
- For migration: shared storage (NFS, Ceph, iSCSI, etc.) or sufficient bandwidth for offline migration
Network Preparation
Before creating a cluster, configure a dedicated network bridge on each Proxmox node for cluster communication. This is optional but recommended for separating cluster traffic from VM traffic.
Create Cluster Network Bridge (on each node)
- Better performance for live migration
- Isolation from management traffic
- Reduced latency for cluster synchronization
Creating the Cluster
Step 1: Create Cluster on Primary Node
Step 2: Get Join Information
Step 3: Join Additional Nodes to Cluster
- During join, the second node will temporarily lose web UI access (1-2 minutes)
- The second node's configuration will be synchronized with the cluster
- After joining, refresh the browser or reboot if the node doesn't appear
- Check primary node console for join status messages if UI doesn't update
Step 4: Verify Cluster
VM/Container Migration
Once clustered, you can migrate VMs and containers between nodes. There are two types of migration:
Offline Migration (VM powered off)
Suitable when you don't need zero downtime. Works with both local and shared storage.
Online/Live Migration (VM stays running)
Zero-downtime migration. Requires shared storage or very fast network.
- Move the Cloud-Init disk to shared storage first
- Remove the Cloud-Init disk before migration (lose cloud-init functionality)
- Use offline migration instead
Migration Performance Considerations
| Scenario | Speed | Downtime | Requirements |
|---|---|---|---|
| Offline + Shared Storage | β‘ Instant | β Yes (shutdown) | Shared NFS/Ceph/iSCSI |
| Offline + Local Storage | π Slow (disk copy) | β Yes (shutdown) | None |
| Online + Shared Storage | β‘ Fast (seconds) | β No | Shared storage + good network |
| Online + Local Storage | π Very slow | β No (but risky) | 10GbE network recommended |
Troubleshooting Cluster Issues
Node Not Appearing After Join
- Wait 2-3 minutes and refresh browser
- Check primary node's console for error messages
- Verify network connectivity between nodes:
ping node_ip - Check cluster status:
pvecm status - Reboot the joining node if configuration sync failed
Cannot Join Cluster
- Incorrect root password for primary node
- Network connectivity issues (firewall, routing)
- Time synchronization problems (check NTP)
- Node already part of another cluster (must remove first)
Cluster Management Commands (CLI)
Shows cluster status, quorum information, and node list.
Lists all nodes in the cluster.
Temporarily allows cluster to operate with only 1 node (emergency use only).
Basic Cluster Architecture
192.168.1.10
Cluster Leader
192.168.1.11
Cluster Member
NFS/Ceph/iSCSI
High Availability Clustering
High Availability (HA) is a critical feature that automatically restarts VMs on surviving nodes when a Proxmox host fails. This minimizes downtime and ensures business continuity. However, HA is fundamentally different from basic clustering and has specific requirements.
Understanding High Availability
Without HA Standalone
What happens when server crashes?
Everything on that server goes offline. You must manually diagnose, fix the hardware, and restart VMs. Downtime could be minutes, hours, or days depending on the severity.
Think of it like: A restaurant with one chef. If the chef gets sick, the restaurant closes until they recover.
Recovery: 100% manual, depends on human response time
With HA Cluster
What happens when server crashes?
The cluster detects the failure within seconds, automatically fences the dead node, and restarts protected VMs on surviving nodes. Downtime is typically 1-2 minutes with no human intervention.
Think of it like: A restaurant with three chefs. If one is sick, the other two automatically cover the shift.
Recovery: Fully automated, predictable downtime
What HA Protects vs. What It Doesn't
- Server hardware failure (CPU, RAM, motherboard, power supply)
- Complete host crash or kernel panic
- Network isolation of a node
- Power loss to a single node
- Accidental file deletion inside a VM
- Bad software updates corrupting VM data
- Guest OS bugs or crashes
- Ransomware or malware
- Shared storage failure (all nodes lose access)
- Datacenter-wide power/network outage
The Quorum Problem: Why 3 Nodes Minimum?
Understanding Split-Brain
Imagine you have 2 nodes and the network link between them breaks. Both nodes are still running, but they can't communicate. Each node faces an impossible question:
"Did the other node crash, or is it just our connection that broke?"
If both nodes assume the other is dead and try to take over the same VMs and shared storage simultaneously, you get split-brainβtwo nodes writing to the same disk at the same time, causing catastrophic data corruption.
How Quorum Solves This
Quorum requires a majority vote to make cluster decisions. The math is simple:
| Total Nodes | Majority Required | Can Lose | Result |
|---|---|---|---|
| 2 | 2 | 0 | β If 1 fails, you have 1/2 votes = no majority. Cluster freezes. No HA benefit. |
| 3 | 2 | 1 | β If 1 fails, you have 2/3 votes = majority. Cluster knows which node failed and safely restarts VMs. |
| 5 | 3 | 2 | β Can lose 2 nodes and maintain quorum. |
| 7 | 4 | 3 | β Can lose 3 nodes and maintain quorum. |
A cluster can tolerate losing βn/2β nodes (rounding down).
Why odd numbers? With 4 nodes, you can still only lose 1 node (same as 3 nodes). The 4th node doesn't improve fault tolerance but adds cost and complexity. Always use odd numbers: 3, 5, 7, etc.
Workaround for 2-Node Clusters
Proxmox supports a QDevice (Quorum Device)βa lightweight third voter that doesn't run VMs. This can be:
- A Raspberry Pi
- A small VM on a separate physical host
- A low-power miniPC
The QDevice breaks ties in split-brain scenarios. However, 3 full nodes is still the recommended approach for production environments.
Setting Up High Availability
Prerequisites
- At least 3 Proxmox nodes in a working cluster
- Shared storage accessible from all nodes (NFS, Ceph, iSCSI, etc.)
- Reliable network connectivity between all nodes
- VMs you want to protect must be on shared storage
Step 1: Move VM to Shared Storage
HA only works with VMs on shared storage. If your VM is on local storage, move it first:
Step 2: Configure HA Resource
Step 3: Start the VM
HA Configuration Parameters Explained
| Parameter | Description | Recommended Value |
|---|---|---|
| Request State | Desired state of the VM | started - VM should always run; stopped - stop the VM but keep HA monitoring; ignored - temporarily disable HA |
| Max Restart | Attempts to restart on same node before relocating | 1-2 for most cases; prevents repeated failures on bad hardware |
| Max Relocate | Attempts to relocate to other nodes | 1-2; prevents VM bouncing between nodes indefinitely |
| Group | Preferred nodes for VM placement | Optional; useful for workload distribution |
Testing High Availability
After configuring HA, you should test it to ensure it works as expected.
Safe Test Method
sysrq-trigger command immediately reboots the node
without gracefully shutting down services. Only use this in a test environment or during scheduled
maintenance. Never use it on production systems without planning.
What to Expect During Failover
- 0-10 seconds: Cluster detects node is unresponsive
- 10-30 seconds: Quorum confirms node is dead, begins fencing
- 30-60 seconds: HA manager selects a new node and starts VM boot process
- 60-120 seconds: VM boots on new node and becomes accessible
- VM boot time (larger VMs take longer)
- Storage speed (faster storage = faster boot)
- Network latency between nodes
- Cluster load (other VMs competing for resources)