ERROR: Insufficient free extents in volume group
While adding a logical volume you might face an error as follows:
Insufficient free extents (XXXX) in volume group VOLUMEGROUPNAME: XXXXX required
localhost:~ # lvcreate -L +100G -n <logical_vol_name> <vg_name>
Insufficient free extents (25599) in volume group vg_data: 25600 required
This error basically arrises as the vgdisplay or the vgs command try to round off and manipulate the assigned size in to human readable format.
To work around this issue you can consider using the physical extent units instead of the exact byte format for the size limits.
Following the steps mentioned below can help to sort the issue:
Use the following command to verify the free extent and total extent count:
localhost:~ # vgs -o +vg_free_count,vg_extent_count
VG #PV #LV #SN Attr VSize VFree Free #Ext
vg_data 1 0 0 wz–n- 100.00G 100.00G 25599 25599
You can notice the free extents available are 25599 . Now in order to use the free extent value instead of the byte size you can use the option -l as follows
localhost:~ # lvcreate -l 25599 -n LV_home vg_data
Logical volume “LV_home” created
Above command will use all the available free extents. Check this with the following command.
localhost:~ # vgs -o +vg_free_count,vg_extent_count
VG #PV #LV #SN Attr VSize VFree Free #Ext
vg_data 1 1 0 wz–n- 100.00G 0 0 25599
Now view the created logical volume.
localhost:~ # lvdisplay
— Logical volume —
LV Name /dev/vg_data/LV_home
VG Name vg_data
LV UUID 3BLbnm-8KfX-pHOm-oE5f-GRei-qTN8-uHFgZI
LV Write Access read/write
LV Status available
# open 0
LV Size 100.00 GB
Current LE 25599
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:0