5

Attempting to add a disk to mirror an LVM volume on CentOS 7 always fails with "Insufficient free space: 1 extents needed, but only 0 available". Having searched for a solution, I have tried specifying disks, multiple logging options, adding 3rd log partition, but have not found a solution

Not sure if I am making a rookie mistake, or there is something more subtle wrong (I am more familiar with ZFS, new to using LVM):

# lvconvert -m1 centos_bi/home
  Insufficient free space: 1 extents needed, but only 0 available  
# lvconvert -m1 --corelog centos_bi/home
  Insufficient free space: 1 extents needed, but only 0 available
# lvconvert -m1 --corelog --alloc anywhere centos_bi/home
  Insufficient free space: 1 extents needed, but only 0 available
# lvconvert -m1 --mirrorlog mirrored --alloc anywhere centos_bi/home /dev/sda2
  Insufficient free space: 1 extents needed, but only 0 available  
# lvconvert -m1 --corelog --alloc anywhere centos_bi/home /dev/sdi2 /dev/sda2
  Insufficient free space: 1 extents needed, but only 0 available

The two disks are of the same size, and have identical partition layouts via "sfdisk -d /dev/sdi > part_table; sfdisk /dev/sda < part_table". The current configuration is detailed below.

# pvs
  PV         VG        Fmt  Attr PSize   PFree
  /dev/sda1  centos_bi lvm2 a--  496.00m 496.00m
  /dev/sda2  centos_bi lvm2 a--  465.27g 465.27g
  /dev/sdi2  centos_bi lvm2 a--  465.27g      0

# vgs
  VG        #PV #LV #SN Attr   VSize   VFree
  centos_bi   3   3   0 wz--n- 931.02g 465.75g 

# lvs -a -o +devices
  LV   VG        Attr       LSize   Pool Origin Data%  Move Log Cpy%Sync Convert Devices
  home centos_bi -wi-ao---- 391.64g                                              /dev/sdi2(6050)
  root centos_bi -wi-ao----  50.00g                                              /dev/sdi2(106309)
  swap centos_bi -wi-ao----  23.63g                                              /dev/sdi2(0)


# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sdi2
  VG Name               centos_bi
  PV Size               465.27 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              119109
  Free PE               0
  Allocated PE          119109

  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               centos_bi
  PV Size               465.27 GiB / not usable 3.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              119109
  Free PE               119109
  Allocated PE          0

  --- Physical volume ---
  PV Name               /dev/sda1
  VG Name               centos_bi
  PV Size               500.00 MiB / not usable 4.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              124
  Free PE               124
  Allocated PE          0

# vgdisplay
  --- Volume group ---
  VG Name               centos_bi
  System ID
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  10
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               931.02 GiB
  PE Size               4.00 MiB
  Total PE              238342
  Alloc PE / Size       119109 / 465.27 GiB
  Free  PE / Size       119233 / 465.75 GiB

# lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos_bi/swap
  LV Name                swap
  VG Name                centos_bi
  LV Write Access        read/write
  LV Creation host, time localhost, 2014-08-07 16:34:34 -0400
  LV Status              available
  # open                 2
  LV Size                23.63 GiB
  Current LE             6050
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Logical volume ---
  LV Path                /dev/centos_bi/home
  LV Name                home
  VG Name                centos_bi
  LV Write Access        read/write
  LV Creation host, time localhost, 2014-08-07 16:34:35 -0400
  LV Status              available
  # open                 1
  LV Size                391.64 GiB
  Current LE             100259
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

  --- Logical volume ---
  LV Path                /dev/centos_bi/root
  LV Name                root
  VG Name                centos_bi
  LV Write Access        read/write
  LV Creation host, time localhost, 2014-08-07 16:34:37 -0400
  LV Status              available
  # open                 1
  LV Size                50.00 GiB
  Current LE             12800
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
  • Um, have you tried the obvious? Shrink one of the LVs. – Michael Hampton Aug 21 '14 at 15:34
  • Its not too obvious, as "lvreduce -l 1" warns of potential data destruction on the home and root volumes. Since this is a test machine, I tried it anyway, and the volumes no longer mount. – kermatt Aug 21 '14 at 15:51
  • 1
    yeah you should've shrunk the fs first... – Petter H Aug 21 '14 at 17:39
  • And the default XFS filesystem in CentOS 7 is not shrinkable. Will have to recreate with some slack space. – kermatt Aug 21 '14 at 18:10
  • try with "lvconvert -m1 --corelog centos_bi/home /dev/sda2" – c4f4t0r Aug 21 '14 at 21:49
12

Since about September 2013, the default mirror segment type in lvm2 has been 'raid1' (not 'mirror'). This makes --corelog and --mirrorlog disk/core/mirrored options inapplicable in this default case, because raid1 segment type always stores its logs (in fact, metadata subvolumes) on-disk on the same PV(s) as the LV being mirrored. You no-longer need a third PV for the log, or to store the log in-memory.

There are two further implications. First, the command to create the mirror is simplified, because there is only a need to specify the LV to be mirrored, and the (usually one) PV on which the mirror segment will be stored: # lvconvert -m1 /dev/my_vg/my_lv /dev/my_new_pv

Second, there are a couple of space considerations. You need to have:

  • obviously, space on the mirror PV to store the copy of the original LV,
  • but also, 1 additional LE on the mirror PV, to store the log,
  • AND ALSO (and this is the point I missed for some time), 1 additional LE on the original PV, to store the log (since the log is stored on BOTH the original PV and the new PV).

Often this original-PV additional space requirement causes a problem because there is no space in the existing PV for even 1 new LE to be allocated for the log. In this case, you might get an error of the kind OP encountered, ie., 1 extents needed, but only 0 available.

The remedy, as indicated above by others, is to resize (shrink, after shrinking the filesystem) the existing LV, so there is room for the log to be allocated on the same PV. If you can't do that, you can use --type mirror to force legacy 'mirror' segment type.

  • 1
    How much do I need to shrink the FS and LV to make room for 1 LE? – bjarkef Nov 3 '16 at 10:12
  • @bjarkef 1LE is usually 4MiB. You can confirm this for your particular system/vg with vgs -o vg_name,vg_extent_size – Patrick Nov 3 '16 at 22:38
  • So long as the total size of your VG is at least 2x your LV +1 extent shouldn't it be possible to extend the existing LV by the one necessary extent? – Sammitch Nov 9 '16 at 20:24

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.