Move Debian on to software RAID setup

Q I have been happily running Debian Etch for a few months now, and would like to move it from hdb to a software RAID 1 setup on hde and hdg, My current setup is:

/boot on hdb1 using ext2.
/ on hdb2 using ReiserFS.
/home on hdb3, also using ReiserFS.

I can move things to put /boot on md0, / on md1 and /home on md2 but how do I set up Grub? I know that Grub reads hard disks and partitions from zero, but what about RAID setups? How do I reconfigure and reinstall Grub for my new RAID setup?

A You'd be surprised at how easy this is to do with RAID 1. The individual disks can be accessed as though they were standalone disks because the RAID data is not written to the rootblock of the disk. If /dev/ md0 is constructed from /dev/hde1 and /dev/hdg1, either of those can be used as the boot disk. They are probably labelled (hd1,0) and (hd2,0) because /dev/hdb will be (hd0), but you can find this out with Grub's find command.

touch /boot myraidbootdisks
#switches to grub prompt here
find /myraidbootdisks

This will show you something like this:

find /myraidbootdisks

You can use either of these to boot from, but I would recommend setting up Grub on each of them and including two menu entries, one for each disk. That way, if one of the boot filesystems is corrupted, you can boot from the other disk. Once the kernel is running and the RAID array created, it should repair itself. You can use any file in the find command, but creating a file instead of searching for a kernel avoids the possibility of confusion from your old boot disk. If you intend to remove hdb after setting up Grub, remember that your disk numbering will change and your Grub menu files will need to be amended. If you have set up Grub on both disks as recommended above, the first menu entry should still work, although it will be referring to the second disk by then. That may seem confusing, but it will make sense when you try it and will allow you boot without hdb in order to change the menu files.

Follow us on or Twitter

Username:   Password:
Create Account | About TuxRadar