LVM2 raid1 without mdadm - Break the mirror and re-synchronize it back the other way around.
Hi gang,
I currently have /boot and / (root) on raid 1 with mdadm. Which is useful for me specially when I patch the server because I break the mirror prior the patching and if something goes wrong is pretty straight forward to synchronize the mirror the other way around and fall back all the changes.
I recently discovered that LVM allows us to create a raid 1 without mdadm, as I show below. You should use 3 hard disks to do a mirror, a third one for the lvm log file, makes sense.
At this point I have two main concerns:
1. Which would be the procedure to fall back the changes? How can I mirror the disks the other way around and roll back any change?
2. Is it possible to encapsulate /boot file system into LVM and if it is possible, how do you configure GRUB2?
Please let me know your thoughts.
Thanks
Andrés-
························································
/* LVM mirror procedure */
I have 3 disks /dev/sd[abd]. Sda is partitioned, sdb is same size than sda and sdd is a small third disk.
Debian:~# sfdisk -l /dev/sda
Disk /dev/sda: 522 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/sda1 * 0+ 30 31- 248976 83 Linux
/dev/sda2 31 521 491 3943957+ 8e Linux LVM
[snip]
1. I create the pvs
# pvcreate /dev/sd[bd]
Check:
# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 Debian lvm2 a- 3.76G 0
/dev/sdb Debian lvm2 a- 4.00G 4.00G
/dev/sdc1 SwapVG lvm2 a- 192.00M 0
/dev/sdd Debian lvm2 a- 196.00M 196.00M
2. Add the new PVs into the root volume group
# vgextend Debian /dev/sd[bd]
Check:
# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 Debian lvm2 a- 3.76G 0
/dev/sdb Debian lvm2 a- 4.00G 4.00G
/dev/sdc1 SwapVG lvm2 a- 192.00M 0
/dev/sdd Debian lvm2 a- 196.00M 196.00M
3. Mirror the data (in this case I'll use sdb to mirror sda and sdd as a third disk)
# lvconvert -m1 /dev/Debian/root /dev/sdb /dev/sdd
/dev/cdrom: open failed: Read-only file system
/dev/Debian/root: Converted: 5.3%
/dev/Debian/root: Converted: 12.4%
/dev/Debian/root: Converted: 20.4%
/dev/Debian/root: Converted: 25.7%
/dev/Debian/root: Converted: 29.5%
/dev/Debian/root: Converted: 32.9%
/dev/Debian/root: Converted: 36.6%
/dev/Debian/root: Converted: 40.3%
/dev/Debian/root: Converted: 43.9%
/dev/Debian/root: Converted: 47.5%
/dev/Debian/root: Converted: 51.2%
/dev/Debian/root: Converted: 54.8%
/dev/Debian/root: Converted: 58.3%
/dev/Debian/root: Converted: 61.9%
/dev/Debian/root: Converted: 65.5%
/dev/Debian/root: Converted: 69.2%
/dev/Debian/root: Converted: 72.8%
/dev/Debian/root: Converted: 76.5%
/dev/Debian/root: Converted: 80.0%
/dev/Debian/root: Converted: 83.6%
/dev/Debian/root: Converted: 87.4%
/dev/Debian/root: Converted: 91.0%
/dev/Debian/root: Converted: 94.6%
/dev/Debian/root: Converted: 98.2%
/dev/Debian/root: Converted: 100.0%
Logical volume root converted.
Check:
Debian:~# lvs -a -o +devices
LV VG Attr LSize Origin Snap% Move Log Copy% Convert Devices
root Debian mwi-ao 3.54G root_mlog 100.00 root_mimage_0(0),root_mimage_1(0)
[root_mimage_0] Debian iwi-ao 3.54G /dev/sda2(0)
[root_mimage_1] Debian iwi-ao 3.54G /dev/sdb(0)
[root_mlog] Debian lwi-ao 4.00M /dev/sdd(0)
swap_1 Debian -wi-ao 228.00M /dev/sda2(905)
SwapVol SwapVG -wi-ao 192.00M /dev/sdc1(0)
You can break the mirror with
# lvconvert -m0 Debian
Reply to: