Boot Arch Linux from an mdadm array
This method will allow you to configure your
/boot directory or partition on a raid 0, 5, or 6. This was not previously possible before grub2. The code in this write-up was tested against a virtual machine with 2 20GB hard disks, with a couple of raid 0 partitions.
First, Boot your arch install image. Once running in your live environment, configure your partitions. It's very important to remember that your first partition must begin further into the disk than the typical default of 2048 sectors, 4096 worked for me. My test box has the following partition table on each disk.
[root@archiso ~]# fdisk -l /dev/sda Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x2a8e3edb Device Boot Start End Blocks Id System /dev/sda1 * 4096 37752831 18874368 fd Linux raid autodetect /dev/sda2 37752832 41943039 2095104 fd Linux raid autodetect
Next create your arrays.
mdadm --create /dev/md0 --raid-devices=2 --level=0 /dev/sda1 /dev/sdb1 mdadm --create /dev/md1 --raid-devices=2 --level=0 /dev/sda2 /dev/sdb2
Once your arrays are set, run through your normal arch setup process, skipping all of the bootloader steps. Remember on the "Prepare Hard Drives" step to choose "Manually configure block devices, filesystems, and mountpoints", and choose the appropriate /dev/mdX devices.
After the install is complete, we have a few more steps to get grub2 installed. Make sure you've got networking.
Prepare your installed root, and chroot into it.
cp /etc/resolv.conf /mnt/etc/resolv.conf mount -o bind /proc/ /mnt/proc/ mount -o bind /sys/ /mnt/sys/ mount -o bind /dev/ /mnt/dev/ chroot /mnt/
Now that we are essentially running within our installed environment, we can install grub2.
pacman -Sy grub2
Ignore the pacman upgrade request, and allow pacman to remove the "grub" package, as we don't need it. Next, prepare your mdadm.conf file.
mdadm --examine --scan > /etc/mdadm.conf
Add "mdadm" to the "HOOKS" array in your
/etc/mkinitcpio.conf. As of this writing, a bug prevents your
/boot/grub/grub.cfg from generating correctly unless you uncomment the line "GRUB_TERMINAL_OUTPUT=console" in your
/etc/default/grub. Generate your
/boot/grub/grub.cfg and install grub2 to every device in your array.
grub-mkconfig -o /boot/grub/grub.cfg grub-install /dev/sda grub-install /dev/sdb
Re-generate your init image.
mkinitcpio -p linux
You should see a message go by saying
Custom /etc/mdadm.conf file will be used in initramfs for assembling arrays.
If you don't see this message, make sure you didn't miss any steps above. You should be able to boot from any disk in your array into your new arch install.
If you hit busybox, boot back into your live environment, chroot back into your installed environment, modify your /etc/default/grub to uncomment "GRUB_DISABLE_LINUX_UUID=true", and re-run the grub-mkconfig command from above. I've seen a udev/UUID bug that sometimes prevents your initramfs mdadm from correctly assembling your arrays.
Most of the information in the article was pieced together from https://wiki.archlinux.org/index.php/Software_RAID_and_LVM and https://wiki.archlinux.org/index.php/GRUB2 and maybe a couple of other places.