/boot 200m
/swap 1Gig raid0
/ rest of drive
I used the following partitions
| Device | Size | Id | Eventual mount point |
|---|---|---|---|
| /dev/sda1 | 200M | 83 | /boot/ |
| /dev/sda5 | 1G | 82 | swap |
| /dev/sda6 | 100G | 83 | / |
I'm assuming you know how to do the above by running fdisk from the install of your choice.
After installing:#apt-get install wajig
#wajig install mdadm
#wajig install rsync
#wajig install e3
Update kernel to kernel-image-2.6.8-1-k7-smp
| Device | Size | Id | Eventual mount point |
|---|---|---|---|
| /dev/sdb1 | 200M | fd | /boot/ |
| /dev/sdb5 | 1G | fd | swap |
| /dev/sdb6 | 100G | fd | / |
# mdadm --create /dev/md0 --level 1 --raid-devices=2 missing /dev/sdb1
The above line is the long version of the next line just for reference. .#mdadm -Cv /dev/md0 -l1 -n2 missing /dev/sdb1
#mdadm -Cv /dev/md1 -l1 -n2 missing /dev/sdb5
#mdadm -Cv /dev/md2 -l1 -n2 missing /dev/sdb6
This creates 3 degraded RAID1 devices (for /boot, swap, and /) consisting of a dummy drive "missing" (why was this so hard to figure out!)
#cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sdb5[1]
979840 blocks [2/1] [_U]
md0 : active raid1 sdb1[1]
192640 blocks [2/1] [_U]
md2 : active raid1 sdb6[1]
159661888 blocks [2/1] [_U]
unused devices:
Note how one drive in all three cases is missing ("_") as opposed to up and running' ("U").
#mkfs.jfs /dev/md2
#mkdir /mntroot
#mkdir/mntboot
#mount /dev/md2 /mntroot
#mount /dev/md0 /mntboot
MODULES=most
###MODULES=most
MODULES=dep
ROOT=probe
###ROOT=probe
ROOT="/dev/md2 jfs"
This tells init to use what it takes to boot off of a raid device not the /dev/sda device currently used.
Now run#mkinitrd -o /boot/initrd.img-2.6.8-1-k7-smp-md 2.6.8-1-k7-smp
title Debian GNU/Linux, kernel 2.6.8-1-k7-smp
root (hd0,0)
kernel /vmlinuz-2.6.8 root=/dev/sda6 ro
initrd /initrd.img-2.6.8
savedefault
boot
title Debian GNU/Linux, kernel 2.6.8-1-k7-smp -md Disk1
root (hd0,0)
kernel /vmlinuz-2.6.8 root=/dev/ md2 ro
initrd / initrd.img-2.6.8-1-k7-smp-md
savedefault
boot
title Debian GNU/Linux, kernel 2.6.8-1-k7-smp-md Disk2
root (hd 1 ,0)
kernel /vmlinuz-2.6.8 root=/dev/md2 ro
initrd /initrd.img-2.6.8-1-k7-smp-md
savedefault
boot
DEVICE /dev/sda* /dev/sdb*
mdadm --detail --scan >> /etc/mdadm/mdadm.conf
#mkdir /mntroot/proc /mntroot/boot /mntroot/sys
#chmod 555 /mntroot/proc
#rsync -auHx /boot/ /mntboot/
# /etc/fstab: static file system information.
#
#
proc /proc proc defaults 0 0
/dev/ md1 none swap sw 0 0
/dev/ md0 /boot jfs defaults 0 2
/dev/ md2 / jfs defaults,errors=remount-ro 0 1
/dev/hda /media/cdrom iso9660 ro,user,noauto 0 0
/dev/fd0 /media/floppy auto rw,user,noauto 0 0
/dev/hda /cdrom iso9660 ro,user,noauto 0 0
If it won't work you should be able to boot off of the old grub listing
At this point the box should be running off the degraded RAID1 devices on the second drive (/dev/sdb)
If all is OK you should change the partition types of the first drive (/dev/sda)
- but you will lose all data!
| Device | Size | Id | Eventual mount point |
| /dev/sda1 | 200M | fd | /boot/ |
| /dev/sda5 | 1G | fd | swap |
| /dev/sda6 | 100G | fd | / |
# mdadm /dev/md0 -a /dev/sda1
# mdadm /dev/md1 -a /dev/sda5
# mdadm /dev/md2 -a /dev/sda6
#cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sda1[0] sdb1[1]
192640 blocks [2/2] [UU]
md1 : active raid1 sda5[0] sdb5[1]
979840 blocks [2/2] [UU]
md2 : active raid1 sda6[2] sdb6[1]
159661888 blocks [2/1] [_U]
[ =====>..................] recovery = 17.9% (28697920/159661888) finish=56.4min speed=38656K/sec
unused devices:
# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sda1[0] sdb1[1]
192640 blocks [2/2] [UU]
md1 : active raid1 sda5[0] sdb5[1]
979840 blocks [2/2] [UU]
md2 : active raid1 sda6[2] sdb6[1]
159661888 blocks [2/2] [UU]
unused devices:
Yes, this needs to happen again after the raid is complete!
#mkinitrd -o /boot/initrd.img-2.6.8-1-k7-smp-md 2.6.8-1-k7-smp
(Is this still a needed step?)
Regenerate /etc/mdadm/mdadm.conf
edit /etc/mdadm/mdadm.conf
Delete all but the top line
DEVICE /dev/sda* /dev/sdb*
mdadm --detail --scan >> /etc/mdadm/mdadm.conf
DEVICE /dev/sda* /dev/sdb*
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=4d58ade4:dd80faa9:19f447f8:23d355e3
devices=/dev/sda1,/dev/sdb1
devices=/dev/sda5,/dev/sdb5
ARRAY /dev/md2 level=raid1 num-devices=2 UUID=7dfd7fcb:d65245d6:f9da98db:f670d7b6
devices=/dev/sdb6,/dev/sda6
Install the MBR on the second disk
#grub --device-map=/boot/grub/device.map
>> root (hd0,0)
>> setup (hd0)
>> root (hd1,0)
>> setup (hd1)
>> quit
Edit /boot/grub/menue.lst
## default kernel options for automagic boot options
## If you want special options for specifiv kernels use kopt_x_y_z
## where x.y.z is kernel version. Minor versions can be omitted.
## e.g. kopt=root=/dev/hda1 ro
# kopt=root=/dev/sd6 ro
## default kernel options for automagic boot options
## If you want special options for specifiv kernels use kopt_x_y_z
## where x.y.z is kernel version. Minor versions can be omitted.
## e.g. kopt=root=/dev/hda1 ro
# kopt=root=/dev/md2 ro
Just run:
dpkg-reconfigure mdadm
Test boot from both drives
Kill a drive and see if you get a email about the event.
Write up a step by step procedure to restore from a drive outage. (send a copy this way for this page!)
You should be all finished!
Please send notes of any typos/corrections to the email address below.
Special thanks to Onni Koskinen of Finland, whose gentle yet expert emails removed several glaring errors on this page and resulted in a vastly improved document.
How do you see what is in a initrd file?
mount -o loop /tmp/myinitrd /mnt/myinitrd
From http://xtronics.com/reference/SATA-RAID-debian-for-2.6.html
inform@xtronics.com