Sometimes you don't want to deal with the web UI and just need to start, stop or manage VMs directly from the terminal. Proxmox ships with the tool qm, which gives you full control over KVM-based virtual machines via CLI.
This article explains the essential commands and what they actually do.
Prerequisites
You need:
- A Proxmox VE system
- The VM ID you want to control
(You can list all VMs with:qm list)
Full Available qm Function Overview
You can see all supported commands with:
qm
Once you have entered this command you should see following options:
qm <command> <vmid> [OPTIONS]
qm [create|set] <vmid>
--memory <MBYTES> memory in MB (64 - 8192)
--smp <N> set number of CPUs to <N>
--ostype NAME specify OS type
--onboot [yes|no] start at boot
--keyboard XX set vnc keyboard layout
--cpuunits <num> CPU weight for a VM
--name <text> Add a name for the VM
--boot [a|c|d|n] specify boot order
--bootdisk <disk> enable booting from <disk>
--acpi (yes|no) enable/disable ACPI
--localtime (yes|no) set the RTC to local time
--vlan[0-9u] MODEL=XX:XX:XX:XX:XX:XX[,MODEL=YY:YY:YY:YY:YY:YY]
--ide<N> [file=]file,][,media=d]
[,cyls=c,heads=h,secs=s[,trans=t]]
[,snapshot=on|off][,cache=on|off][,format=f]
--ide<N> <GBYTES> create new disk
--ide<N> delete delete disk
--cdrom <file> is an alias for --ide2 <file>,media=cdrom
--scsi<N> [file=]file,][,media=d]
[,cyls=c,heads=h,secs=s[,trans=t]]
[,snapshot=on|off][,cache=on|off][,format=f]
--scsi<N> <GBYTES> create new disk
--scsi<N> delete delete disk
--virtio<N> [file=]file,][,media=d]
[,cyls=c,heads=h,secs=s[,trans=t]]
[,snapshot=on|off][,cache=on|off][,format=f]
--virtio<N> <GBYTES> create new disk
--virtio<N> delete delete disk
qm monitor <vmid> connect to vm control monitor
qm start <vmid> start vm
qm reboot <vmid> reboot vm (shutdown, start)
qm shutdown <vmid> gracefully stop vm (send poweroff)
qm stop <vmid> kill vm (immediate stop)
qm reset <vmid> reset vm (stop, start)
qm suspend <vmid> suspend vm
qm resume <vmid> resume vm
qm destroy <vmid> destroy vm (delete all files)
qm cdrom <vmid> [<device>] <path> set cdrom path. <device is ide2 by default>
qm cdrom <vmid> [<device>] eject eject cdrom
qm unlink <vmid> <file> delete unused disk images
qm vncproxy <vmid> <ticket> open vnc proxy
qm list list all virtual machinesReplace <vmid> with the actual VM number, for example:
qm start 101
Why Graceful Shutdown Might Not Work
The command:
qm shutdown <vmid>
only works if the VM accepts ACPI shutdown signals.
If the VM ignores the shutdown request, fix it inside the guest OS:
Windows Guests
Enable shutdown without login:
- Press
Win + R, run:gpedit.msc Go to:
Computer Configuration → Windows Settings → Security Settings → Local Policies → Security Options
- Enable:
"Shutdown: Allow system to be shut down without having to log on." - Optional (to avoid popup nags):
Display Shutdown Event Tracker → Disabled
Linux Guests (Ubuntu, Debian, etc.)
Install acpid:
apt-get update apt-get install acpid
After installation, ACPI shutdown should work normally.
Stop All Virtual Machines
There used to be a command called qm stopall, but it’s deprecated.
Use this instead:
service pve-manager stop
This tries a graceful shutdown first and then stops containers and VMs in the correct order.
Summary
If you just need the quick cheat sheet:
qm start <id> # Start VM qm shutdown <id> # Graceful shutdown qm stop <id> # Force stop qm reboot <id> # Reboot qm reset <id> # Hard reset qm list # Show all VMs
Make sure ACPI is enabled to avoid having to use force-stop.
Comments
0 comments
Please sign in to leave a comment.