Monday, March 24, 2014

Mirrored FAT32 EFI Boot Partitions

Most modern hardware ships with UEFI firmware and can be booted in EFI mode automatically when a disk is found with EFI setup. When I recently put Arch Linux on my desktop machine, I went with gummiboot to try something new and I really like the results.

Now that I'm bringing my Xeon machine back online for some benchmarking, I want to use gummiboot there too. The twist is that while my desktop has a single SSD for root+data, this machine has a few more drives installed.


The root drives actually aren't visible in the photo. They're 2.5" SATA drives behind the side panel on the left side, directly behind the red and black SAS tray.

Since I'm installing a mirrored root on btrfs and using EFI, I want to have /boot mirrored to both drives so the system will still boot if one of them fails. The easy way would be to format both and rsync with a cron job. While that would catch 99% of updates, I figure since I'm using this machine for crazy disk stuff I might as well try mirroring the EFI filesystem.

Because of the way EFI works, FAT32 is pretty much the only decent choice for a filesystem on the EFI partition (code ef02). Since /boot only needs to hold initramfs, kernels, and the EFI configuration, I'll simply mount it on /boot as vfat.

This is how it's set up on my desktop. But now I want mirroring. I tried mdraid, but even with metadata 1.0 the fat filesystem can't be direct mounted. No big deal. The Linux LVM is actually a frontend to a kernel disk abstraction called device mapper. It includes a mirror target, so all I had to do was spin up a quick mirrored LV then dump the device mapper table.

Here's the breakdown of what the device mapper table says in English:

0 8192 mirror core 1 1024 2 253:0 0 253:1 0 1 handle_errors

Present blocks 0 to 8192 as a mirror with in-core replication log of the size 1024 with 2 devices, 253:0 and 253:1 both starting at offset 0 with one argument of 'handle_errors'.  The syntax is terse and the documentation is incomplete, so that's as far as I can tell. Device mapper can do a lot more than this, but this is all I need for now.

With the knowledge of what an LVM-created device mapper table looks like, writing a script that sets up the mirror is pretty easy. I'll throw this into a systemd unit file when I'm done with the setup.

With that script written the rest is mostly by the book (wiki), but I'll go ahead and test that the partitions are usable alone.

And with that, my workstation has redundant boot drives and can be set up to boot with gummitboot per the wiki instructions.

Edit: I may have spoke too soon. Will update again when I figure out why gummiboot won't run.

No comments: