Virtualization¶
Virtual machine and container management in Proxmox VE including Docker deployment and VM optimization.
📋 Virtualization Overview¶
Proxmox VE supports multiple virtualization technologies:
KVM Virtual Machines: Full virtualization with hardware emulation
LXC Containers: Lightweight OS-level virtualization
Docker Containers: Application containerization within LXC
GPU Passthrough: Direct hardware access for VMs
🖥️ Virtual Machine Management¶
VM Creation and Configuration¶
VM Creation via Web Interface:
Create VM: Datacenter → Node → Create VM
General: Set VM ID, name, and resource pool
OS: Select ISO image and OS type
System: Configure BIOS, machine type, and SCSI controller
Hard Disk: Set disk size, format, and storage location
CPU: Configure CPU type, cores, and sockets
Memory: Set RAM allocation
Network: Configure network interfaces
VM Creation via CLI:
# Create Ubuntu VM example
qm create 100 \
--name ubuntu-server \
--memory 2048 \
--cores 2 \
--net0 virtio,bridge=vmbr0 \
--scsi0 local-lvm:32 \
--ide2 local:iso/ubuntu-22.04-server.iso,media=cdrom \
--boot c \
--bootdisk scsi0 \
--ostype l26
Automated VM Creation with Packer:
Create VMs on Proxmox in Seconds! - Comprehensive guide to using Packer for automated VM template creation
Linux VM Optimization¶
Install QEMU Guest Agent for better integration:
# Ubuntu/Debian
sudo apt update
sudo apt install qemu-guest-agent
sudo systemctl enable qemu-guest-agent
sudo systemctl start qemu-guest-agent
# CentOS/RHEL
sudo yum install qemu-guest-agent
sudo systemctl enable qemu-guest-agent
sudo systemctl start qemu-guest-agent
Enable in Proxmox:
VM → Options → QEMU Guest Agent: Enable
Shutdown and restart the VM
Windows VM Configuration¶
VirtIO Drivers Installation:
Download VirtIO drivers ISO from Proxmox VirtIO Drivers
Attach ISO during Windows installation
Install drivers for network, storage, and balloon
Physical Drive Passthrough:
Reference: Passing a Physical Drive through to a VM in ProxMox
# List available disks
ls -n /dev/disk/by-id/
# Add physical disk to VM
/sbin/qm set [VM-ID] -virtio2 /dev/disk/by-id/[DISK-ID]
📦 LXC Container Management¶
Container Creation¶
Create LXC Container:
# Create Ubuntu LXC container
pct create 200 \
local:vztmpl/ubuntu-22.04-standard_22.04-1_amd64.tar.zst \
--hostname ubuntu-container \
--memory 1024 \
--cores 2 \
--net0 name=eth0,bridge=vmbr0,ip=dhcp \
--storage local-lvm \
--rootfs local-lvm:8
Container Configuration:
# Start container
pct start 200
# Enter container console
pct enter 200
# Set root password
passwd
Container Optimization¶
Privileged vs Unprivileged: - Privileged: Full root access, better compatibility - Unprivileged: Better security, limited functionality
Resource Limits:
# Set CPU limit
pct set 200 --cores 2 --cpulimit 1.5
# Set memory limit
pct set 200 --memory 1024 --swap 512
🐳 Docker in LXC Containers¶
Docker LXC Setup¶
References: - Running Docker under LXC Containers in ProxMox for Extra Granularization
Create Docker-Ready LXC:
Create privileged container (required for Docker)
Enable nesting: Options → Features → Nesting
Configure keyctl: Options → Features → Keyctl
Docker Installation in LXC:
# Update system
apt update && apt upgrade -y
# Install required packages
apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common
# Add Docker GPG key
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
# Add Docker repository
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
# Update package list
apt update
# Install Docker
apt install docker-ce
# Verify Docker installation
systemctl status docker
docker run hello-world
# Install additional tools
apt install cifs-utils docker-compose
Docker Service Configuration¶
Create Docker service user:
# Create docker user
adduser docker-user
usermod -aG docker docker-user
Configure Docker daemon:
# Create daemon configuration
mkdir -p /etc/docker
cat > /etc/docker/daemon.json << EOF
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
},
"storage-driver": "overlay2"
}
EOF
# Restart Docker
systemctl restart docker
🔧 VM Templates and Automation¶
VM Template Creation¶
Create Packer Templates:
Reference: Create VMs on Proxmox in Seconds!
Manual Template Creation:
Install and configure base VM
Clean up logs and temporary files
Shutdown VM
Convert to template: Right-click VM → Convert to template
Clone from Template:
# Clone VM from template
qm clone 9000 100 --name new-vm --full
# Start cloned VM
qm start 100
Cloud-Init Configuration¶
Enable Cloud-Init:
# Add Cloud-Init drive
qm set 100 --ide2 local-lvm:cloudinit
# Configure Cloud-Init
qm set 100 --ciuser ubuntu --cipassword password
qm set 100 --ipconfig0 ip=192.168.1.100/24,gw=192.168.1.1
qm set 100 --nameserver 8.8.8.8
qm set 100 --searchdomain local
📊 Performance Monitoring¶
VM Performance Monitoring¶
Monitor VM Resources:
# Check VM status
qm status 100
# Monitor VM performance
qm monitor 100
# List all VMs
qm list
Performance Tuning:
# Enable NUMA
qm set 100 --numa 1
# Set CPU type
qm set 100 --cpu host
# Enable hardware acceleration
qm set 100 --args '-cpu host,+aes'
Container Monitoring¶
# Check container status
pct status 200
# Monitor container resources
pct exec 200 -- htop
# List all containers
pct list
🔄 Backup and Migration¶
VM Backup Configuration¶
Automated Backups:
Datacenter → Backup
Add backup job: - Node: Select target node - Storage: Backup destination - Schedule: Set backup frequency - Selection: Choose VMs/containers - Retention: Set backup retention policy
Manual Backup:
# Backup VM
vzdump 100 --storage local --compress gzip
# Backup container
vzdump 200 --storage local --compress lzo
VM Migration¶
Live Migration:
# Migrate VM to another node
qm migrate 100 node2
# Migrate with storage
qm migrate 100 node2 --targetstorage local-lvm
🚨 Troubleshooting¶
Common VM Issues¶
VM Won’t Start:
# Check VM configuration
qm config 100
# Check system logs
journalctl -u qemu-server@100
# Reset VM
qm reset 100
Performance Issues:
# Check host resources
htop
iostat -x 1
# Check VM disk usage
qm monitor 100
info blockstats
Container Issues¶
Container Won’t Start:
# Check container configuration
pct config 200
# Check container logs
journalctl -u pve-container@200
# Force stop and start
pct stop 200 --force
pct start 200
📋 Virtualization Checklist¶
After virtualization setup:
[ ] VM templates created and tested
[ ] LXC containers configured for services
[ ] Docker environment set up in LXC
[ ] Guest agents installed in VMs
[ ] Backup jobs configured for critical VMs
[ ] Performance monitoring implemented
[ ] Resource limits configured appropriately
[ ] Network connectivity verified