Hi just a note to possibly save others some time with regard to conversion of lvm2 (linear) logical volumes to mirrored volumes using lvconvert, eg, to implement raid1 redundancy on an existing linear lv.
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 PVs 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 lv, to store the log (since the log is stored on BOTH the original pv and the new pv)
In some cases this third space requirement causes a problem because there is no space in the existing lv for even 1 new LE to be allocated for the log. In this case, you might get an error such as:
1 extents needed, but only 0 available
(unhelpfully not indicating that the LE is required on the original pv, not the new pv)
The remedy is to resize the existing lv (and other lvs on the same pv, and the underlying filesystems, if necessary) so that there is enough space on the existing lv to allocate 1 additional PE for the log. In my case, for example, my existing pv was completely full, so I had to:
- resize each filesystem on the pv to make each slightly smaller (use resize2fs)
- then resize each lv to make each slightly smaller to allow room for logs (use lvreduce)
- and only then, use lvconvert to create the mirrors