A note of caution: What I describe belowed worked for me. I also took a backup from the virtual machine before doing any of the operations. There is no guarantee that this is the best, correct or even recommended way of doing the the resize.
About the terms I have used:
- host is the physical server that runs VMware Server. In our case version 2.0
- guest is the virtual machine that runs on the host
The first task was to expand the original 8 GiB virtual disk to 32 GiB. Here is what I did on the host:
host% sudo /opt/vmware/bin/vmware-vdiskmanager -x 32GB devel.vmdk
Grow: 100% done.
Disk expansion completed successfully.
WARNING: If the virtual disk is partitioned, you must use a third-party
utility in the virtual machine to expand the size of the
partitions. For more information, see:
http://www.vmware.com/support/kb/enduser/std_adp.php?p_faqid=1647
Now that the VMware disk image has been resized, what does it look like from the guest operating system? Boot up the guest and check with fdisk command:
guest% sudo fdisk -l /dev/sda
Disk /dev/sda: 34.3 GB, 34359738368 bytes
255 heads, 63 sectors/track, 4177 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000df028
Device Boot Start End Blocks Id System
/dev/sda1 * 1 1044 8385898+ 83 Linux
As one can see, the disk is now larger, but the Linux partition is still the same size as before resize.
The next steps are to expand the partition and its file system. In this case since we are resizing the root partition, the operation can not be done from the host operating itself. One method is to boot a live CD that contains the necessary tools.
Expanding the Linux partition and file system
For expanding the Linux partition and its file system, I decided to try GParted the Gnome Partition Editor which is conveniently available as a live CD.
The main screen of GParted shows what the current configuration is. There is 8 GiB of allocated space for sda1 and 24 GiB space available for expansion.
The resizing operation was simple. I clicked on "Resize/Move" to open a new window with a slider for moving and resizing the partition. I dragged the slider to cover the whole partition and clicked "Apply" from the main window. After the operation was completed, the partition was ready. Choosing "Partition -> Information" brings up this window:
The result
So did it work? Yes, just as expected.
After shutting the the GParted live CD and rebooting from the hard disk, everything was as expected. Host root file system was 32GiB, fdisk did not complain and no oddities were observed. Here are a couple of examples:
host% df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 32G 5.7G 25G 19% /
[rest of the output removed]
host% sudo fdisk -l /dev/sda
Disk /dev/sda: 34.3 GB, 34359738368 bytes
255 heads, 63 sectors/track, 4177 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000df028
Device Boot Start End Blocks Id System
/dev/sda1 * 1 4177 33551721 83 Linux