Ubuntu – Shrink extended partition containing lvm

gpartedlvmpartitioning

I have been bashing my head against the wall, regretting ever having opted into using LVM.

Gparted screenshot]

I need to shrink the 75GB /dev/sda2/ to make room for a new OS installation. To do this, I need to shrink the /dev/sd5 partition which is contained in sd2.

I first attempted to use GParted, but my version says it does not support LVM. I downloaded the latest .iso for GParted Live into a CD, but the results were similar.

So I have already taken all the steps to shrink the filesystem, volume group, physical volume, and so on.

user@computer:~$ sudo pvs
  PV         VG     Fmt  Attr PSize  PFree   
  /dev/sda5  ubuntu lvm2 a-   56.00g 1020.00m



user@computer:~$ sudo lvdisplay 
  --- Logical volume ---
  LV Name                /dev/ubuntu/root
  VG Name                ubuntu
  LV UUID                blahblahblah
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                55.00 GiB
  Current LE             14080
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

I have even removed the swap_1 volume.
When I run the latest GParted from the LiveCD, it does show the used 56GB volume group, then some 18GB unallocated space. However, it still does not let me resize /dev/sda5 or /dev/sda2. How can I resize /dev/sda2, given that the volume group and physical volumes are already 55GB, while is 18GB less than the size of the containing extended partition /dev/sd2?

Best Answer

Perhaps not the smartest solution:

use the tool system-config-lvm to migrate your data to another (temporal, external hard drive) device, delete the partition / do your resizing and migrate the data back.

hope that helps