Howdy. I have an Ubuntu Server (18.04) VM that I created quite a while ago. It’s running under vSphere 6.7. I initially created the vdisk to only be 60GB, not knowing how much I would need in the long run. I’m down to about 10% free so I’d like to expand the existing partition/file system.
I expanded the vdisk within vSphere to 100GB no problem. But I’m not familiar enough with the filesystem to understand what’s going on. I followed a guide I found on using fdisk but that didn’t work, as the partition wasn’t usable after.
This is the output of df -h, I don’t understand what the /dev/mapper/hera--vg-root is. (Hera is the hostname).
After you expanded the virtual “physical” disk for your vm, there are two layers of software that need to be adjusted.
First the partition holding your data needs to be expanded, a low level tool of fdisk could do that.
Then the file system needs to be expanded to take advantage of that newly available space. In your case this has two layers by itself: LVM and the file system on top.
I’m just explaining this so that you know why you were not successful, yet. I’d say don’t bother with the low level stuff and follow the advise from @Cizin : use the graphical tool “gparted” that will take care of this for you.
Install it in your vm and on opening you should find a disk that leaves space to expand a partition. Drag the existing partition to fill the space, let gparted do the rest.
resize drive to maximum capacity using parted
parted /dev/sda
type following commands into parted
list (shows you which partitions are used)
resizepart 5 80G (number 5 was my partition can be different for you)
then exit parted and type following as root (do sudo su if you don't know how to root)
pvresize /dev/sda5
lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
df -H