Can't resize a partition using resize2fs
If you only changed the partition size, you're not ready to resize the logical volume yet. Once the partition is the new size, you need to do a pvresize
on the PV so the volume group sees the new space. After that you can use lvextend
to expand the logical volume into the volume group's new space. You can pass -r
to the lvextend
command so that it automatically kicks off the resize2fs
for you.
Personally, I would have just made a new partition and used vgextend
on it since I've had mixed results with pvresize
.
Thanks a lot for @Bratchley answer and the comments. It helped me :)
My environment: Ubuntu 18.04 in VirtualBox 6.1
My case: I created 10GB fixed VDI disk and increased to 30GB dynamic using VirtualBox GUI. But still the increased space is not available to filesystem. Then came across @Bratchley answer.
Steps I ran:
- Get PV (Physical Volume) name (Ex:
/dev/sda1
)
sudo pvs
- Resize the PV
sudo pvresize /dev/sda1
- Get root logical volume name (Filesystem value of
/
row; ex:/dev/mapper/ubuntu--vg-root
)
df -h
- Expand logical volume:
sudo lvextend -r -l +100%FREE /dev/mapper/ubuntu--vg-root