Patent attributes
Systems and methods for compacting a virtual machine file are presented. In one example, the system accesses a source virtual machine file associated with a guest file system. The system creates a destination virtual machine file based on the guest file system and initializes a block allocation table of the destination virtual machine file. The system accesses a block allocation table of the source virtual machine file and, for each block of the source virtual machine file, determines whether the block is in use. If so, the system copies the block to the destination virtual machine file and updates the block allocation table of the destination virtual machine file. If not, the system does not copy the block or update the block allocation table of the destination virtual machine file, thereby reducing the destination virtual machine file's size compared to the source virtual machine file's size.