Hotline: Wenn Profis unter sich sind…

Just as a personal reminder for the next time I need that:

If there’s a machine, for example a Xen host, with just one harddisk and you want to be somewhat safe in case of a disk failure, you can add a second disk and setup a RAID1 (mirroring). It’s most simple to shutdown the machine and setup the RAID1 for the dom0. Afterwards you can start the domU VMs again when you’re using LVM for their virtual disks. Following these steps will add RAID1 underneath your LVM setup:

0. /dev/sda5 is your current physical volume for your LVM, on the second (equally partitioned) disk /dev/sdb5 will be your starting point for your RAID1 (/dev/md3)
1. create a degraded RAID1 on /dev/sdb5:

# mdadm –create /dev/md3 –level=1 -f –raid-devices=1 /dev/sdb5
mdadm: array /dev/md3 started.
# cat /proc/mdstat
md3 : active raid1 sdb5[0]
135540288 blocks [1/1] [U]

2. prepare it for LVM and add it to your virtual group:

# pvcreate /dev/md3
# vgextend /dev/vg /dev/md3
Volume group “vg” successfully extended

3. move the extends from one disk to the other and be verbose to watch the progress:

# pvmove -v /dev/sda5
Finding volume group “vg”
Archiving volume group “vg” metadata (seqno 22).
Creating logical volume pvmove0
Moving 192 extents of logical volume vg/ts2-swap
Moving 1536 extents of logical volume vg/ts2-disk
[….]
Found volume group “vg”
Removing temporary pvmove LV
Writing out final volume group after pvmove
Creating volume group backup “/etc/lvm/backup/vg” (seqno 31)

4. remove the old partition from the virtual group:

# vgreduce /dev/vg /dev/sda5
Removed “/dev/sda5” from volume group “vg”

5. add the old partition to your raid and set it active:

# mdadm –add /dev/md3 /dev/sda5
mdadm: added /dev/sda5
# cat /proc/mdstat
md3 : active raid1 sda5[1](S) sdb5[0]
135540288 blocks [1/1] [U]
# mdadm –grow /dev/md3 –raid-devices=2
# cat /proc/mdstat
md3 : active raid1 sda5[2] sdb5[0]
135540288 blocks [2/1] [U_]
[>………………..] recovery = 0.2% (284480/135540288) finish=39.6min speed=56896K/sec

6. let the RAID1 doing its sync and you’re done.

Just as a small side note:
I don’t know why the kernel don’t want to boot when it get passed root=/dev/md2 as a kernel parameter. It works with root=/dev/sda3, though…

Uncategorized