cheat-sheets

Proxmox qm and pct

qm manages KVM virtual machines, pct manages LXC containers. Run on a PVE node as root. <VMID> and <CTID> share one ID space per cluster.

Documentation: qm(1) · pct(1)

Verification: all qm commands, including qm disk import, qm disk move, qm disk resize, qm guest exec, qm showcmd and qm monitor, were checked against the qm docs. The pct subcommands (create, set, resize, snapshot, move-volume, fsck, migrate --restart) were not verified against the docs and no command was executed. Run pct help <SUBCOMMAND> to confirm.

See also: Proxmox VE Overview and Install · Proxmox Storage · Proxmox Cloud-Init Templates · Proxmox Troubleshooting and One-Liners


qm: Virtual Machines #

COMMANDDESCRIPTION
qm listList VMs on this node
qm status <VMID>Running state
qm config <VMID>Show config
qm start <VMID>Start
qm shutdown <VMID>Graceful ACPI shutdown
qm stop <VMID>Hard stop
qm reboot <VMID> / qm reset <VMID>Graceful reboot / hard reset
qm suspend <VMID> / qm resume <VMID>Pause / resume
qm create <VMID> --name <NAME> --memory 2048 --cores 2 --net0 virtio,bridge=vmbr0Create an empty VM
qm set <VMID> --memory 4096 --cores 4Change resources
qm set <VMID> --onboot 1Start at boot
qm set <VMID> --agent enabled=1Enable QEMU guest agent (install it in the guest too)
qm clone <VMID> <NEWID> --name <NAME> --fullFull clone (omit --full for a linked clone from a template)
qm template <VMID>Convert a VM to a template
qm destroy <VMID> --purgeDelete VM and remove it from jobs
qm snapshot <VMID> <NAME>Snapshot
qm listsnapshot <VMID>List snapshots
qm rollback <VMID> <NAME>Roll back
qm delsnapshot <VMID> <NAME>Delete a snapshot
qm unlock <VMID>Clear a stuck lock
qm terminal <VMID>Serial console (needs a serial port, -serial0 socket)
qm monitor <VMID>QEMU monitor
qm showcmd <VMID> --prettyShow the kvm command line
qm migrate <VMID> <TARGET> --onlineLive migrate in a cluster (Proxmox Clustering and HA)

Guest agent #

COMMANDDESCRIPTION
qm agent <VMID> pingCheck the agent responds
qm guest exec <VMID> -- <CMD> <ARGS>Run a command in the guest
qm guest cmd <VMID> network-get-interfacesGuest NIC info

Disks #

COMMANDDESCRIPTION
qm set <VMID> --scsi1 <STORAGE>:32Add a new 32 GiB disk
qm disk import <VMID> <FILE> <STORAGE>Import a disk image (qm importdisk is the older alias)
qm disk move <VMID> scsi0 <STORAGE> --delete 1Move a disk to another storage (qm move-disk alias)
qm disk resize <VMID> scsi0 +5GGrow a disk (qm resize alias)
qm set <VMID> --delete unused0Remove an unused disk entry
qm rescanRe-scan storage and fix up unused volumes

Resize a disk #

Grow in the GUI or with qm disk resize <VMID> scsi0 +5G. Then grow the partition and filesystem inside the guest (growpart, resize2fs or xfs_growfs).

Shrink a disk (manual, risky) #

Take a backup first (Proxmox Backup and Restore). Proxmox cannot shrink disks. Shrink the filesystem and partition inside the guest first, otherwise data is lost.

  1. Convert qcow2 to raw
qemu-img convert vm-<VMID>.qcow2 vm-<VMID>.raw
  1. Shrink the disk
qemu-img resize -f raw --shrink vm-<VMID>.raw 10G
  1. Convert back to qcow2
qemu-img convert -p -O qcow2 vm-<VMID>.raw vm-<VMID>.qcow2

Applies to file-based storage (directory, NFS). For LVM or ZFS volumes, shrink the volume itself with lvreduce or zfs set volsize, which is not covered here.


pct: LXC Containers #

COMMANDDESCRIPTION
pct listList containers
pct status <CTID>Running state
pct config <CTID>Show config
pct create <CTID> <STORAGE>:vztmpl/<TEMPLATE> --hostname <NAME> --unprivileged 1 --net0 name=eth0,bridge=vmbr0,ip=dhcp --rootfs <STORAGE>:8Create from a downloaded template (pveam download)
pct start <CTID> / pct shutdown <CTID> / pct stop <CTID>Start, graceful, hard stop
pct enter <CTID>Shell into a container from the host
pct exec <CTID> -- <CMD>Run a command in a container
pct push <CTID> <LOCAL> <REMOTE>Copy a file in
pct pull <CTID> <REMOTE> <LOCAL>Copy a file out
pct set <CTID> --memory 1024 --cores 2Change resources
pct set <CTID> --features nesting=1,keyctl=1Enable nesting (needed for Docker in LXC)
pct set <CTID> --mp0 <STORAGE>:8,mp=/dataAdd a mount point volume
pct set <CTID> --mp0 /host/path,mp=/mnt/pathBind mount a host directory
pct resize <CTID> rootfs +4GGrow the root disk
pct snapshot <CTID> <NAME> / pct rollback <CTID> <NAME>Snapshot and roll back
pct clone <CTID> <NEWID> --hostname <NAME>Clone
pct template <CTID>Convert to a template
pct destroy <CTID> --purgeDelete
pct unlock <CTID>Clear a stuck lock
pct fsck <CTID>Check the root filesystem (container stopped)
pct migrate <CTID> <TARGET> --restartMigrate (containers restart, no live migration)
pct restore <CTID> <ARCHIVE> --storage <STORAGE>Restore from a vzdump archive

Unprivileged containers and bind mounts #

Unprivileged containers map container UID 0 to host UID 100000. A bind-mounted host directory must be owned by the mapped IDs (for example chown -R 100000:100000 <DIR>) or you need custom lxc.idmap entries. Sharing an NFS export into a container is usually easiest by mounting it on the host first, see NFS and Proxmox Storage.


Container Templates #

COMMANDDESCRIPTION
pveam updateRefresh the template index
pveam available --section systemList OS templates
pveam download local <TEMPLATE>Download to local storage
pveam list localDownloaded templates
pveam remove <STORAGE>:vztmpl/<TEMPLATE>Delete a template

General Linux commands inside guests: Linux.

Search all sheets

Tip: / or Ctrl/Cmd+K to open, Esc to close.