Rocky_Linux_8
Sponsored Link

LVM : Configure Mirroring Volume2021/07/20

 
Configure Mirroring Volumes. It is like RAID 1.
[1] For example, create a Mirroring Volume with Phisical Volume [/dev/sdb1] and [/dev/sdc1].
# create vlume group [vg_mirror] with [/dev/sdb1] and [/dev/sdc1]

[root@dlp ~]#
vgcreate vg_mirror /dev/sdb1 /dev/sdc1

  Volume group "vg_mirror" successfully created

# create a mirroring volume

[root@dlp ~]#
lvcreate -L 50G -m1 -n lv_mirror vg_mirror

[  211.634519] raid6: sse2x1   gen() 13407 MB/s
[  211.651498] raid6: sse2x1   xor()  7802 MB/s
[  211.668499] raid6: sse2x2   gen() 14909 MB/s
[  211.685497] raid6: sse2x2   xor()  9596 MB/s
[  211.702474] raid6: sse2x4   gen() 15373 MB/s
[  211.719495] raid6: sse2x4   xor()  6706 MB/s
[  211.736494] raid6: avx2x1   gen() 25409 MB/s
[  211.753492] raid6: avx2x1   xor() 14189 MB/s
[  211.770470] raid6: avx2x2   gen() 28151 MB/s
[  211.787491] raid6: avx2x2   xor() 16780 MB/s
[  211.804490] raid6: avx2x4   gen() 28382 MB/s
[  211.821489] raid6: avx2x4   xor()  9060 MB/s
[  211.822143] raid6: using algorithm avx2x4 gen() 28382 MB/s
[  211.822944] raid6: .... xor() 9060 MB/s, rmw enabled
[  211.823668] raid6: using avx2x2 recovery algorithm
[  211.825543] async_tx: api initialized (async)
[  211.827868] xor: automatically using best checksumming function   avx
[  211.848178] device-mapper: raid: Loading target version 1.15.1
[  211.966127] device-mapper: raid: Superblocks created for new raid set
[  211.997568] md/raid1:mdX: not clean -- starting background reconstruction
[  211.998611] md/raid1:mdX: active with 2 out of 2 mirrors
[  212.239445] mdX: bitmap file is out of date, doing full recovery
[  212.295174] md: resync of RAID array mdX
  Logical volume "lv_mirror" created.

[root@dlp ~]#
lvdisplay /dev/vg_mirror/lv_mirror

  --- Logical volume ---
  LV Path                /dev/vg_mirror/lv_mirror
  LV Name                lv_mirror
  VG Name                vg_mirror
  LV UUID                H8a1z5-r759-QLqb-kIyf-CU4H-RGUd-6kgnRb
  LV Write Access        read/write
  LV Creation host, time dlp.srv.world, 2021-07-20 20:08:18 +0900
  LV Status              available
  # open                 0
  LV Size                50.00 GiB
  Current LE             12800
  Mirrored volumes       2
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:6
[2] If you'd like to set mirroring volume from a normal logical volume which is already running, Configure like follows.
# extend the volume group

[root@dlp ~]#
vgextend vg_dlp /dev/sdc1

  Volume group "vg_dlp" successfully extended

# set mirroring volume

[root@dlp ~]#
lvconvert -m1 /dev/vg_dlp/lv_data /dev/sdc1

Are you sure you want to convert linear LV vg_dlp/lv_data to raid1 with 2 images enhancing resilience? [y/n]: y
[ 2448.363275] device-mapper: raid: Device 1 specified for rebuild; clearing superblock
[ 2448.364539] device-mapper: raid: Superblocks created for new raid set
[ 2448.374732] md/raid1:mdX: active with 1 out of 2 mirrors
[ 2448.518744] mdX: bitmap file is out of date, doing full recovery
[ 2448.579886] md: recovery of RAID array mdX
  Logical volume vg_dlp/lv_data successfully converted.

# verify status

# complete to sync if [Cpy%Sync] turns to [100]

[root@dlp ~]#
lvs

  LV      VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root    rl     -wi-ao---- <26.00g
  swap    rl     -wi-ao----   3.00g
  lv_data vg_dlp rwi-a-r---  30.00g                                    15.70

[root@dlp ~]#
lvs

  LV      VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root    rl     -wi-ao---- <26.00g
  swap    rl     -wi-ao----   3.00g
  lv_data vg_dlp rwi-a-r---  30.00g                                    100.00
[3] Unset Mirroring Volume like follows if you want.
# specify -m0 to unset

[root@dlp ~]#
lvconvert -m0 /dev/vg_mirror/lv_mirror

Are you sure you want to convert raid1 LV vg_mirror/lv_mirror to type linear losing all resilience? [y/n]: y
  Logical volume vg_mirror/lv_mirror successfully converted.

[root@dlp ~]#
lvs -a -o vg_name,name,devices,size

  VG        LV        Devices        LSize
  rl        root      /dev/sda2(768) <26.00g
  rl        swap      /dev/sda2(0)     3.00g
  vg_mirror lv_mirror /dev/sdb1(1)    50.00g
Matched Content