Introduction

SoftPerfect Virtual Disk Trim makes virtual machine disk images smaller. A virtual disk grows as the guest system writes to it, but it does not shrink when files are deleted inside the guest: the guest marks the space as free, yet the blocks stay in the image. The usual remedy is to overwrite the free space with zeros inside the running guest and then have the hypervisor compact the image.

Virtual Disk Trim takes the direct route. Every file system keeps a record of which of its clusters are in use. The application reads that record straight from the image file and rebuilds the image without the blocks that hold nothing. The virtual machine is never started, nothing is mounted and nothing inside the guest is modified. It runs on Windows, macOS and Linux and needs no virtualisation software.

How it works

  • Analysis. When an image is added, the application reads its block table, finds the partitions and reads the allocation record of each file system it recognises. It also checks that the image is safe to trim. Only this bookkeeping is read, so even a large image takes moments, and nothing is written.
  • Trim. A new image is written with the blocks that are in use, leaving out the rest. Everything the guest relies on stays byte for byte the same (only free space, and files you chose to discard, may read differently), volumes with an unrecognised file system are copied whole, and the disk keeps the identity by which the hypervisor knows it. A fixed-size disk is rebuilt as a dynamically expanding one, which is how it gives up its empty space.
  • Verification. The new image is opened again and compared with the original. Only when they agree does it take the original’s place; otherwise it is discarded and the original is left exactly as it was.

Partitions are not moved or resized, and the capacity of the disk as the guest sees it does not change: only the image file becomes smaller.