qm-destroy
Delete virtual machines and containers
TLDR
Destroy a specific virtual machine
Destroy all disks that are not explicitly referenced in a specific virtual machine's configuration
Destroy a virtual machine and remove from all locations (inventory, backup jobs, high availability managers, etc.)
Destroy a specific virtual machine ignoring locks and forcing destroy
SYNOPSIS
qm destroy
PARAMETERS
The unique numerical ID of the virtual machine to destroy.
--purge
Remove also all disks. This option is destructive.
--destroy-unreferenced-disks
Remove all disks that the virtual machine once held but are no longer in the config.
--skiplock
Ignore locks - only use if the VM is not running and you know what you are doing.
--verbose
Be verbose.
DESCRIPTION
The `qm destroy` command in Proxmox VE removes a virtual machine from the system. This process involves deleting the VM's configuration files and optionally wiping associated disk images. It is a permanent operation, so caution is advised. The command requires the VMID (Virtual Machine ID) as an argument. Before running `qm destroy`, ensure the VM is powered off using `qm shutdown` or `qm stop`. While the command attempts to remove disk images, manually verifying and deleting them after running `qm destroy` is a good practice, especially in shared storage environments to free up space and avoid orphaned files. Important: This action is irreversible.
CAVEATS
Destroying a VM is permanent, and data recovery is generally impossible. Double-check the VMID before executing. Always shut down the VM cleanly before destroying it to minimize the risk of data corruption. Use --purge with extreme caution.
DISK MANAGEMENT
After running `qm destroy`, particularly without the `--purge` option, it is crucial to verify that all associated disk images are properly removed to avoid orphaned disks consuming storage space. Use the Proxmox VE web interface or command-line tools like `lvremove` (for LVM) or `zfs destroy` (for ZFS) to manually delete the disks.
ERROR HANDLING
If `qm destroy` fails due to locked resources, ensure the VM is not running or in a migrating state. The `--skiplock` option can be used, but only when you're certain the VM is truly not in use and understand the potential risks.
HISTORY
The `qm destroy` command is part of the Proxmox VE (Virtual Environment) suite of tools for managing virtual machines. It's been present since the early versions of Proxmox VE, designed to provide a straightforward way to remove VMs and reclaim resources. Its functionality has remained relatively consistent, with incremental improvements to error handling and option additions to handle specific disk cleanup scenarios.