1

I tried to allocate 60GB of additional storage to my Win7 KVM by adding a new disk under 'Hardware Settings' using Add Hardware. But the new disk didn't show up in Win7 so i deleted the Disk using Remove Hardware. But the KVM img file .qcow2 has not released the 60 GB back. How do i get it back ? My KVM shows 70 GB disk but the .qcow2 image file is 131 GB in size.

John W
  • 11
  • 1

1 Answers1

2

virt-sparsify is a tool which can make a virtual machine disk (or any disk image) sparse a.k.a. thin-provisioned. This means that free space within the disk image can be converted back to free space on the host.

  1. Typical Usage: which copies indisk to outdisk, making the output sparse. outdisk is created, or overwritten if it already exists. The format of the input disk is detected (eg. qcow2) and the same format is used for the output disk.

    # This Method requires free space on disk to perform sparse:
    # By default it uses /tmp directory which commonly don't have required free space.
    #
    export TMPDIR=/<some directory with twice of the image size space available>
    virt-sparsify /path/to/indisk /path/to/outdisk
    
  2. you can sparsify a disk image in place by doing:

    virt-sparsify --in-place /path/to/disk.qcow2
    

Note: Using virt-sparsify on live virtual machines, or concurrently with other disk editing tools, can be dangerous, potentially causing disk corruption. The virtual machine must be shut down before you use this command, and disk images must not be edited concurrently.

Saqib Hashmi
  • 141
  • 5