Hardware RAID with NixOS

Has anyone had any luck using NixOS with a hardware RAID controller for the boot drive? I’m thinking about mirroring my boot drive (well, my only drive, really) and using something like a HighPoint SSD7105. That RAID controller supports RHEL, Debian, Ubuntu, Fedora, Proxmox, and Rocky Linux, so I’m hoping there might be a way to get it (or something similar) working with NixOS.

Why though? IMO the software RAID options out there these days are better anyway.

Yeah, I’m considering that option as well. I read about some people having issues with mdadm and boot drives, but maybe those were isolated instances.

You won’t want to use software RAID for the EFI partition, but grub has nixos options for replicating the boot loader to multiple drives. We don’t have anything like that for systemd-boot unfortunately.

I’m trying to protect against the situation where a single drive failure can render my machine unusable/unbootable.

I’m fine using GRUB. Assume I have drive A and drive B. Both are 1TB. Based on your info, I could create a 1GB partition on each for EFI use and an additional partition on both that is my boot/main drive. I’d install NixOS onto the second partition on drive A and use the 1GB partition as the EFI partition. I’d ignore drive B during initial install. Once everything is loaded up, I can use mdadm to create a software RAID 1 drive using the second partition on drive B. I’d then use a GRUB option to replicate the bootloader into the 1GB partition on drive B. This way, if drive A completely failed, I could still boot from drive B.

Does that approach make sense?

I wouldn’t set it up as a single drive and then add the second drive after first boot. I would set it up all in one go. Create identical partition layouts on both drives, make an mdadm array out of the main partitions and mount that as the root fs. Go ahead and configure grub’s mirroredBoot option before running nixos-install; it’ll work just fine.

I would also personally prefer a copy-on-write file system like btrfs or ZFS that has mirroring and checksumming built in, rather than mdadm. Being CoW avoids write hole issues, and handling checksumming and mirroring at the file system level allows the file system to determine which mirror is correct in case one of them bitrots a few bytes. Note that while btrfs’s raid1 is good, its raid5/6 is not.

And since you’re going to go with grub for the mirrored boots, I do have to caution: Do not let grub do anything smart. Don’t let grub do encryption, or raid, or any of that. Give it a dead simple file system on /boot (preferably just the EFI partition itself) to read the kernel and initrd from, and let linux / initrd handle the smart file system stuff. Grub is bad at it.

1 Like

Thanks! That sounds like the right approach. I was reading up on the btrfs docs as you were posting this and I agree that it seems like the better route than mdadm, in this case. Thanks also for the pointer to mirroredBoot. I was having trouble finding the right docs on that.