qm-disk-resize
Resize a virtual machine disk
TLDR
Add n gigabytes to a virtual disk
SYNOPSIS
qm-disk-resize
PARAMETERS
vmid
The unique ID of the Qemu guest virtual machine.
disk
The identifier of the virtual disk to resize (e.g., 'scsi0', 'ide0', 'virtio0', 'sata0').
size
The target size for the disk. Can be an absolute size (e.g., '32G', '1T') or a relative change (e.g., '+10G', '-2G').
--format
Specifies the target image format (e.g., 'qcow2', 'raw') when resizing certain disk types. Only applicable if the backend allows format changes.
--sparse
Enables sparse allocation for the resized image, meaning disk blocks are only allocated as data is written.
--dryrun
Performs a simulated resize operation without making any actual changes to the disk. Useful for validating parameters.
DESCRIPTION
The qm-disk-resize command in Proxmox VE facilitates the resizing of virtual disks attached to Qemu guests. This powerful utility allows administrators to either increase or decrease the storage capacity of a VM's disk, providing flexibility in managing virtual machine resources. It supports various storage backends, including local directories, LVM, ZFS, and Ceph.
When increasing a disk's size, it's typically a safe operation from a data integrity perspective, though it usually necessitates an additional step of expanding the filesystem within the guest operating system to utilize the newly available space. Conversely, decreasing a disk's size is a highly critical operation that carries a significant risk of data loss if not performed with extreme caution. Before attempting to shrink a disk, the filesystem inside the guest must be shrunk to a size smaller than the target disk size. Failure to do so will result in data corruption.
The command offers options for specifying the new size (absolute or relative), setting the image format for certain storage types, and a dry-run mode to preview changes without committing them. While some setups might support live resizing, it is generally recommended to stop the virtual machine before performing disk resize operations to ensure data consistency and avoid potential issues. Always back up your virtual machine before undertaking disk resizing to prevent unforeseen data loss.
CAVEATS
Resizing disks, especially decreasing their size, carries inherent risks.
Decreasing a disk: This operation is extremely dangerous if the filesystem inside the guest is not shrunk before the disk. Data loss is highly probable if the guest filesystem occupies space beyond the new disk size.
Increasing a disk: While generally safer, the guest operating system's filesystem will need to be explicitly expanded to utilize the newly available space.
VM State: For most storage types and configurations, the VM should be powered off before resizing. Live resize capabilities are limited and highly dependent on storage type and guest OS support.
Snapshots: Having active snapshots might prevent disk resizing operations.
Backup: Always create a full backup of the VM before attempting any disk resize operation.
HISTORY
The qm-disk-resize command is an integral part of the Proxmox VE (Virtual Environment) suite, designed to provide flexible disk management for Qemu-KVM virtual machines. Its development has mirrored the evolution of Proxmox VE itself, adapting to support new storage technologies like ZFS, Ceph, and various LVM setups, while continuously improving the robustness and safety of disk operations. It was introduced to simplify disk adjustments directly from the Proxmox CLI, abstracting the underlying qemu-img operations for various storage backends.