I had a lot of similar troubles. A few things:
- do the VDI resize whilst the machine is powered off
- resize the partition with
fdisk
before resizing anything related to LVM
- you've possibly set your
/dev/sda2
to extend past the end of the disk if you also have /dev/sda1
(you used the full 20G for /dev/sda2
, but it probably does not start at 0)
I found this page to be most complete. There are also a couple of answers which you might find handy.
I would guess that you need to either shrink /dev/sda2
with pvresize
so the whole of /dev/sda
fits into the VDI, or grow the VDI a little more. Then you can use fdisk
, then continue with the LVM operations as you did above.
Because the partition contains an LVM2 volume group, it's treated as busy (even if it doesn't appear mounted). You need to deactivate the VG:
sudo vgscan # to discover the name of the volume group "mint-vg"
sudo vgchange -a n mint-vg
Then, in gparted, select GParted
/ Refresh Devices
. This should remove the lock icon from the partitions.
Aside: rather than a lock icon, my copy of gparted displays a telephone, which is ... confusing.
At this point, you should be able to resize the extended partition, /dev/sda2
as normal to use the unallocated space. Apply the change.
Then resize the 'lvm2 pv' partition, /dev/sda5
. Apply the change.
Then resize the PV:
sudo pvresize /dev/sda5
Check the new size:
sudo pvdisplay /dev/sda5
Reactivate the volume group:
sudo vgchange -a y mint-vg
Then extend the logical volume into the new space:
sudo lvextend /dev/mint-vg/root /dev/sda5
I forgot to specify -r
to resize the filesystem, so I have to do that as well...
sudo e2fsck -f /dev/mint-vg/root
sudo resize2fs /dev/mint-vg/root
Best Answer
The process appears to be:
cfdisk
to flag the new partition as Linux LVM instead of whatever you chose abovepvcreate
to flag your new partition as a physical volume for LVMvgextend
to add your new physical volume to your existing VolumeGrouplvresize
to expand your desired logical volume with the new space in its volume groupresize2fs
to grow your fs to use the new space on your logical volume (I hope your filesystem supports online resizing)