侧边栏壁纸
  • 累计撰写 99 篇文章
  • 累计创建 54 个标签
  • 累计收到 1 条评论

目 录CONTENT

文章目录
PVE

PVE pct command list

FlyingEagle
2025-07-04 / 0 评论 / 0 点赞 / 29 阅读 / 1,675 字

🧰 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-only
  • backup=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
    
0

评论区