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 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.
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 addNIXOS_SWITCH_USE_DIRTY_ENV=1
to nixos-rebuild (https://nixos.wiki/wiki/Change_root).Now it seems to work and I could piece by piece reactive all the deactivated parts.