πŸ–₯️ Proxmox Expert Guide

Complete Documentation for Virtual Machines, Containers, Templates & Advanced Configuration

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

πŸ’‘ What is Cloud-Init?
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.

Hardware β†’ CD/DVD Drive β†’ Do not use any media

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.

Hardware β†’ Add β†’ CloudInit Drive β†’ Storage: local-lvm

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
Cloud-Init β†’ User: admin Cloud-Init β†’ Password: YourSecurePassword Cloud-Init β†’ SSH public key: ssh-rsa AAAAB3NzaC1yc2E...

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).

βœ… Best Practice: Always use full clones for production environments to ensure complete independence between VMs. Linked clones are faster but create dependencies on the original template disk.

VM Template Workflow

Create VM
β†’
Remove ISO
β†’
Add Cloud-Init
β†’
Configure
β†’
Convert to Template
β†’
Clone as Needed

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

πŸ” Key Difference: Containers vs VMs
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.

Local (pve) β†’ Right-click β†’ CT Templates β†’ Templates β†’ Ubuntu β†’ Ubuntu 20.04 β†’ Download

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

Storage: local Template: ubuntu-20.04-standard_20.04-1_amd64.tar.gz

3Root Disk Configuration

Storage: local-lvm Disk size (GiB): 16

4CPU Allocation

Cores: 2

5Memory Configuration

Memory (MiB): 1024 Swap (MiB): 1024

6Network Settings

IPv4: DHCP (or static IP) IPv6: DHCP (or disable if not needed)

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
⚠️ Security Note: Unprivileged containers run as non-root users on the host system and cannot directly access host resources. While more secure, some applications (like Docker or nested virtualization) require privileged containers. Use privileged mode only when absolutely necessary.

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.

πŸ”’ Important Security Note: By default, SSH root login is disabled in most Linux distributions for security reasons. You'll need to either create a regular user account or enable root SSH access (not recommended for production).
adduser admin usermod -aG sudo admin su - admin

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?

πŸ” Security Concern: If you clone a container without removing SSH host keys, all clones will share the same SSH identity. This causes:
  • 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

sudo apt update && sudo apt upgrade -y sudo apt clean sudo apt autoremove -y

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.

cd /etc/ssh sudo rm ssh_host_*

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.

cat /etc/machine-id sudo truncate -s 0 /etc/machine-id
πŸ’‘ Additional Consideration: On some distributions, you should also check /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

sudo poweroff

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 vs Linked Clone:
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

cd /etc/ssh ls sudo dpkg-reconfigure openssh-server

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

Create Container
β†’
Update System
β†’
Remove SSH Keys
β†’
Clear Machine ID
β†’
Convert to Template
β†’
Clone β†’ Regenerate Keys

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

πŸ”‘ Key Differences:
  • 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

Datacenter β†’ Permissions β†’ Users β†’ Add User name: johndoe Realm: Proxmox VE authentication server Group: (optional, for easier permission management)

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
βœ… Best Practice: Create PVE realm users for team members and assign them minimal permissions needed for their tasks. Reserve PAM realm accounts only for infrastructure administrators who need host-level access.

Example: Granting VM Access to a User

Select VM β†’ Permissions β†’ Add β†’ User Permission User: johndoe@pve Role: PVEVMUser Propagate: Yes (if you want permissions on child objects)

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

βœ… Use Snapshots For:
  • Before applying system updates or patches
  • Before making configuration changes
  • Before installing new software
  • During development/testing (quick rollback)
⏱️ Duration: Delete snapshots within hours or days. Never keep them long-term.

When to Use Backups

βœ… Use Backups For:
  • Scheduled daily/weekly protection
  • Disaster recovery planning
  • Long-term archival
  • Migrating VMs to different hosts
  • Compliance and audit requirements
⚠️ Critical Warning: On LVM-Thin storage, accumulating snapshots can cause severe performance degradation and even fill your storage pool. Always clean up snapshots after you're done with them. Snapshots are NOT a replacement for proper backups!

Working with Snapshots

Creating a Snapshot

1. Select VM/Container β†’ Snapshots tab 2. Click "Take Snapshot" 3. Name: before-nginx-upgrade (descriptive name) 4. Description: Snapshot before upgrading nginx to 1.21 5. Include RAM: βœ… (if VM is running and you want to resume exactly)
πŸ’‘ RAM Snapshots: Including RAM allows you to restore the VM to its exact running state, with all processes still active. This is useful for testing but increases snapshot size significantly. For containers, RAM snapshots are not supported.

Restoring a Snapshot

1. Select VM/Container β†’ Snapshots tab 2. Select the snapshot you want to restore 3. Click "Rollback" 4. Confirm the action
⚠️ Data Loss Warning: Rolling back a snapshot discards ALL changes made after the snapshot was taken. This action cannot be undone. Make sure you understand what you're about to lose before confirming.

Deleting Snapshots

1. Snapshots tab β†’ Select snapshot 2. Click "Delete" 3. Confirm deletion

Working with Backups

Backup Storage Configuration

Before creating backups, ensure you have a storage location configured for backup files:

Datacenter β†’ Storage β†’ Check for "VZDump backup file" in Content column

Creating a Manual Backup

1. Select VM/Container β†’ Backup tab 2. Click "Backup Now" 3. Storage: Select backup storage location 4. Mode: Snapshot (default, minimal downtime) 5. Compression: ZSTD (recommended: fast + efficient) 6. Note: Optional description 7. Click "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.

1. Datacenter β†’ Backup β†’ Add 2. Node: Select your Proxmox node (or "All" for clusters) 3. Storage: Where to save backups 4. Schedule: 00:00 (daily at midnight) or "sun 02:00" (weekly) 5. Selection Mode: All (automatically includes new VMs) 6. Mode: Snapshot 7. Compression: ZSTD 8. Send email: Always (or "On failure") 9. Enable: βœ…

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
πŸ’Ύ Storage Planning: This retention policy gives you recovery points spanning 3 months while automatically pruning old backups. A typical 20GB VM might use ~150GB with this policy, depending on how much data changes between backups.

The 3-2-1 Backup Rule

Industry Standard Backup Strategy

3 Copies
Original + 2 backups
+
2 Media Types
Local NAS + Cloud
+
1 Offsite
Cloud or remote location

Backup Storage Options

Option 1: Proxmox Backup Server (PBS) ⭐ Recommended

Why PBS is the Best Choice:
  • 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
1. Install PBS on a separate physical machine or dedicated VM 2. In Proxmox: Datacenter β†’ Storage β†’ Add β†’ Proxmox Backup Server 3. Server: PBS_IP_ADDRESS 4. Username: username@pbs 5. Datastore: name_of_datastore_on_PBS

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)

⚠️ Not Recommended for Production: USB drives fail frequently, have limited write cycles, and you might forget to plug them in. Use only for temporary testing scenarios.

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

1. Navigate to your backup storage in left panel (e.g., "local") 2. Click "Backups" or "Content" tab 3. Find and select the backup file 4. Click "Restore" 5. Target storage: Where to restore the disk 6. VM ID: Keep same or choose new ID to preserve original 7. Click "Restore"

Recommended Setup Summary

βœ… Ideal Home Lab Setup:
  • 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

Proxmox Host
VMs & Containers
β†’
Local NAS
Fast Backups
β†’
PBS Server
Deduplicated
β†’
Cloud Storage
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

1. Log into QNAP web interface 2. Control Panel β†’ Network & File Services β†’ Win/Mac/NFS/WebDAV 3. Click "NFS Service" tab 4. Enable NFS service β†’ Apply

Step 2: Create Dedicated Backup Folder

1. Open File Station 2. Navigate to your main volume (e.g., /Volume1) 3. Create new folder: "proxmox-backups"

Step 3: Configure NFS Permissions

1. Right-click "proxmox-backups" folder β†’ Properties 2. Click "NFS Host Access" tab 3. Click "Add" button 4. Host/IP: 192.168.1.100 (your Proxmox host IP) 5. OR for entire subnet: 192.168.1.0/24 6. Privilege: Read/Write 7. Squash: No squash (important!) 8. Click "Apply"
⚠️ Squash Option Explained:
  • 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)

1. Proxmox web UI β†’ Datacenter β†’ Storage β†’ Add β†’ NFS 2. ID: qnap-backups (unique identifier) 3. Server: 192.168.1.50 (your QNAP's IP address) 4. Export: /proxmox-backups (click dropdown to auto-detect) 5. Content: βœ… VZDump backup file 6. Max Backups: 7 (or leave empty to control per job) 7. Nodes: All (or select specific nodes in cluster) 8. Enable: βœ… 9. Click "Add"

Using SMB/CIFS (Alternative)

If you prefer SMB/CIFS or have mixed Windows/Linux environments:

1. Ensure Samba service is enabled on QNAP 2. Proxmox β†’ Datacenter β†’ Storage β†’ Add β†’ SMB/CIFS 3. ID: qnap-backups-smb 4. Server: 192.168.1.50 5. Share: proxmox-backups 6. Username: your_qnap_username 7. Password: your_qnap_password 8. Content: βœ… VZDump backup file 9. Click "Add"

Part 3: Configure Backup Job

1. Datacenter β†’ Backup β†’ Add (or edit existing job) 2. Storage: qnap-backups 3. Schedule: 02:00 (daily at 2 AM) 4. Selection Mode: All 5. Mode: Snapshot 6. Compression: ZSTD 7. Retention: Keep Last 3, Daily 7, Weekly 4, Monthly 3 8. Email: [email protected] (for notifications) 9. Click "Create"

Verification & Testing

Test Manual Backup

1. Select any VM β†’ Backup tab 2. Click "Backup Now" 3. Storage: qnap-backups 4. Mode: Snapshot 5. Click "Backup"

Verify on QNAP

1. Open QNAP File Station 2. Navigate to /proxmox-backups/dump/ 3. Verify .vma.zst or .tar.zst files appear 4. Check file sizes are reasonable

Troubleshooting Common Issues

Issue: "Permission Denied" when backing up

Solution:
  • Check NFS permissions: must use "No squash"
  • Verify Proxmox host IP is allowed in QNAP NFS settings
  • Test manual connection: showmount -e QNAP_IP from Proxmox shell

Issue: Export path not appearing in dropdown

Solution:
  • 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

βœ… Recommendations:
  • 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

Proxmox Host
192.168.1.100
β†’ NFS/SMB β†’
QNAP NAS
192.168.1.50
β†’ Stores β†’
Backup Files
.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.

🚨 CRITICAL WARNING: Before enabling the firewall, you MUST configure proper rules to allow access to the Proxmox web interface (port 8006) and SSH (port 22). If you enable the firewall without these rules, you will be immediately locked out and will need to use IPMI or physical console access to recover.

Firewall Architecture Levels

Firewall Hierarchy

Datacenter
Global Rules
↓
Node (pve1)
Host-level Rules
↓
VM/Container
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:

1. Access via IPMI: pve1.ipmi.your-domain.com 2. Open console 3. Login to host 4. Edit firewall config: nano /etc/pve/firewall/cluster.fw 5. Find the line: enable: 1 6. Change to: enable: 0 7. Save and exit (Ctrl+X, Y, Enter) 8. Firewall is now disabled

Initial Firewall Configuration

Step 1: Configure Rules BEFORE Enabling Firewall

Allow Web UI Access (Port 8006)

1. Datacenter β†’ Firewall β†’ Add 2. Direction: in 3. Action: ACCEPT 4. Enable: βœ… 5. Protocol: tcp 6. Dest. port: 8006 7. Interface: vmbr0 (your management bridge) 8. Source: (leave empty for all, or specify your admin subnet) 9. Comment: Allow Proxmox Web UI

Allow SSH Access (Port 22)

1. Datacenter β†’ Firewall β†’ Add 2. Direction: in 3. Action: ACCEPT 4. Enable: βœ… 5. Macro: SSH 6. Interface: vmbr0 7. Source: 192.168.1.0/24 (your admin network) 8. Comment: Allow SSH from admin network
πŸ’‘ Firewall Macros: Proxmox includes predefined macros for common services (SSH, HTTP, HTTPS, etc.). Macros automatically handle protocol and port configuration, reducing errors. Use macros when available instead of manual protocol/port specification.

Allow ICMP (Ping)

1. Datacenter β†’ Firewall β†’ Add 2. Direction: in 3. Action: ACCEPT 4. Enable: βœ… 5. Protocol: icmp 6. Interface: vmbr0 7. Source: 192.168.1.0/24 8. Comment: Allow ping from admin network

Step 2: Set Default Policy

1. Datacenter β†’ Firewall β†’ Options 2. Double-click "Input Policy" 3. Change to: DROP 4. Click "OK"
πŸ”’ Security Principle: Default Deny
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:

1. Datacenter β†’ Firewall β†’ Options 2. Double-click "Firewall" 3. Change to: Yes 4. Click "OK"

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:

1. Select VM/Container β†’ Firewall β†’ Add 2. Direction: in 3. Action: ACCEPT 4. Enable: βœ… 5. Macro: HTTP 6. Comment: Allow web traffic
1. Add another rule 2. Direction: in 3. Action: ACCEPT 4. Enable: βœ… 5. Macro: HTTPS 6. Comment: Allow secure web traffic

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

βœ… Security Recommendations:
  • 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:

Datacenter β†’ Firewall β†’ Options β†’ Log level: info View logs: Datacenter β†’ Firewall β†’ Log

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

qm list

Lists all virtual machines with their VMID, name, status, memory, and CPU allocation.

qm start 101

Starts VM with ID 101. The VM boots through its normal boot process.

qm shutdown 101

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.

qm reboot 101

Gracefully reboots VM 101 by sending an ACPI reboot signal.

qm reset 101

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.

qm stop 101

Immediately stops VM 101 without shutting down the guest OS. Equivalent to pulling the power plug. Use only in emergencies.

⚠️ shutdown vs stop vs reset:
  • 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

qm config 101

Displays all configuration parameters for VM 101, including CPU, memory, disks, network interfaces, and boot options.

qm set 101 --onboot 1

Enables automatic start of VM 101 when the Proxmox host boots. Use --onboot 0 to disable.

qm set 101 --memory 2048

Changes VM 101's RAM allocation to 2048 MB (2 GB). The VM must be shut down for this change to take effect.

qm set 101 --cores 4

Allocates 4 CPU cores to VM 101.

qm set 101 --name webserver01

Changes the display name of VM 101 to "webserver01".

Advanced VM Operations

qm clone 101 102 --name webserver02 --full

Creates a full clone of VM 101 as a new VM with ID 102.

qm migrate 101 pve2

Live-migrates VM 101 to another node called "pve2" in the cluster.

Container Management with pct

Basic Container Operations

pct list

Lists all containers with their CT ID, status, name, and resource allocation.

pct start 104

Starts container 104.

pct shutdown 104

Gracefully shuts down container 104.

pct reboot 104

Restarts container 104.

pct stop 104

Forcefully stops container 104.

Container Shell Access

pct enter 104

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.

πŸ’‘ Why pct enter is Useful: Unlike SSH, pct enter works even if:
  • The container has no SSH server installed
  • Network configuration is broken
  • You forgot the root password
It's the equivalent of physical console access for containers.

Container Configuration

pct config 104

Displays all configuration options for container 104.

pct set 104 --onboot 1

Enables auto-start on host boot for container 104.

pct set 104 --memory 1024

Changes container 104's memory limit to 1024 MB.

pct set 104 --cores 2

Allocates 2 CPU cores to container 104.

pct set 104 --hostname webserver

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

for vmid in $(qm list | awk '{print $1}' | grep -E '^[0-9]+$'); do qm start $vmid; done

Bulk Shutdown All Containers

for ctid in $(pct list | awk '{print $1}' | grep -E '^[0-9]+$'); do pct shutdown $ctid; done

List All Running VMs

qm list | grep running

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?

πŸ”’ Security Benefits:
  • 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

Physical NIC
enp5s0f0
β†’
Linux Bridge
vmbr0
β†’
Proxmox Host
+ 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

1. Node β†’ System β†’ Network β†’ Create β†’ Linux Bridge 2. Name: vmbr1 3. IPv4/CIDR: 10.10.10.1/24 (example VM network subnet) 4. Bridge ports: enp5s0f1 (second physical NIC) 5. Autostart: βœ… 6. Comment: VM Traffic Network 7. Click "Create" 8. Click "Apply Configuration"
⚠️ Network Change Warning: Applying network configuration changes can temporarily disrupt connectivity. If connecting remotely, ensure you have IPMI or physical console access before applying changes. In a production environment, schedule network changes during maintenance windows.

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:

During VM creation β†’ Network tab β†’ Bridge: vmbr1

For existing VMs:

1. Select VM β†’ Hardware 2. Double-click Network Device 3. Bridge: vmbr1 4. Click "OK" 5. Reboot VM for changes to take effect

VLAN-Based Segmentation

If you only have one physical network interface but a managed switch, you can use VLANs:

1. Node β†’ System β†’ Network β†’ Create β†’ Linux VLAN 2. Name: vmbr0.100 (VLAN 100) 3. VLAN raw device: vmbr0 4. VLAN tag: 100 5. IPv4/CIDR: 10.10.100.1/24 6. Create

Segmented Network Architecture

Management
192.168.1.0/24
vmbr0
VM Network
10.10.10.0/24
vmbr1
DMZ/Public VMs
VLAN 200
vmbr0.200

Firewall Rules for Network Segmentation

After segmenting networks, add firewall rules to enforce isolation:

Datacenter β†’ Firewall β†’ Add rule Direction: in Action: DROP Source: 10.10.10.0/24 (VM network) Dest: 192.168.1.0/24 (management network) Comment: Block VMs from accessing management network

Best Practices

βœ… Network Security Recommendations:
  • 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?

βœ… Benefits:
  • 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:

TrueNAS UI β†’ Storage β†’ Pools β†’ Add β†’ Create Pool Name: tank (example) Layout: Choose RAID level (RAID-Z1, RAID-Z2, Mirror, etc.) Select disks for the pool Click "Create"

Step 2: Create Dataset for Proxmox

TrueNAS UI β†’ Storage β†’ Pools β†’ Select your pool β†’ Add Dataset Name: proxmox-storage Compression: LZ4 (recommended for performance) Quota: (optional, set storage limit) ACL Mode: POSIX Click "Save"

Step 3: Configure Permissions

1. Select the dataset β†’ Edit Permissions 2. User: Create or select "proxmox" user 3. Group: Create or select "proxmox" group 4. βœ… Apply User 5. βœ… Apply Group 6. βœ… Apply permissions recursively 7. βœ… Traverse 8. Click "Save"
⚠️ Permission Requirements: The "proxmox" user on TrueNAS should have read/write permissions. Incorrect permissions are the most common cause of connection failures when adding TrueNAS storage to Proxmox.

Sharing Storage via NFS

Step 1: Enable NFS Service

TrueNAS β†’ Services β†’ NFS β†’ Start Automatically: βœ… Click the play button to start the service

Step 2: Create NFS Share

Sharing β†’ Unix Shares (NFS) β†’ Add Path: /mnt/tank/proxmox-storage Description: Proxmox shared storage Networks: 192.168.1.0/24 (your Proxmox network) Maproot User: root Maproot Group: root Click "Submit"

Adding TrueNAS Storage to Proxmox

For VM/Container Storage

Proxmox β†’ Datacenter β†’ Storage β†’ Add β†’ NFS ID: truenas-storage Server: 192.168.1.50 (TrueNAS IP) Export: /mnt/tank/proxmox-storage Content: βœ… Disk image, βœ… Container Nodes: All Enable: βœ… Click "Add"

For Backups (Separate Dataset Recommended)

Create a second dataset specifically for backups:

TrueNAS β†’ Create dataset: proxmox-backups Share via NFS Proxmox β†’ Add NFS storage: ID: truenas-backups Export: /mnt/tank/proxmox-backups Content: βœ… VZDump backup file

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

Create VM β†’ Hard Disk tab Storage: truenas-storage Disk size: 32 GB Continue with normal VM creation

Migrating Existing VM to TrueNAS

1. Shut down the VM 2. Select VM β†’ Hardware β†’ Hard Disk 3. Click "Disk Action" β†’ "Move Storage" 4. Target storage: truenas-storage 5. Delete source: βœ… (optional, saves space) 6. Click "Move Disk"

TrueNAS Snapshots for Additional Protection

TrueNAS ZFS snapshots are independent of Proxmox snapshots and provide an additional recovery layer:

TrueNAS β†’ Storage β†’ Pools β†’ Select dataset Snapshots tab β†’ Add snapshot Name: pre-maintenance Recursive: βœ… (includes child datasets)

Schedule Automatic Snapshots

Tasks β†’ Periodic Snapshot Tasks β†’ Add Dataset: tank/proxmox-storage Recursive: βœ… Schedule: Daily @ 01:00 Lifetime: 7 days

Performance Considerations

⚑ Performance Tips:
  • 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

Proxmox Node 1
VMs & Containers
β†’ NFS β†’
TrueNAS
ZFS Storage Pool
← NFS ←
Proxmox Node 2
VMs & Containers
πŸ’Ύ High Availability Setup: When multiple Proxmox nodes share TrueNAS storage, you can migrate VMs between nodes seamlessly. If one Proxmox host fails, VMs can be quickly started on another node since the disk data is on shared storage. This is the foundation of Proxmox clustering.

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?

πŸ”— Cluster Benefits:
  • 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)

1. Node β†’ System β†’ Network β†’ Create β†’ Linux Bridge 2. Name: vmbr2 (example for cluster network) 3. IPv4/CIDR: 10.10.10.1/24 (node 1), 10.10.10.2/24 (node 2), etc. 4. Bridge ports: enp5s0f2 (dedicated NIC for cluster communication) 5. Comment: Cluster Communication Network 6. Apply Configuration 7. Reboot Proxmox node to ensure network changes are stable
πŸ’‘ Network Planning: While you can use your existing management network for clustering, a dedicated cluster network provides:
  • Better performance for live migration
  • Isolation from management traffic
  • Reduced latency for cluster synchronization

Creating the Cluster

Step 1: Create Cluster on Primary Node

1. On first Proxmox node (will be cluster leader) 2. Datacenter β†’ Cluster β†’ Create Cluster 3. Cluster Name: pve-cluster (choose any descriptive name) 4. Cluster Network: Leave empty to auto-detect, or specify: 10.10.10.0/24 5. Click "Create"
πŸ“ Cluster Name Restrictions: The cluster name must be unique and cannot be changed later without rebuilding the cluster. Choose wisely! Use lowercase letters, numbers, and hyphens only.

Step 2: Get Join Information

1. On the primary node: Datacenter β†’ Cluster 2. Click "Join Information" button 3. Copy the entire join information (long encoded string)

Step 3: Join Additional Nodes to Cluster

1. On second Proxmox node 2. Datacenter β†’ Cluster β†’ Join Cluster 3. Paste the join information from step 2 4. Peer Address: (auto-filled from join info) 5. Password: Enter root password of the PRIMARY node 6. Fingerprint: Verify matches the primary node 7. Click "Join"
⚠️ Join Process Notes:
  • 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

1. On any cluster node web UI 2. Datacenter β†’ You should now see all nodes listed in the tree 3. Click each node to verify connectivity 4. Datacenter β†’ Cluster β†’ Status to view cluster health

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.

1. Shut down the VM/container 2. Right-click VM/Container β†’ Migrate 3. Target Node: pve2 (destination node) 4. Target Storage: Select storage accessible on target node 5. With local storage: Full copy, takes time 6. With shared storage: Instant, just updates configuration 7. Click "Migrate"

Online/Live Migration (VM stays running)

Zero-downtime migration. Requires shared storage or very fast network.

1. Right-click running VM β†’ Migrate 2. Target Node: pve2 3. Mode: Online 4. With shared storage: Instant migration (RAM transfer only) 5. Without shared storage: Disk + RAM transfer (very slow) 6. Click "Migrate"
🚨 Cloud-Init Disk Limitation: VMs with Cloud-Init disks stored on local storage cannot be live-migrated. You must either:
  • 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

Solutions:
  • 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

Common Causes:
  • 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)

pvecm status

Shows cluster status, quorum information, and node list.

pvecm nodes

Lists all nodes in the cluster.

pvecm expected 1

Temporarily allows cluster to operate with only 1 node (emergency use only).

Basic Cluster Architecture

pve1
192.168.1.10
Cluster Leader
↔
pve2
192.168.1.11
Cluster Member
↔
Shared Storage
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

βœ… HA Protects Against:
  • 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
❌ HA Does NOT Protect Against:
  • 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
That's what backups are for! HA is for uptime, backups are for data safety. You need both in production.

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:

πŸ€” The Dilemma:
"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.
πŸ“ The Formula:
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:

1. Shut down the VM 2. Select VM β†’ Hardware β†’ Hard Disk 3. Disk Action β†’ Move Storage 4. Target Storage: truenas-storage (or your shared storage name) 5. Format: QEMU image format (qcow2) 6. Delete Source: βœ… (to save space) 7. Click "Move Disk"
⚠️ Important: The VM must be shut down before moving disks. Also, if you have a Cloud-Init disk on local storage, move it too or the HA setup will fail.

Step 2: Configure HA Resource

1. Datacenter β†’ HA β†’ Add 2. Resource: Select your VM (e.g., VM 101 - webserver01) 3. Max Restart: 1 (how many times to try restarting on same node before relocating) 4. Max Relocate: 1 (how many times to relocate to another node before giving up) 5. Request State: started (VM should always be running) 6. Group: (optional, for preferring specific nodes) 7. Click "Add"

Step 3: Start the VM

1. Start the VM normally 2. Verify it's running 3. In Datacenter β†’ HA, you should see the VM listed with state "started"

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

1. Note which node the VM is currently running on (e.g., pve1) 2. On that node's console, simulate a crash: echo b > /proc/sysrq-trigger 3. This immediately reboots the node (simulate hardware failure) 4. Within 1-2 minutes, watch Datacenter β†’ HA 5. The VM should automatically start on pve2 or pve3
⚠️ Warning: The 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

  1. 0-10 seconds: Cluster detects node is unresponsive
  2. 10-30 seconds: Quorum confirms node is dead, begins fencing
  3. 30-60 seconds: HA manager selects a new node and starts VM boot process
  4. 60-120 seconds: VM boots on new node and becomes accessible
πŸ’‘ Downtime Expectation: For most VMs, expect 1-2 minutes of downtime during failover. This is significantly better than manual recovery which could take hours. The exact time depends on:
  • VM boot time (larger VMs take longer)
  • Storage speed (faster storage = faster boot)
  • Network latency between nodes
  • Cluster load (other VMs competing for resources)

Live Migration vs. HA Fail