Lvm – What prevents me from extending an LVM logical volume

lvm

I transferred an LVM-on-LUKS partition from my old computer and almost managed to resize it to use all 223 GB.

It's a typical Ubuntu installation with two LVM partitions:

~# lsblk

...
└─sda5                                          8:5    0   223G  0 part  
  └─luks-a8df437a-7906-4574-a6ff-16e337f8cb19 252:0    0   223G  0 crypt 
    ├─szop--vg-root                           252:1    0 146.6G  0 lvm   
    └─szop--vg-swap_1                         252:2    0     2G  0 lvm   
...

I also have a PV and VG which take the whole size:

~# pvdisplay

  --- Physical volume ---
  PV Name               /dev/mapper/luks-a8df437a-7906-4574-a6ff-16e337f8cb19
  VG Name               szop-vg
  PV Size               223.04 GiB / not usable 1.84 MiB
  Allocatable           NO
  PE Size               4.00 MiB
  Total PE              57097
  Free PE               19064
  Allocated PE          38033
  PV UUID               oxRbRw-P8xz-wTM9-1p1n-UkP7-zknB-31AHLR

~# vgdisplay

  --- Volume group ---
  VG Name               szop-vg
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  20
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               223.04 GiB
  PE Size               4.00 MiB
  Total PE              57097
  Alloc PE / Size       38033 / 148.57 GiB
  Free  PE / Size       19064 / 74.47 GiB
  VG UUID               IFezjq-rKPJ-Ydko-JV9P-l8RM-4oX8-Tijx9w

There are two LVs for this typical Ubuntu installation:

~# lvdisplay

  --- Logical volume ---
  LV Path                /dev/szop-vg/root
  LV Name                root
  VG Name                szop-vg
  LV UUID                a7BeRt-5STg-gbsr-cBES-h2q8-P0yT-nuK2Ic
  LV Write Access        read/write
  LV Creation host, time szop, 2016-08-07 16:39:48 +0000
  LV Status              available
  # open                 0
  LV Size                146.59 GiB
  Current LE             37528
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:1

  --- Logical volume ---
  LV Path                /dev/szop-vg/swap_1
  LV Name                swap_1
  VG Name                szop-vg
  LV UUID                On2jUZ-UTqF-3AxH-YkVq-DYPn-dbUA-2cq3iy
  LV Write Access        read/write
  LV Creation host, time szop, 2016-08-07 16:39:49 +0000
  LV Status              available
  # open                 0
  LV Size                1.97 GiB
  Current LE             505
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:2

I'd like to resize the root partition to use some remaining space:

~# lvresize -L +10G /dev/mapper/szop–vg-root

  Insufficient free space: 2560 extents needed, but only 0 available

Why I get this error?

Best Answer

I needed to mark my PV as Allocatable yes by using pvchange:

~# pvchange -x y /dev/mapper/szop--vg-root

Physical volume "/dev/mapper/luks-a8df437a-7906-4574-a6ff-16e337f8cb19" changed
1 physical volume changed / 0 physical volumes not changed

After this I could successfully resize my LV.

Related Topic