How to extend HDD space in ubuntu 20 VM (this example is hosted on ESXi)

After extending the hard disk of the VM in ESXi or any other hypervisor, reboot the VM and boot using a bootable GPARTED iso image.

Before the extention, this VM has 200GB HDD which is almost full now

Once the GPARTED gui comes up, confirm that the free space is showing up and then select the partition which needs to be extended and use the slider to extend it my moving it towards right side. Then click on SAVE to write the changes. We are done here so we can now reboot the machine to claim the newly added space in the OS. If the disk is 100% used then the OS will not let you make/save any partition chanes to the disk which is counter intutive but that is how it is designed so when the OS is rebooted, press escape button on keyboard and then select advanced ubuntu startup options and drop to root shell. Once here, run apt-get clear && apt-get autoremove this will remove enough space to enable you to write changes to the disk.

GPARTED – extending the partition

After the reboot, run these commands in this sequence to extend the volume.