Debian 12 bookworm
Sponsored Link

Create Mirroring Volume2023/07/18

 
Create Mirroring Volume.
[1] For example, create a Mirroring Volume with Physical Volume [/dev/sdb1] and [/dev/sdc1].
# create volume 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 mirroring volume

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

  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                7rm2om-Q3X8-41I9-EuB1-ilZg-j11m-71OxyL
  LV Write Access        read/write
  LV Creation host, time dlp.srv.world, 2023-07-17 20:18:03 -0500
  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     256
  Block device           253:6
[2] Configure like follows if you'd like to set mirroring volume from a logical volume which is already running.
# extend volume group

root@dlp:~#
vgextend vg_dlp /dev/sdc1

  Volume group "vg_dlp" successfully extended

# set mirror 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
  Logical volume vg_dlp/lv_data successfully converted.

# confirm : 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    debian-vg -wi-ao----  78.56g
  swap_1  debian-vg -wi-ao---- 980.00m
  lv_data vg_dlp    rwi-a-r---  80.00g                                    12.49
[3] Unset Mirroring Volume.
# 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
  debian-vg root      /dev/sda5(0)      78.56g
  debian-vg swap_1    /dev/sda5(20112) 980.00m
  vg_mirror lv_mirror /dev/sdb1(1)      50.00g
Matched Content