{"id":6706,"date":"2017-05-08T14:29:31","date_gmt":"2017-05-08T06:29:31","guid":{"rendered":"http:\/\/rmohan.com\/?p=6706"},"modified":"2017-05-08T14:29:31","modified_gmt":"2017-05-08T06:29:31","slug":"centos-rhel-7-how-to-create-and-remove-the-lvm-mirrors-using-lvconvert","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6706","title":{"rendered":"CentOS \/ RHEL 7 : How to Create and Remove the LVM Mirrors Using lvconvert"},"content":{"rendered":"<p>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 \u2018[ -m | \u2013mirrors ]\u2019 specifies the degree of the mirror you wish to create.<\/p>\n<p>For example:<\/p>\n<p>\u201c-m 1\u201d would convert the original logical volume to a mirror volume with 2-sides; that is, a linear volume plus one copy.<br \/>\nAnd \u201d -m 0 \u201d will converts the mirrored logical volume to a linear logical volume, removing or breaking the mirror leg including the mirrored devices.<br \/>\nCreating LVM mirrors<\/p>\n<p>The following command converts the linear logical volume \u2018datavg\/testlv\u2019 to a mirrored logical volume :<\/p>\n<p># lvconvert -m1 datavg\/testlv<br \/>\nThe below commands shows the configuration of the volume after the lvconvert command changed the volume to a volume with two mirror copies.<\/p>\n<p># lvs -a -o name,copy_percent,devices datavg<br \/>\n  LV                Cpy%Sync Devices<br \/>\n  testlv            100.00   testlv_rimage_0(0),testlv_rimage_1(0)<br \/>\n  [testlv_rimage_0]          \/dev\/sdb(0)<br \/>\n  [testlv_rimage_1]          \/dev\/sdc(1)<br \/>\n  [testlv_rmeta_0]           \/dev\/sdb(256)<br \/>\n  [testlv_rmeta_1]           \/dev\/sdc(0)<br \/>\n# lvs &#8211;all &#8211;segments -o +devices<br \/>\n  LV                VG     Attr       #Str Type   SSize  Devices<br \/>\n  root              centos -wi-ao&#8212;-    1 linear 17.47g \/dev\/sda2(512)<br \/>\n  swap              centos -wi-ao&#8212;-    1 linear  2.00g \/dev\/sda2(0)<br \/>\n  testlv            datavg rwi-aor&#8212;    2 raid1   1.00g testlv_rimage_0(0),testlv_rimage_1(0)<br \/>\n  [testlv_rimage_0] datavg iwi-aor&#8212;    1 linear  1.00g \/dev\/sdb(0)<br \/>\n  [testlv_rimage_1] datavg iwi-aor&#8212;    1 linear  1.00g \/dev\/sdc(1)<br \/>\n  [testlv_rmeta_0]  datavg ewi-aor&#8212;    1 linear  4.00m \/dev\/sdb(256)<br \/>\n  [testlv_rmeta_1]  datavg ewi-aor&#8212;    1 linear  4.00m \/dev\/sdc(0)<br \/>\nRemoving LVM mirrors<\/p>\n<p>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.<\/p>\n<p># lvconvert -m0 datavg\/testlv \/dev\/sdc<br \/>\nCheck the status of volume and devices again to see the difference :<\/p>\n<p># lvs -a -o +devices<br \/>\n  LV     VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices<br \/>\n  root   centos -wi-ao&#8212;- 17.47g                                                     \/dev\/sda2(512)<br \/>\n  swap   centos -wi-ao&#8212;-  2.00g                                                     \/dev\/sda2(0)<br \/>\n  testlv datavg -wi-ao&#8212;-  1.00g                                                     \/dev\/sdb(0)<br \/>\n# lvs -a -o name,devices datavg<br \/>\n  LV     Devices<br \/>\n  testlv \/dev\/sdb(0)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6706"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6706"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6706\/revisions"}],"predecessor-version":[{"id":6707,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6706\/revisions\/6707"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}