45

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?

  • this image sourced from the linux HOST or GUEST (aka VM) – linuxdev2013 May 22 '15 at 0:33
  • The image is from the guest VM, sorry if I was not clear – papnikol May 22 '15 at 0:38
  • 2
    Okay , 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 May 22 '15 at 0:40
  • 1
    It 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 May 22 '15 at 1:06
  • 2
    the lock implies mounted or crypted select them should have ` unmount ` option – linuxdev2013 May 22 '15 at 1:56
59

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]
| improve this answer | |
  • 4
    Thanks! 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 Aug 20 '15 at 11:02
  • Thanks for your precise answer, that saved me hours and grey hair! – derFunk Sep 2 '15 at 16:40
  • 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 Nov 25 '15 at 22:54
  • Unfortunately, for me deactivating them doesn't work. No error message either... Any hints? – Christoph Wurm Dec 4 '15 at 16:08
  • 5
    I 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 Mar 9 '16 at 21:10
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

| improve this answer | |
  • 1
    He was asking how to resize the physical volume ( the disk partition ), not a logical volume. – psusi Nov 7 '18 at 16:49
  • 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 Oct 22 '19 at 2:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.