🧰 Proxmox pct Command Cheat Sheet
Manage LXC containers in Proxmox VE using the pct command-line tool.
🛠️ Create & Configure Containers
📦 Create a New Container
pct create 101 local:vztmpl/debian-12-standard_12.0-1_amd64.tar.zst \
--hostname debian-lxc \
--cores 2 \
--memory 2048 \
--net0 name=eth0,bridge=vmbr0,ip=dhcp \
--rootfs local-lvm:10G \
--password your_password
📝 Modify Container Configuration
pct set 101 --cores 4 --memory 4096
pct set 101 --net0 name=eth0,bridge=vmbr0,ip=192.168.1.101/24,gw=192.168.1.1
pct set 101 --mp0 /mnt/data,mp=/mnt/shared # Bind mount
❌ Unset Config Option
pct unset 101 --net0
pct unset 101 --mp0
🚦 Lifecycle Commands
pct start 101
pct stop 101
pct shutdown 101
pct reboot 101
pct status 101
🔧 Container Access & File Copy
pct enter 101 # Shell access
pct exec 101 -- apt update # Run a command inside
pct push 101 ./file.txt /root/ # Copy file to container
pct pull 101 /etc/hostname ./ # Copy file from container
💽 Mount & Unmount Filesystem
pct mount 101
pct unmount 101
🔄 Resize Disk
pct resize 101 rootfs +5G
🧰 Snapshot Management
pct snapshot 101 pre-upgrade
pct listsnapshot 101
pct rollback 101 pre-upgrade
pct delsnapshot 101 pre-upgrade
♻️ Clone, Backup & Restore
pct clone 101 201 --hostname new-container
pct restore 102 /var/lib/vz/dump/vzdump-lxc-102-*.tar.zst
🔓 Unlock a Container
pct unlock 101
🌐 Networking Configuration
pct set 101 --net0 name=eth0,bridge=vmbr0,ip=dhcp
pct set 101 --net0 name=eth0,bridge=vmbr0,ip=192.168.1.101/24,gw=192.168.1.1
📁 Bind Mount Host Directory
Mount host directory /mnt/data to /mnt/shared inside container:
pct set 101 --mp0 /mnt/data,mp=/mnt/shared
Optional flags:
ro=1→ read-onlybackup=0→ exclude from backups
🧠 Useful Notes
- VMID must be a unique numeric ID.
- Templates are stored in
/var/lib/vz/template/cache/ - Download templates:
pveam update pveam available pveam download local debian-12-standard_12.0-1_amd64.tar.zst
评论区