Use Case
The use case is that we’ll have a small server with two disks, which use RAID 1 (mirroring) for fault tolerance. We would like the system to boot if one of the disks fails. The assumption is, in the event of a failure, the hard disk will be replaced, then the entire computer may be replaced as well with a new system with two fresh drives. The reasoning is that rebuilding a broken RAID 1 isn’t necessarily safe, given that it’s likely that the disk is failing due to age and use.
Theory
Booting into a raid volume is possible because the GRUB2 bootloader knows how to start RAID 1 before the OS is loaded. This is possible because GRUB2 is a large bootloader – but that also requires that we reserve more space at the start of the disk, to allow GRUB to start.
For this reason, we’ll create partitions at the END of the disk, rather than the start. We’ll leave plenty of room at the start, before the partitions, to allow for a big GRUB bootloader.
Practicalities
Before you start installing the server, I suggest loading up a computer to run a Squid proxy. (Use Squid, because Lusca seems flaky on Ubuntul 12.04 at this time.) Configure it to cache requests on port 80. The reason to use a caching proxy is speed: odds are, you’re going to do more than one installation, just to get it right. Why suffer long waits on the 2nd and subsequent installations?
You might want to practice on a VirtualBox VM. In the simulated environment, you can use small disks, which will format and otherwise react faster than a real server’s larger disks. I used 8GB, but think a 3GB would be enough. Create two virtual disks of fixed size.
When you start the install, press Esc, F6, and then space bar to select the “Advanced Mode”. You’ll need that to enable the partitioning options.
Go through most of the install as usual.
If you’re using a proxy, it’s probably at http://ip-address-of-your-box:3128/
When you get to the partitioning options, select Manually Configure.
If you see existing partitions or RAID, carefully delete each partition until you have totally blank disks. There’s no need to write the partition – just get the partitions cleared out.
Let’s then create this layout:
– at least 8MB of empty space (for GRUB2)
– at least enough swap to equal our physical RAM
– a huge partition that will be RAID 1
Work out the partition sizes on paper, before you perform the partition.
Then, you basically add the partitions in this order:
– the huge RAID 1 partition. Primary, at the end of the disk, and set the type to “raid”.
– the swap space. Primary, at end of disk, set type to swap.
– double check to see that there’s free space at the beginning, for GRUB2.
Do the same thing for the second disk.
Then, from the first partitioning screen, select to configure RAID.
Pick a name for the RAID device, like md0. Choose raid level 1, 2 disks, no spares. Then, select the two RAID partitions you defined. The installer will ask if you want to boot from a degraded array. Answer YES.
On the partitioning screen, you should see the new raid device /dev/md0. Add a partition to that, and set it to mount at the root /.
Alternatively, for better flexibility, ou can create an LVM group out of the new /dev/md0, and then create logical volumes within the LVM volume group. Define one as the root file system. (Article to be written.)
Write the partition table.
Then write the boot sector to the disks. When you select this, it’ll ask you if you want to do it – say yes, and it’ll write the boot sector to BOTH the disks. It probably does this because you chose to boot from the degraded array.
(Note: I think this last paragraph may be wrong. You may need to specify the boot devices by selection the option that allows you to enter them manually. Enter “/dev/sda /dev/sdb” as the parameters so the boot sectors are written to both disks.)
Continue with the server installation as usual.