LVM mirror attempt results in "Insufficient free space"
Solution 1:
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.