When attempting to create an LVM mirror on CentOS 7, I consistently encountered the frustrating "Insufficient free space" error despite having adequate physical space available. The error message appeared in various forms:
# lvconvert -m1 centos_bi/home
Insufficient free space: 1 extents needed, but only 0 available
From the output of pvs
, vgs
, and lvs
commands, we can see:
# 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
The key observations:
- Volume group has 465.75GB free space (more than enough)
- Physical volume /dev/sda2 is completely free (465.27GB)
- Existing logical volumes are all on /dev/sdi2
After extensive testing, I discovered the issue relates to how LVM handles metadata areas and allocation policies. The critical points:
- LVM requires free extents on specific PVs based on allocation policy
- The default "normal" allocation policy restricts placement of mirror legs
- Metadata areas must be available on all PVs involved in mirroring
Here are the working approaches I found:
Solution 1: Using --alloc anywhere Policy
This overrides the default allocation constraints:
# lvconvert -m1 --alloc anywhere centos_bi/home /dev/sda2
Solution 2: Preparing PVs Properly
Ensure metadata areas exist on target PV:
# pvcreate --metadatacopies 2 /dev/sda2
# vgextend centos_bi /dev/sda2
Solution 3: Using Corelog Option
Eliminates need for separate log device:
# lvconvert -m1 --corelog centos_bi/home /dev/sda2
This sequence worked reliably in my environment:
# pvcreate /dev/sda2
# vgextend centos_bi /dev/sda2
# lvconvert -m1 --corelog --alloc anywhere centos_bi/home /dev/sda2
# lvconvert -m1 --mirrorlog mirrored centos_bi/root /dev/sda2
Key points to remember:
- Always verify free space with
pvs
andvgs
first - Consider your performance needs when choosing log type
- Test mirror sync with
lvdisplay
after creation
When attempting to create an LVM mirror on CentOS 7, you might encounter the frustrating "Insufficient free space: 1 extents needed, but only 0 available" error. This typically occurs even when you have physical volumes with available space, as shown in the example:
# lvconvert -m1 centos_bi/home
Insufficient free space: 1 extents needed, but only 0 available
From the provided configuration, we can see:
- Three physical volumes in the VG: /dev/sda1, /dev/sda2, and /dev/sdi2
- /dev/sdi2 is completely allocated (0 free extents)
- /dev/sda2 has all extents free (119109 free extents)
- The logical volumes (home, root, swap) are all on /dev/sdi2
The error occurs because LVM's default allocation policy tries to place the mirror legs on the same physical volume as the original. Since /dev/sdi2 is full, it fails. Even when specifying other devices with --alloc anywhere
, the operation still fails because of this default behavior.
Solution 1: Using Temporary Mirror
This workaround creates a temporary linear volume first:
# lvcreate -n home_mirror -l 100259 centos_bi /dev/sda2
# lvconvert --type mirror -m1 --mirrorlog core centos_bi/home /dev/sda2
# lvremove centos_bi/home_mirror
Solution 2: Manual Allocation
Force LVM to use specific devices for mirror legs:
# lvconvert --type mirror -m1 --alloc anywhere \
--mirrorlog core centos_bi/home /dev/sda2
Solution 3: Rebalancing Existing Volumes
Move some existing logical volumes to free up space:
# pvmove /dev/sdi2:0-6050 /dev/sda2 # Move swap
# lvconvert --type mirror -m1 centos_bi/home
- Always leave some free space in your VG for future operations
- Consider using
--alloc contiguous
when creating volumes - Plan your storage layout carefully when setting up LVM
If the above solutions don't work, try these advanced steps:
# vgchange --alloc normal centos_bi
# lvconvert --type mirror -m1 --mirrorlog core centos_bi/home /dev/sda2
Remember that LVM mirroring requires careful planning of your storage layout. The key is to ensure you have properly distributed your logical volumes across physical volumes before attempting mirror operations.