fileSystems declaration breaks boot process

Hi! Fairly new to Nix, I’ll get straight to the point.
Rebuilding with the following lines in configuration.nix breaks my unit during boot.

fileSystems = {
  "/home/maedas/HDD/" = { 
      device = "/dev/disk/by-label/external";
      fsType = "ext4";
  };

running sudo mount /dev/disk/by-label/external ~/HDD as user maedas works fine after booting, so I’m unsure what is going on.

Is it trying to mount before the labels have been generated perhaps?

Any feedback is appericiated, thanks!

No, systemd will wait for that label symlink to exist before attempting to mount it.

It’s hard to say what’s going wrong without seeing logs. What does systemctl status /home/maedas/HDD say (after boot, before you try to mount it manually)?

The only thing I can think of is that for some reason it thinks it’s neededForBoot and you’re missing some kernel module in initrd. But, that option should default to false.

2 Likes

A kernel module might be on to something, it is on an Raspberry Pi 4 running the crosscompiled AArch64 installation so it might be more barebones than a regular install. I just dont know enough to check and understand if that is the case.

I doubt the neededForBoot is the culprit, nothing on that disk is vital for boot, it’s just a partition containing data for services when they are up and running.

It does not complete boot with that code block enabled, so I can’t check for what you are asking. (and running it on a previous generation just doesn’t find anything there.)

I might have found something that might be useful to know:
I am not using GRUB as the default bootloader, I use boot.loader.generic-extlinux-compatible
No idea if that’s why it does this.

When it fails to boot, it should drop you into emergency mode. It should prompt you for the root password and drop you into a shell where you can poke around.

Otherwise, on a working generation, you can do journalctl -u /home/maedas/HDD to see logs from previous boots.

I wish I could but since I can only SSH into that machine I cannot boot into an unstable version the revert back to the stable one.

ok, well on a generation that does boot, you can still do journalctl -u /home/maedas/HDD to see logs from previous boots

I figured it out it seems through your instructions and trying to mount the drive on my main computer, I am using exFAT as a file system so my initial config was incorrect.

(running journalctl -u /home/maedas/HDD/ and looking at the result gave me the answer in an error incorrect file type)

Now the only question that remains if exFAT is allowed as a file system for mount, it just said "unknown filesystem type ‘exFAT’ when I tried that as an input.

Edit:
Solved it. It was just being picky not recognizing exFAT but exfat was correct. I do get that it’s case sensitive but that’s such a weird thing with naming schemes related to computers.

Edit 2: Summarised

1 Like

It is a bit interesting that a non-neededForBoot mount point failure resulted in a failed boot, though.

Is that… expected @ElvishJerricco ?

Yeah I agree, it’s kind of weird that it doesn’t just fail it and still attempt to boot. the only result would be that a non-critical drive isn’t correctly mounted.

If we don’t hear from @ElvishJerricco soon, it’d be great if you could go ahead and file an issue for it. I don’t know that I can dig in but please CC me if you do.

1 Like
  fileSystems."/home/maedas/HDD" = {
    device = "/dev/disk/by-label/external";
    fsType = "exfat";
  };
 fileSystems = {
    "/home/maedas/HDD" = {
      device = "/dev/disk/by-label/external/";
      fsType = "exfat";
    };
  };

The upper one rebuilds without issue, the lower one panics and goes straight to rescue mode. As far as I can tell it’s because the device path in #2 ends with a /.

Actually it was never a wrong fsType flag. It was the trailing / on the device option.

Just confirmed it by adding it to a working permutation of the settings. Final solution:

  fileSystems."/home/maedas/HDD" = {
    device = "/dev/disk/by-label/external";
    fsType = "exfat";
  };

Edit: Added working permutation above.

Yes, it’s expected. By default, all file systems in /etc/fstab are made a Requires= dependency of local-fs.target, which has OnFailure=emergency.target. If you don’t want this to cause a failure to boot, you need to use the nofail file system option, which weakens that dependency to Wants=.

2 Likes

Thanks so much for completing the circle for me. Though, I must say, it’s a bit surprising.

So, is the correct syntax to add the nofail?

  fileSystems."/home/maedas/HDD" = {
    device = "/dev/disk/by-label/external";
    fsType = "exfat, nofail";
  };

No. fsType = "exfat";, but add options = ["nofail"];

2 Likes

Thank you, and I think whoever comes in here in 5+ years also thanks you :slight_smile:

1 Like