Apparently the VMware tools installed on Ubuntu 11.10 and some other
versions of Linux are not able to shrink an ext4 disk partition.
http://www.insomnihack.com/?p=387
To do it another way, first fill up the empty parts of the virtual
disk with zeros:
# This step is optional, but can eliminate some apt package files and
# save some disk space.
% sudo apt-get clean
# This step is also optional, but can help identify apt packages
# taking up the most disk space. Source:
# http://www.commandlinefu.com/commands/view/3842/list-your-largest-installed-packages-on-debianubuntu
% sed -ne '/^Package: \(.*\)/{s//\1/;h;};/^Installed-Size: \(.*\)/{s//\1/;G;s/\n/ /;p;}' /var/lib/dpkg/status | sort -n
# bs=20megabytes is simply the block size that will be written at a
# time. The command below will copy 2 megabytes of 0 bytes from
# /dev/zero at a time to the file /0bits, until the virtual disk is
# full.
sudo dd if=/dev/zero of=/0bits bs=20971520
# Now remove that file.
sudo rm /0bits
After you've executed these commands, shutdown your VM and use
vmware-vdiskmanager to shrink the virtual drive file.
Windows instructions:
cd "C:\Program Files\VMware\VMware Workstation"
vmware-vdiskmanager -k path\to\your\VirtualDisk.vmdk
On my Mac:
cd ~/Virtual Machines.localized/Ubuntu 11.04 32bit.vmwarevm
# With VMware Fusion 4
# also works with VMware Fusion 6, although file name may be something like Virtual\ Disk.vmdk
/Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager -k Ubuntu\ 11.04\ 32bit.vmdk
# Older cmd line with VMware Fusion 3
/Library/Application\ Support/VMware\ Fusion/vmware-vdiskmanager -k Ubuntu\ 11.04\ 32bit.vmdk