VMmanager Knowledge Base

VM disk size is not decreasing

Description

The platform continues to display the maximum value of the disk space used after the disk is released.

The reason for this behavior is that dynamic space allocation for virtual disks in the file storage works only upwards. And it is only possible to reduce the size of the VM disk to return the unused space manually using the virt-sparsify utility. This is due to the limitation of libguestfs software. For more information about the virt-sparsify utility, see the official libguestfs documentation.

Solution

Warning

Before taking any actions on a virtual disk:

  • create a backup of the VM;
  • make sure that the VM that uses the virtual disk is stopped.
Note
The instructions are relevant for file storage.

To reduce the disk size manually:

  1. Shut down the VM.
  2. Rename the virtual disk file. For example:

    mv /vm/test-1 /vm/test-1.bak
  3. Run optimization with the virt-sparsify utility:

    virt-sparsify /vm/test-1.bak /vm/test-1
    Comments
  4. Start the VM.
  5. If the disk space optimization was successful, delete the source virtual disk file:

    rm /vm/test-1.bak
    Comments