Resizing an Ubuntu virtual machine under VMware Workstation

05 Jul 2017

Having had trouble finding the instructions I needed to resize the “disk” of my Ubuntu based virtual machine under VMware Workstation 12, I have decided to create my own little guide.

Environment and tools:

Things to note are that my virtual machine is my main development environment that I have been maintaining for years now and I find that I need to give it a little extra room now and again. One of the main changes I made a while ago is to use lvm with a single volume group and only two logical groups: one for swap and one for everything else. In my opinion, it is more of a hindrance to have separate partitions for virtual machines as the major reasons for having multiple partitions do not really apply to virtual machines.

Steps:

  1. While the virtual machine is shut down, use VMware’s “Edit virtual machine settings” to open the settings menu.
  2. Click on the hard drive and then the “Expand” button.
  3. Increase the size to the new desired size.
  4. For the CD/DVD, specify the gparted iso and make sure “connect at powerup” is enabled.
  5. Boot the virtual machine with gparted. This might require using “Power on to Firmware” in order for the iso to boot before the OS.
    1. “deactivate” the partition so that it can be edited.
    2. resize the extended partition to fill the space.
    3. resize the sub-partition to fill the space.
    4. Apply the changes.
  6. Reboot into the OS.
    1. vgdisplay to see volume group information. Note the “Free PE /Size” value.
    2. lvdisplay to get the LV Path.
    3. lvextend -L +<size>G <lv path> to resize the logical volume.
    4. resize2fs <lv path> to get the file system to adjust to the new size.