3.3. Managing Virtual Disks

In Virtuozzo Hybrid Server, you can resize virtual disks and compact them (reduce their size on the physical hard drive). These operations are described in the following subsections in detail.

3.3.1. Resizing Virtual Disks

Before resizing a virtual disk, note the following requirements and restrictions:

  • The virtual machine that uses the virtual disk to be resized must not have any snapshots.

  • The virtual disk size shown inside the virtual machine or container may differ from the size the virtual disk occupies on server’s physical disk.

  • In case disk size is increased, the added disk space is added as unallocated. You can use standard tools of the guest OS to allocate the added space.

  • You cannot reduce a container’s virtual disk by more than 16TB in total if the container is running. To do this, stop the container first and run vzctl set <CTID> --save --offline --diskspace <new_disk_size>.

  • You cannot reduce XFS file systems (the default choice for CentOS 7 and Red Hat Enterprise Linux 7).

3.3.1.1. Resizing Virtual Disks Offline

You can resize virtual hard disks of stopped virtual machines or containers with the prl_disk_tool resize --size command. For example:

# prl_disk_tool resize --hdd /vz/vmprivate/d35d28e5-11f7-4b3f-9065-8fef6178bc5b/harddisk.hdd --size 100G

3.3.1.2. Resizing Virtual Disks Online

Warning

Reducing virtual disk capacity of running virtual machines is prohibited.

You can resize virtual hard disks of running containers with the prl_disk_tool resize --size command. For example:

# prl_disk_tool resize --hdd /vz/private/85094686-4829-4ffa-a230-961c32c82bbe/root.hdd --size 100G

To resize virtual hard disks of running virtual machines, use the prlctl set --device-set --size --no-fs-resize command. For example, to resize the hdd0 hard disk of the MyVM virtual machine to 100G, execute:

# prlctl set MyVM --device-set hdd0 --size 100G --no-fs-resize

With the --no-fs-resize option specified, the last partition on the hard disk is not resized.

3.3.1.3. Checking the Minimum Disk Capacity

If, before reducing disk capacity, you want to know the minimum size to which it can be reduced, use the prl_disk_tool resize --info command. For example, if the disk hdd0 of the virtual machine MyVM is emulated by the image /vz/vmprivate/d35d28e5-11f7-4b3f-9065-8fef6178bc5b/harddisk.hdd, run the following command:

# prl_disk_tool resize --info --hdd /vz/vmprivate/d35d28e5-11f7-4b3f-9065-8fef6178bc5b/harddisk.hdd
Disk information:
...
Minimum: 2338M
...

3.3.2. Compacting Disks

Warning

Only use prl_disk_tool on disks of stopped virtual machines.

In Virtuozzo Hybrid Server, you can reduce the space your virtual machines and containers occupy on the physical server’s disk drive by compacting their virtual disks. Doing so frees up server disk space for hosting more virtual machines and containers.

To compact a virtual disk, you can use the prl_disk_tool compact command. For example, to compact the disk /vz/vmprivate/d35d28e5-11f7-4b3f-9065-8fef6178bc5b/harddisk.hdd, run this command:

# prl_disk_tool compact --hdd /vz/vmprivate/d35d28e5-11f7-4b3f-9065-8fef6178bc5b/harddisk.hdd/

To check the space that was freed by compacting the virtual disk, you can use standard Linux utilities (for example, df).