Proxmox QM and PVESH CLI Reference

Clone a VM

qm clone VMIDTOCLONE NEWVMIDNUMBER --name "VMNAME" --full true
  • Set the macaddress for VM’s primary NIC
qm set 1001 --net0 virtio,macaddr=BC:24:11:6B:7D:2B,,bridge=vmbr0,firewall=1
  • Migrate a VM to a different node and specify the storage
qm migrate 1004 sandalwood --targetstorage NVME-01

Controlling VMs on different Nodes using pvesh

For controlling VMs on different nodes than the one you’re accessing the terminal from you have to use pvesh CLI tool

  • https://pve.proxmox.com/pve-docs/pvesh.1.html

  • Start a VM on different node

pvesh create /nodes/NODENAME/qemu/VMIDNUMBER/status/start
  • Reboot a VM on different node
pvesh create /nodes/sandalwood/qemu/1005/status/reboot
  • Forcefully reset a VM on different node (similiar to forcefully unplugging pc from power)
pvesh create /nodes/sandalwood/qemu/1005/status/reset
  • Shutdown a VM on a different node
pvesh create /nodes/sandalwood/qemu/1005/status/shutdown
  • Delete a VM on a different node.
  • Have to use the pvesh CLI to control the VMs on the different nodes
    • https://forum.proxmox.com/threads/issue-qm-shutdown-from-one-node-to-another.44150/
    • https://pve.proxmox.com/pve-docs/pvesh.1.html
pvesh delete /nodes/NODENAME/qemu/VMIDNUMBER ; 
  • Script to query the Proxmox API for VM name and set hostname of the VM accordingly
    • https://github.com/badsmoke/proxmox-auto-hostname

Last updated on July 31, 2024. For any questions/feedback, email me at blog@zinchuk.xyz.