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.

Friday, March 21, 2014

Running at Night

I've been running regularly for more than 6 months and see no reason why that will ever stop. With a 10k behind me, I'm training to do a half marathon. The twist in my regimen is that I usually run at night with my samoyed.


Running at night is a different experience from running under the day star. There are less people, less traffic, it's cooler, and more dangerous.

Tip 1: stay on the right-hand side of the road.

If you're going against traffic, the headlights will constantly ruin your night vision. Most cars are set up to shine the headlights a little to the right, which means you're getting far more lights shined in your eyes if you're on the left side of the road.

Tip 2: thin-soled shoes are dangerous.

Since I started running, I've become a huge fan of Vibram Five-fingers shoes. My first model was the Treksport. I step on a few liquidambar seed pods every time I go out. With the Treksports I feel them but it does not hurt much. The one time I wore my pair of KSO's, I hit a rock at full force and have not worn them since. When the strap on my Treksports broke, I bought a pair of Speed and have found the protection satisfactory, but not quite as good as the Treksport.

Tip 3: try using a metronome instead of music.

I tried listening to upbeat music when I started out, but it kept distracting me. For me, running is more mental than physical, so this is rather important. I installed a metronome app on my phone and started at around 80BPM, taking two steps to a beat to reach 160 steps per minute. It's hard at first, but once you get into you it becomes easy to line up your steps & breathing and really pack the miles on. It's also handy on race day to keep yourself from overdoing it early in the race.

Another advantage over music is that the tick of the metronome doesn't drown out the sounds around you. The additional sensory information can be crucial at night.

Tip 4: have a regular route and stick to it.

This is an unusual one for me. Any time I run during the day, I take off in a random direction and try to find new routes every time. At night, I pretty much always take the same 5 mile route. I know where all of the sidewalk bulges are. I know where people smoke in their driveways. It really helps lighten the mental load and keep me safe.