May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

CentOS / RHEL 7 : How to Create and Remove the LVM Mirrors Using lvconvert

When you convert a linear volume to a mirrored volume, you are basically creating an extra mirror copy for an existing volume. This means that your volume group must contain the devices and space for the mirrors and for the mirror log. If losing a copy of a mirror, LVM converts the volume to a linear volume so that you still have access to the volume. And Option ‘[ -m | –mirrors ]’ specifies the degree of the mirror you wish to create.

For example:

“-m 1” would convert the original logical volume to a mirror volume with 2-sides; that is, a linear volume plus one copy.
And ” -m 0 ” will converts the mirrored logical volume to a linear logical volume, removing or breaking the mirror leg including the mirrored devices.
Creating LVM mirrors

The following command converts the linear logical volume ‘datavg/testlv’ to a mirrored logical volume :

# lvconvert -m1 datavg/testlv
The below commands shows the configuration of the volume after the lvconvert command changed the volume to a volume with two mirror copies.

# lvs -a -o name,copy_percent,devices datavg
LV Cpy%Sync Devices
testlv 100.00 testlv_rimage_0(0),testlv_rimage_1(0)
[testlv_rimage_0] /dev/sdb(0)
[testlv_rimage_1] /dev/sdc(1)
[testlv_rmeta_0] /dev/sdb(256)
[testlv_rmeta_1] /dev/sdc(0)
# lvs –all –segments -o +devices
LV VG Attr #Str Type SSize Devices
root centos -wi-ao—- 1 linear 17.47g /dev/sda2(512)
swap centos -wi-ao—- 1 linear 2.00g /dev/sda2(0)
testlv datavg rwi-aor— 2 raid1 1.00g testlv_rimage_0(0),testlv_rimage_1(0)
[testlv_rimage_0] datavg iwi-aor— 1 linear 1.00g /dev/sdb(0)
[testlv_rimage_1] datavg iwi-aor— 1 linear 1.00g /dev/sdc(1)
[testlv_rmeta_0] datavg ewi-aor— 1 linear 4.00m /dev/sdb(256)
[testlv_rmeta_1] datavg ewi-aor— 1 linear 4.00m /dev/sdc(0)
Removing LVM mirrors

The following command converts the mirrored logical volume datavg/testlv to a linear logical volume, removing or breaking the mirror copy including the mirrored devices. Note that, we have to specify the device to detach the mirror copy.

# lvconvert -m0 datavg/testlv /dev/sdc
Check the status of volume and devices again to see the difference :

# lvs -a -o +devices
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert Devices
root centos -wi-ao—- 17.47g /dev/sda2(512)
swap centos -wi-ao—- 2.00g /dev/sda2(0)
testlv datavg -wi-ao—- 1.00g /dev/sdb(0)
# lvs -a -o name,devices datavg
LV Devices
testlv /dev/sdb(0)

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>