Rescue gentoo with software raid-1

Chroot to Gentoo env

livecd ~ # modprobe raid1
livecd ~ # mdadm --detail --scan
ARRAY /dev/md/3_0 metadata=0.90 UUID=5af462ee:8e535294:cb201669:f728008a
ARRAY /dev/md/2_0 metadata=0.90 UUID=09338879:65611484:cb201669:f728008a
ARRAY /dev/md/1_0 metadata=0.90 UUID=2fc18a05:fd33a57f:cb201669:f728008a
livecd ~ # mdadm --detail --scan > /etc/mdadm.conf
livecd ~ # ls /dev/md
md/       md125     md126     md127     mdev.seq  
livecd ~ # ls /dev/md
md/       md125     md126     md127     mdev.seq  
livecd ~ # ls /dev/md/
1_0  2_0  3_0  
livecd ~ # mount /dev/md/3_0 /mnt/gentoo/
livecd ~ # ls /mnt/gentoo/
bin  boot  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  sys  tmp  usr  var
livecd ~ # mount /dev/md/1_0 /mnt/gentoo/boot 
livecd ~ # mount -t proc proc /mnt/gentoo/proc
livecd ~ # mount --rbind /dev /mnt/gentoo/dev
livecd ~ # mount --rbind /sys /mnt/gentoo/sys
livecd ~ # cp -L /etc/resolv.conf /mnt/gentoo/etc/ 
livecd / # chroot /mnt/gentoo /bin/bash                      
livecd ~ # source /etc/profile

Do kernel stuff

cd /usr/src/linux
make && make modules_install
make install

Grub2 stuff: add additional parameters to kernel
nano -w /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT=”domdadm rootfstype=ext4″


# emerge genkernel
# genkernel --install initramfs

To configure genkernel add your mdadm.conf file to your initrd with the “MDADM_CONFIG=” option in /etc/genkernel.conf

nano -w etc/genkernel.conf


If you need specific support in the initramfs, such as lvm or raid, add in the appropriate options to genkernel. See genkernel –help for more information, or the next example which enables support for LVM and software raid (mdadm):

# genkernel --lvm --mdadm --install initramfs

grub2 setup

grub2-mkconfig -o /boot/grub/grub.cfg

check result in /boot/grub/grub.cfg and compare raid device id with

blkid | grep /dev/md3


livecd linux-3.15.10-hardened-r1 # exit
livecd ~ # umount -l /mnt/gentoo/dev{/shm,/pts,}
livecd ~ # umount -l /mnt/gentoo{/proc,/boot,/sys,}
livecd ~ # reboot