Although lvconvert command is used for many purposes, it is mostly used for mirroring LVM volumes or convert a mirrored volume to a linear one. To convert a linear volume to a mirrored one use lvconvert with the “-m” option. The “-m” option takes a number as an argument that represents the number of copies of the data that you want to have. The other options are the name of the LV that you want to convert followed by a list of all the physical volumes (PV) that will be used for the mirror and its log disk. The log disk contains information on which section of the mirror needs to be synced, it speeds up operations at boot time and improves reliability. When we want to specify that a PV is the one that should be used as a log disk we specify the extent that we want to use for it by appending “:0” to the device name.

For example if we have a VG called mirrorvg, with a LV called lv0 that is linear and is using a PV called mpath0 and we want to create a two way mirror (a mirror that has two replica disks) we use the following command line:

# lvconvert -m 2 /dev/mirrorvg/lv0 /dev/mpath/mpath0 /dev/mpath/mpath1 /dev/mpath/mpath2 /dev/mpath/mpath3:0

With this command, we specify that we want to have two copies of the data, that the volume that we want to convert is lv0 and belongs to mirrorvg VG. We also specify the PV that contains the original data mpath0 and two PV that will contain two copies of the data mpath1 and mpath2. The last PV, mpath3, is the PV that we want to use as a log disk so we append to it.

Similarly, if you want to remove a leg of the mirror, use the below command. We are decreasing the mirror copied with the “-m” switch.

# lvconvert -m 1 /dev/mirrorvg/lv0 /dev/mpath/mpath0

Similarly, we can go on and remove one more leg of the mirror to make the volume linear as shown below:

# lvconvert -m 0 /dev/mirrorvg/lv0 /dev/mpath/mpath1

examples of lvconvert command

1. To specify the degree of mirror to create:

# lvconvert -m 1
# lvconvert --mirrors 1

3. To specify the type of log to use:

# lvconvert --mirrorlog disk
# lvconvert --mirrorlog core
# lvconvert --mirrorlog mirrored
# lvconvert --corelog

4. To divide the mirror into regions:

# lvconvert -R MirrorLogRegionSize
# lvconvert --regionsize MirrorLogRegionSize

5. To run the daemon in background:

# lvconvert -b
# lvconvert --background

6. To report progress as a percentage at regular intervals:

# lvconvert -i Seconds
# lvconvert --interval Seconds

7. To disable udev synchronization:

8. To split off mirror images to form a new logical volume:

# lvconvert --splitmirrors Images

9. To apply name to a logical volume which has been split off from a mirror logical volume:

10. To Create a snapshot from existing logical volume using another existing logical volume as its origin:

# lvconvert -s
# lvconvert --snapshot

11. To Power of 2 chunk size for the snapshot logical volume between 4k and 512k:

# lvconvert -c ChunkSize
# lvconvert --chunksize ChunkSize

12. To Controls zeroing of the first KB of data in the snapshot:

# lvconvert -Z y|n
# lvconvert --zero y|n

13. To Merges a snapshot into its origin volume:

14. To Repair a mirror after suffering a disk failure: