Archive for February, 2013

How To Shrink VMware Virtual Disk Files with Windows Guest

Feb 20 2013 Published by under Windows

While at home for reading week, I set up my development environment on Windows XP Professional, 64-bit. XP x64 was never meant to be run on real hardware, as it lacks driver support from hardware vendors. However, it was free for students and quick to set up with VMWare as I only had to enter the license key for an unattended install. I originally indended to carry around the virtual machine on a 8GB USB, but the hard disk file exceeded by a few GB. I managed to shrink all the files required to run the virtual machine combined down to less than 3GB. Here’s a quick run down of the process that requires about 1 hour for a computer to complete:

  1. Uninstall unused applications
  2. Delete downloads manually
  3. Clean out temporary files with CCleaner
  4. Shutdown virtual disk and make a copy
  5. Hook the virtual disk into slot2 and start the virtual machine Settings -> Hard Disk -> Add…
  6. Zero out unused parts of partitions on the copied disk with KillDisk wipe
  7. Shutdown virtual machine to work with the virtual disk file
  8. Defragment copied hard drive under Settings -> Hard Disk -> Utilities
  9. Compress copied hard drive
  10. Find the virtual machine working folder under Settings -> Options tab
  11. Replace the larger virtual disk file with the smaller one
  12. Create a zip folder of the virtual machine files, 7-zip is suggested

It’s easy to see why this process works, if you understand how file systems work. Because deleted files are still on the hard drive, they cannot be compressed in the virtual disk file. So the idea is to overwrite those unused sectors of the hard drive with zero’s. VMWare’s defragment collects zeros together at the end of the disk, and compress completely removes them from the virtual disk file, shrinking the file. If you’re making a clone of the virtual machine for later use, it is suggested to start the operating system again as it will detect hardware changes and reconfigure. Many of these steps take a few minutes to complete, so it is wise to have something else to do while waiting.

Update: Instead of using KillDisk, CCleaner has a wipe utility under Tools -> Drive Wiper. The default settings writes zeros over the free space. Compared to my method, it’s slower. One way to speed it up is to give the process realtime priority in the Task Manager.

No responses yet