Wednesday, April 10, 2013

How to shrink Linux .vmdk file on Windows host

Ever face the problem of your Linux image file keep growing bigger in size while the actual usage is smaller? I encountered this when my apache server created a massive 15GB log file and after deleting the log file, my image file is still 15GB+.

 Follow the steps to reduce the image file.

Step 1. Fill the unused space with zero with the following command:
sudo cat /dev/zero > zero.fill;sync;sleep 1;sync;rm -f zero.fill
Wait for it to complete as it will take some times to complete depending on the assigned storage size.

Step 2. Power down the Linux guest OS when Step 1 complete.

Step 2.   If you have not set a path for your vmware, locate the location of where you installed your vmware. For mine, it is located at "C:\Program Files (x86)\VMware\VMware Workstation".

Step 3. Open command prompt and browse to the directory of the .vmdk file you want to reduce and enter the following command to begin shrinking:

"C:\Program Files (x86)\VMware\VMware Workstation" -k "Your_Image_File.vmdk"

No comments:

Post a Comment