How to expand the ext4 primary partition size in a VMware Player virtual disk?

I have a VMware Player virtual machine setup, running Ubuntu 10.04 as the a guest OS.

The VM was created on a 20GB virtual drive, with a single partition for working space. Finally I got to the point where I need to expand the size of the virtual drive. Resizing the drive itself, adding some 10GB, was easy via the VMware Player menus. I now need to resize the main partition itself (I prefer this over creating a separate partition and mounting it).

According to GParted, I now have the following partitions:

enter image description here

My question is, how can I increase the size of the Filesystem partition to include the free 10GB?

From information I found online, it looks like one limitation is the fact that he swap partition is immediately adjacent to the filesystem, so my understanding is that first thing would be to move that partition to the end of the volume. How can this be done?

Also, some sources suggest that the system should be booted from a LiveCD, so the filesystem is not the boot partition, and thus make it easier to resize. As mentioned above, I run a VM, so I am not sure how to boot it from a LiveCD. Any ideas?


I was just doing exactly that a minute ago. What you want to do is:

  1. In the machine's settings point the CD Drive to the .iso file with your Ubuntu LiveCD. You may also need to make sure the "Connect at power on" check box is checked.
  2. Power the virtual machine on and hit F2 with the focus inside the machine.
  3. Once inside the BIOS move to the Boot tab and select CD-Rom as primary boot device.
  4. Run gParted - I think it's always there.
  5. Destroy the swap partition: swapoff, delete the extended and linux-swap partitions.
  6. Resize your primary partition to desired size.
  7. Allocate your swap back again to whatever you like - create an extended partition and then allocate as linux swap. Remember about swapon :)

And that's it. You now have a big primary partition!

In my case you'd need to have Jedi reflexes to get into BIOS by pressing F2 on the splash screen - the boot delay is just too short. What you can do to slow it down is go to your vm's .vmx file and type in something reasonable like:

bios.bootDelay = "5000"

For 5 seconds of boot delay.