• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

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

By admin

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)

Filed Under: CentOS/RHEL 7

Some more articles you might also be interested in …

  1. How to Change Default Permission of /var/log/messages in CentOS/RHEL
  2. CentOS / RHEL : How to create and host yum repository over httpd
  3. How to change the default location (/var/cache/yum) of yum cache
  4. How to send Audit Logs to Remote Rsyslog Server in CentOS/RHEL 6,7
  5. How to work with multiple java versions under Linux
  6. CentOS / RHEL 7 : How to configure serial getty with systemd
  7. CentOS/RHEL: “id” command doesn’t list the Group Name against GID for LDAP Users
  8. How to Configure rsyslog to Filter/discard Specific IP Address in CentOS/RHEL 6,7
  9. How to configure the logging of failed login attempts for vsftpd
  10. “yum clean all” not clearing yum repository cache in CentOS/RHEL/OEL

You May Also Like

Primary Sidebar

Recent Posts

  • SQL script to find tables that are fragmented
  • TRUNCATE TABLE not releasing space from tablespace
  • How to reclaim entire space of an oracle database table with “Truncate Table” statement
  • Oracle SQL Script to Report Tablespace Free and Fragmentation
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary