this post was submitted on 21 Mar 2025
7 points (88.9% liked)

Nix / NixOS

2109 readers
1 users here now

Main links

Videos

founded 2 years ago
MODERATORS
 

In very short, I have a NixOS install with an /etc/fstab using UUIDs. However, my bulk drive died. I have backups, the data is not the problem.

But I can't boot NixOS without the drive. It throws me into an emergency shell, in which I can't edit /etc/fstab (read-only FS) and since I'm in emergeny mode, nixos rebuild doesn't work either (seems to be mostly a network issue).

So, what's the best, non-reinstalling way to fix that?

you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 4 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

You can boot a live-usb, mount the remaining drive(s) and nixos-enter over like you would if you were installing NixOS for the first time.

This allows you to make changes and build a new generation using the network connection of the live-usb.

[โ€“] [email protected] 1 points 2 weeks ago* (last edited 2 weeks ago)

I didn't know NixOS has its own chroot.

I'm "chrooted" into the system, howver, user-mapping seems not to work currently. Logrotate fails to build because of a missing user ID.

EDIT: I commented out all the "advanced" features and had to add some flags.

services.logrotate.checkConfig = false; in the config solved the "user or group not found" issue and add NIXOS_SWITCH_USE_DIRTY_ENV=1to nixos-rebuild (https://nixos.wiki/wiki/Change_root).

Now it seems to work and I could piece by piece reactive all the deactivated parts.