Gparted cannot resize extended or LVM partition

41

22

I created a VM using VirtualBox and realized it was too small. After some time I managed to create a new, bigger hard drive.

Live GParted CD image (v.022):

GParted screenshot

Now I need to integrate the unallocated space to the /dev/sda5 partition.

  • Right-clicking on sda5 shows the option to resize but I dont get any free space before or after.
  • I though that perhaps I needed to extend the sda2 partition first but right-clicking on sda2 does not allow me to resize.

Do you have any useful advice?

papnikol

Posted 2015-05-21T23:57:36.017

Reputation: 1 269

this image sourced from the linux HOST or GUEST (aka VM) – linuxdev2013 – 2015-05-22T00:33:42.593

The image is from the guest VM, sorry if I was not clear – papnikol – 2015-05-22T00:38:05.560

2Okay , Is the vg crypted OR just mounted in both cases it needs to be unmounted and additionally in the first case decrypted and unmounted – linuxdev2013 – 2015-05-22T00:40:01.327

1It is not encrypted. Since I started from the gparted live cd, shouldn't all partitions be unmounted? If not, how do I unmount them from gparted? – papnikol – 2015-05-22T01:06:31.947

2the lock implies mounted or crypted select them should have unmount option – linuxdev2013 – 2015-05-22T01:56:05.963

The lock you mentioned was the problem. There was a choice called deactivate, I used it, increased the extended partition (sda2) and then increased the lvm partition (sda5). It worked fine. Still, when I enter my VM I see only the previous space as available, but I suspect I must do something to increase th filesystem in the, now allocated, space. – papnikol – 2015-05-22T16:42:02.710

lvextend -r /dev/sda5 should fix that (the -r 'flag' tells the system to resize the filesystem as well) – linuxdev2013 – 2015-05-24T13:06:38.517

Yes, I already found out, after your help, and wrote something similar in the answer – papnikol – 2015-05-24T13:09:52.160

Answers

54

After some help from linuxdev2013, this is what I did:
The problem was that the partitions were somehow locked. So:

  1. I right Clicked both sda2 and sda5 and chose "Deactivate".
  2. I resized the extended (sda2) partition.
  3. I resized the lvm (sda5) partition.

The problem was fixed.

I should add that in the VM the new space was not available, so I had to run those 2 commands: expand LVM to all remaining free space:

lvextend –l +100%FREE [MOUNTPOINT]

expand filesystem:

sudo resize2fs [MOUNTPOINT]

papnikol

Posted 2015-05-21T23:57:36.017

Reputation: 1 269

4Thanks! I also needed lvm lvdisplay to get the exact device for lvextend, and later df -h to find out the volume on which to resize. – Andreas Reiff – 2015-08-20T11:02:08.330

Thanks for your precise answer, that saved me hours and grey hair! – derFunk – 2015-09-02T16:40:58.563

After using gparted, the partition wasn't showing the right amount free. These 2 command line functions were exactly what I needed to finish the job. Thanks for sharing that wizardry – twig – 2015-11-25T22:54:27.030

Unfortunately, for me deactivating them doesn't work. No error message either... Any hints? – Christoph Wurm – 2015-12-04T16:08:03.623

4I had to run sudo lvdisplay to get the [MOUNTPOINT]. In my case it came back as LV Path (/dev/ubuntu-vg/root) – Sheamus O'Halloran – 2016-03-09T21:10:09.663

Nothing was working for me, the lock wouldn't go away even after trying to "deactivate" several times. The only thing that actually unlocked my partition in gparted was to create a new partition in the empty space and then delete it. The lock icon went away and I was able to extend the extended partition... – Frank.Germain – 2016-09-08T14:14:21.737

The GParted Live CD image automatically used the swap space within the LVM partition of my RHEL 5 and 6 VMs. I had to run sudo swapoff -a from the command line then use the deactivate on the partitions with the padlock. – dan_linder – 2016-09-23T15:01:08.377

Thanks - The deactivate of the extended and VG partitions did it for me. – Chris Mendla – 2017-06-09T17:17:45.267

0

appliance@zabbix:~$ sudo lvdisplay

--- Logical volume ---

LV Path /dev/zabbix-vg/root

LV Name root

VG Name zabbix-vg

LV Size 15.52 GiB


--- Logical volume ---

LV Path /dev/zabbix-vg/swap_1

LV Name swap_1

VG Name zabbix-vg

LV Size 4.00 GiB


appliance@zabbix:~$ sudo vgs

VG #PV #LV #SN Attr VSize VFree

zabbix-vg 1 2 0 wz--n- 24.52g 5.00g


As you see i have 5 GB Free space


appliance@zabbix:~$ sudo lvextend -L+5G /dev/zabbix-vg/root

Size of logical volume zabbix-vg/root changed from 15.52 GiB (3973 extents) to 20.52 GiB (5253 extents).

Logical volume root successfully resized.


appliance@zabbix:~$ sudo resize2fs /dev/zabbix-vg/root

The filesystem on /dev/zabbix-vg/root is now 5379072 (4k) blocks long.


appliance@zabbix:~$ sudo lvdisplay

--- Logical volume ---

LV Path /dev/zabbix-vg/root

LV Name root

VG Name zabbix-vg

LV Size 20.52 GiB


--- Logical volume ---

LV Path /dev/zabbix-vg/swap_1

LV Name swap_1

VG Name zabbix-vg

LV Size 4.00 GiB

Abdelhak

Posted 2015-05-21T23:57:36.017

Reputation: 1

1He was asking how to resize the physical volume ( the disk partition ), not a logical volume. – psusi – 2018-11-07T16:49:23.310

exactly what I am looking for. extended my physical drive with no problem but it doesn't apply on the logical drive. you helped me adjust my logical drive. thanks a million! – kapitan – 2019-10-22T02:27:39.580