Expanding the disk size for an Ubuntu guest on VMware ESXi

Stop the guest VM.

Change the attached disk size in VM settings:

Attach a gparted iso or alternatively you can attach the original Ubuntu desktop ISO that you originally installed from.

Change the Boot Option for your VM to boot into the guest VM’s BIOS (‘Force BIOS setup’) to change the boot order with the cdrom first (by default it won’t boot from the attached cdrom as it’s set to only boot from cdrom if the attached disk does not boot first):

With the gparted iso or Ubuntu desktop install iso attached, restart the VM, and then run gparted.

Use gparted to expand the partition into the free space.

Once resized, reboot the Unbuntu guest (reset the boot order or unattach the cdrom iso image).

Use pvdisplay to get the Volume Group name

$ sudo pvdisplay

  --- Physical volume ---

  PV Name               /dev/sda5

  VG Name               ubuntu-vg

  PV Size               39.76 GiB / not usable 2.00 MiB

  Allocatable           yes (but full)

  PE Size               4.00 MiB

  Total PE              10178

  Free PE               0

  Allocated PE          10178

Use vgextend with the volume group name and physical disk name to extend:

sudo vgextend ubuntu-vg /dev/sda5

Use lvextend with param “-l+100%FREE” to expand the logical volume:

sudo lvextend -l+100%FREE /dev/ubuntu-vg/root

Now use resize2fs:

sudo resize2fs /dev/mapper/ubuntu--vg-root

Done!

More info on using gparted here. Info on resizing LVM disks in this article here.

4 Replies to “Expanding the disk size for an Ubuntu guest on VMware ESXi”

  1. Note: on a default Ubtuntu 18.04 server install, resizing the partition in gparted and then booting the VM was enough for it to pick up the new partition size with no other changes (because the default install did not use volume groups?)

  2. My god this was awesome to find. I did several different google searches before this one showed up, but it was exactly what I was looking for and the steps worked. As Kevin wrote, just expanding with gparted was enough. When I restarted my VM (ubuntu server) it already had the extra space.

    Thanks for a great write up!

  3. OMG this was such a lifesaver! Thank you for sharing!

    I went through dozens of articles/forum posts and was about to give up when I found your post. I was literally closing the remaining browser tabs before proceeding to rebuild my VM when I noticed your post had a few commands I’ve never seen before.

    Every other guide and troubleshooting post out there has basically the same steps: “make the disk bigger in VMWare –> boot gparted –> resize the partition –> run resize2fs /dev/sdX”, which didn’t work for me.

    I followed your guide with the minor modifications below and presto, my free space jumped from 0% to 50%!

    sudo vgextend ubuntu-vg /dev/sda3
    sudo lvextend -l+100%FREE /dev/ubuntu-vg/ubuntu-lv
    sudo resize2fs /dev/mapper/ubuntu–vg-ubuntu–lv

Leave a Reply to kevin Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.