As part of a disaster recovery test, we made a backup of a virtual machine that runs our SQL server. The backup file was >360GB and took a long time to copy over USB 2.0 (don't ask me why our disaster recovery company didn't have usb 3.0). However, when we got the VM restored, I ran WinDirStat in it to determine what was taking up so much space, but the total space used reported by WinDirStat was only 100 gigs.

Where'd the extra 260 gigs from? And how can we reduce this in future VM backups?

  • 2
    At one time the virtual machine software expanded the virtual drive. Fixed or dynamic? – Ramhound Jan 12 '16 at 0:18

The virtual hard disk of the client has probably lots of deleted blocks, but the backup stores them, as they are part of the file.

A virtual disk is similar to a real disk - the OS deletes content by flagging the file and the blocks as deleted; but it doesn't overwrite the content. Seen from the host system, the virtual hard disk is just a big file, and the host of course cannot decide which bytes are this kind of old remains, and which are really needed, so all will be considered part of the file, and will be backed up.

There are ways to 'clean up' the virtual hard disk, and reduce its apparent size. Typically, you do:

  1. Defrag inside the client. This should condense the content in mostly contiguous blocks of the virtual hard disk.

  2. Overwrite the empty space with zeros inside the client. Under windows, there is the MicroSoft tool SDELETE that does that, for example. For other OS, there are similar tools.

  3. On the host system, clone the virtual hard disk into a new file. This will drop the blocks that have only zeros, and result in a file size very near to the real content of the hard disk.

  4. On the host, exchange the original virtual hard disk with the clone.

Note that usage of the VM will slowly increase its size again, as every write/delete sequence produces the blocks filled with 'data', so you will need to repeat the steps after some months of usage.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.