How to shrink a VMWare virtual disk
Posted January 31st, 2010 in VMWare
I use VMWare Server on several different computers to run virtualized Linux webservers for developing websites and for testing various versions of Internet Explorer. I recently needed to reduce the size of a Linux virtual disk to fit it onto a USB stick to copy to another machine but simply deleting files does not reduce the size of the disk image. This post links to another article offsite which shows how to do this and adds a couple of notes about it.
How to shrink VMware virtual disk files (.vmdk)
The first thing to do is to delete all the big files you do not need. As I noted above this will not actually make the vmdk files any smaller so a command line tool on Windows called vmware-vdiskmanager.exe or on Linux called vmware-vdiskmanager needs to be run to shrink the virtual disk files to reclaim unused space.
The process about how to do this can be found in the article how to shrink VMware virtual disk files (.vmdk) at HowtoForge.
When I first followed the instructions there I didn't read all the steps fully and missed out running the "cat /dev/zero > zero.fill;sync;sleep 1;sync;rm -f zero.fill" command on the Linux guest. This is a critical step. If the command is not run then the virtual disk files will be the same size after the vdiskmanager command has completed running.
Once the free space is zeroed out (which doesn't take very long) and the vdiskmanager command is run on the shut down guest's virtual disk the files will be reduced to just that actually used by the virtual machine.
When I ran this myself, I reduced the size of my virtual disk files from 10.9GB to 5.1GB, the latter being more or less what "df -h" was reporting inside the virtual machine.
Related posts:
- Connect a USB device with VMWare Server 2 (Friday, June 5th 2009)
- Install VMWare Tools on a Debian 5 Guest Virtual Machine (Saturday, March 7th 2009)
Share or Bookmark
Share or Bookmark this page using the following services. You will need to have an account with the selected service in order to post links or bookmark this page.
Subscribe or Follow
Subscribe via RSS or email, or follow me on Facebook or Twitter below. The RSS icon takes you through to Feedburner where you can select the service or application to use.
