Gentoo on Software RAID1

I am in the process of set­ting up one of my new servers. Yes my old dual pIII machines are going to retire. They are going to live in a “retire­ment com­mu­nity” :P . Any way This time around I am going to use a mir­ror to pro­tect my data. I never expe­ri­enced a hard­ware fail­ure before but I fig­ure bet­ter safe than sorry right? So I am going to out­line the steps needed to boot from a RAID0.

 

modprobe raid1 
mknod /dev/md1 b 9 1 
mknod /dev/md2 b 9 2 
mknod /dev/md3 b 9 3

Now setup your /boot swap and / par­ti­tions on your first disk (I will assume sda). After you have cre­ated your par­ti­tions we need to make the sec­ond drive par­ti­tion table match. (I assume your dri­ves are the same size)

 

sfdisk -d /dev/sda | sfdisk /dev/sdb

Now we need to cre­ate the raids using mdadm

 

mdadm --create --verbose /dev/md1 --level=1 \ 
--raid-devices=2 /dev/sda1 /dev/sdb1 
mdadm --create --verbose /dev/md2 --level=1 \ 
--raid-devices=2 /dev/sda2 /dev/sdb2 
mdadm --create --verbose /dev/md3 --level=1 \ 
--raid-devices=2 /dev/sda3 /dev/sdb3

Or if you are lazy like me

 

for i in `seq 1 3`; do mknod /dev/md$i b 9 $i;\ 
mdadm --create /dev/md$i --level=1 --raid-devices=2\ 
/dev/sda$i /dev/sdb$i; done

Backup your raid config

 

mdadm --detail --scan >> /etc/mdadm.conf

You can mon­i­tor the sta­tus of your raids via /proc/mdstat

 

watch -n .1 "cat /proc/mdstat"

Once the raid is done sync­ing you need to cre­ate your file sys­tems on your md devices and pro­ceed with the nor­mal install rou­tine. You need to do a bit of extra work when installing grub to make sure its installed on both devices, as well as allows you extra options in case of raid failure.

 

grub>device (hd0) /dev/sda 
grub>root (hd0,0) 
grub>setup (hd0) 
grub>device (hd0) /dev/sdb 
grub>root (hd0,0) 
grub>setup (hd0)
grub.conf
default 0 
timeout 30 
splashimage=(hd0,0)/boot/grub/splash.xpm.gz  

title=Gentoo (2.6.17-gentoo-r7) 
        root (hd0,0) 
        kernel /boot/vmlinuz-2.6.17-gentoo-r7 root=/dev/md3  

title=Gentoo (2.6.17-gentoo-r7) [mirror recovery] 
        root (hd1,0) 
        kernel /boot/vmlinuz-2.6.17-gentoo-r7 root=/dev/md3
 
 
 [back­dated from old web­site]

No Comments

Leave a Reply

Your email is never shared.Required fields are marked *

To submit your comment, click the image below where it asks you to...
Clickcha - The One-Click Captcha