I’ve got a nixos setup in my flake that should boot a raspberry pi, it does boot, but my disks don’t mount every time. The disks are attached via USB, a Geekworm NASPI Gemini. I’m using mdadm raid 1, and Logical Volumes on the disks.
The annoying thing is that it seems to work sometimes. Usually when it’s a sometimes thing, it always means that it’s a race condition somehow.
When it doesn’t work, I get dropped down into a maintenance shell, and I find out that the LVMs aren’t actually activated:
What did I do wrong? I assume I just missed something.
A bit of google searching found:
I do not have boot.initrd.systemd=true
, because it does not default to true. Am I supposed to have systemd in initrd to make this cooperate?
Thanks in advance!
I think I may have figured this out on my own.
The solution seems to have been this, adding the dm-raid
module to make sure it was both in stage 1 and stage 2. That’s my guess anyway, why it worked sometimes, I don’t know.
boot = {
# if I don't specify this, it gets very butthurt
kernelPackages = pkgs.linuxKernel.packages.linux_rpi4;
# I'm doing software raid, and I needs it!
swraid.enable = true;
#initrd.availableKernelModules = ["xhci_pci" "usbhid" "usb_storage" "sr_mod"];
initrd.kernelModules = ["dm-raid" "dm-mod" "dm-snapshot" "sd_mod" "uas"];
#I added the dm-raid and dm-snapshot here, as well as to the initrd.
# I think somehow it wasn't always available at the right time somehow. It has reliably booted
kernelModules = ["dm-raid" "dm-mod" "dm-snapshot" "sd_mod" "uas"];
};
The state of the mdraid stuff in NixOS isn’t great. It really needs someone knowledgeable with how it works to go through and make some sweeping improvements. It really only ought to be necessary to enable boot.swraid.enable
and possible configure something in boot.swraid.mdadmConf
2 Likes
Interesting to see that someone else goes down the rabbit hole of running NixOS on a geekworm NASPI ( I have the 3.5" model).
Did you already try to run their scripts for the power button and the fan? I have it kind of working but would be interested in how to do it better. If you are interested I can upload my config.
I hadn’t yet!
I think the pwm overlay is enough to enable the fan. I was going to write a small custom package to include the script that fires up the fan and controls it.
So far, it does all the right things, except for the mdadm/lvm issues.
I’m also touching dnsdist and pdns, since this host is to do dns things for me.
I might have a PR into nixpkgs to give those a little bit of tweaks if I can figure out how to do it.
I’d love to see your config, maybe you’re doing what I already thought of doing
I opened a new topic so other people can find it as well and it does not really fit the original topic: Powerbutton and CPU fan control for Geekworm NASPI Gemini.
I created a btrfs raid which works fine.
1 Like
Turns out I was wrong.
Having
boot = {
# if I don't specify this, it gets very butthurt
kernelPackages = pkgs.linuxKernel.packages.linux_rpi4;
# I'm doing software raid, and I needs it!
swraid.enable = true;
#initrd.availableKernelModules = ["xhci_pci" "usbhid" "usb_storage" "sr_mod"];
# maybe the problem is that I didn't have it in the right location? It shouldn't have mattered, it needed to be there on part 2
# omg, this is terribly unreliable and I really don't know why.
# it constantly can't find the disks
initrd.kernelModules = ["dm-raid" "dm-mod" "dm-snapshot" "sd_mod" "uas"];
kernelModules = ["dm-raid" "dm-mod" "dm-snapshot" "sd_mod" "uas"];
};
STILL causes problems. I cannot boot into my system on random occasions, and I have no idea why it can’t find the disks.
fileSystems = {
"/" = {
device = "/dev/disk/by-label/NIXOS_SD";
fsType = "ext4";
options = ["noatime"];
};
# This needs to be done this way to make it work in initrd land. It seems
# to be a combination of MDADM and LVM that causes it to freak out.
# https://github.com/NixOS/nixpkgs/issues/196800#issuecomment-1336572761
"/var/lib/containers" = {
device = "/dev/disk/by-id/dm-name-raid-podman";
fsType = "ext4";
};
"/srv/control" = {
device = "/dev/disk/by-id/dm-name-raid-control";
fsType = "ext4";
};
};
Disks are defined as in the workaround mentioned, and yet, nope.
All I have to do is this, but I have to do it every time now
That seems to indicate the LVM udev rules aren’t firing for your md device for some reason.