LinuxCommandLibrary

qm-resize

Resize virtual machine disk images

TLDR

View documentation for the original command

$ tldr qm disk resize
copy

SYNOPSIS

qm-resize <vmid> <disk> <size> [<OPTIONS>]

PARAMETERS

<vmid>
    The unique ID of the virtual machine or container.

<disk>
    The identifier of the disk to resize (e.g., 'scsi0', 'ide0', 'virtio0', or 'rootfs' for containers).

<size>
    The target size or the amount to add/subtract. Can be an absolute size (e.g., '100G') or a delta (e.g., '+10G', '-5G'). Supported units are K, M, G, T.

--dry-run
    Perform a dry run; do not actually resize the disk, but show what would happen.

--sparse
    Try to make the disk image sparse after shrinking. Only applicable for file-based storages.

--shrink
    Mandatory option for shrinking operations to explicitly acknowledge the risk of data loss. This prevents accidental shrinking.

DESCRIPTION


The qm-resize command is a specialized utility within the Proxmox Virtual Environment (PVE) designed to modify the size of virtual disk images attached to KVM virtual machines (VMs) and LXC containers (CTs). It allows administrators to either extend the capacity of a virtual disk, providing more storage space to the guest operating system, or cautiously shrink it to reclaim unused space on the host storage.

Crucially, qm-resize operates at the storage backend level, meaning it interacts directly with the underlying storage (e.g., LVM, ZFS, Ceph RBD, directory-backed files). It does not automatically resize the filesystem inside the guest. For extending, users typically resize the guest's filesystem (e.g., using resize2fs or xfs_growfs) after increasing the disk size with qm-resize. For shrinking, it is imperative to shrink the guest's filesystem first to prevent data loss, and the guest must be powered off for shrinking operations.

CAVEATS


Data Loss Warning for Shrinking:
When shrinking a disk, it is absolutely critical to first reduce the size of the filesystem inside the guest operating system. Failing to do so before running qm-resize --shrink will result in immediate and irreversible data loss. This command only modifies the underlying block device size, not the filesystem within.

Guest State: Shrinking operations generally require the VM or container to be powered off. While some online extension capabilities exist for certain storage types, it's often safer and recommended to power off the guest for any resizing operation, especially when dealing with critical data.

Filesystem Resizing: After extending a disk with qm-resize, you must manually extend the filesystem inside the guest to utilize the newly available space (e.g., using resize2fs, xfs_growfs, or other filesystem-specific tools).

USAGE CONSIDERATIONS

While qm-resize directly manipulates the virtual disk size, for Proxmox users, it's often more common to use the higher-level commands like qm set <vmid> --<disk_id> <size> or pct set <vmid> --rootfs <size>. These commands internally call qm-resize, providing a more integrated and user-friendly experience, especially when dealing with configuration updates through the Proxmox web interface or CLI.

COMMON WORKFLOW

Extending a Disk:
1. Power off the VM/CT (recommended, sometimes optional).
2. Use qm-resize (or qm set/pct set) to increase the virtual disk size.
3. Power on the VM/CT.
4. Inside the guest, extend the partition (if applicable) and then the filesystem (e.g., resize2fs /dev/vda1 or lvextend then xfs_growfs).

Shrinking a Disk:
1. Power off the VM/CT.
2. Inside the guest, shrink the filesystem first (e.g., resize2fs -M /dev/vda1).
3. Inside the guest, shrink the partition (if applicable).
4. Use qm-resize --shrink (or qm set/pct set) to reduce the virtual disk size on the host.
5. Power on the VM/CT.

HISTORY

qm-resize is an integral part of the Proxmox Virtual Environment (PVE) suite of utilities, developed alongside the platform itself to provide robust virtual machine and container management capabilities. Its evolution has mirrored the growing sophistication of PVE's storage management, supporting various backend technologies like LVM, ZFS, Ceph, and standard file-based storages. It serves as a backend helper script, primarily invoked by higher-level qm or pct commands for disk modification, emphasizing Proxmox's design philosophy of providing comprehensive, integrated virtualization tools.

SEE ALSO

qm(1), pct(1), resize2fs(8), xfs_growfs(8), fdisk(8), parted(8)

Copied to clipboard