In my NixOS configuration I ended up accidentally overwriting my hardware-configuration.nix. While sudo nixos-generate-config regenerates one, for me the regenerated version appears to be missing the required /boot section.

How can I figure out what this section was / should have been like?

I checked e.g. /nix/var/nix/profiles/, but couldn't find it in there. lsblk shows me some partitions including a sr0 that seems like what should be my /boot:

$ lsblk
sda      8:0    0 931.5G  0 disk 
├─sda1   8:1    0 923.5G  0 part /tmp/c7ca628b-0645-4af0-95d5-741d47d5923f
└─sda2   8:2    0     8G  0 part [SWAP]
sdb      8:16   0 119.2G  0 disk 
└─sdb1   8:17   0 119.2G  0 part 
sr0     11:0    1  1024M  0 rom

... however, trying to plug this in did not seem to work.


IIRC nixos-generate-config generates mounts simply based on what is currently mounted. So... one option is to mount stuff by hand the way you want it and then run the generator. I guess if you have previous system generations that work the way you want, you can boot into one of them via the grub menu and run nixos-generate-config from them.

  • Thanks for your response. I tried this, but the /boot isn't in the generated file, giving me a bit of a chicken-and-egg problem: getting it into a generated config implies having it mounted, while mounting it implies knowing what to mount (and how). e.g. trying sudo mount /dev/sr0 /tmp/sr0 gives me mount: /tmp/sr0: no medium found on /dev/sr0. – Tycho Mar 9 at 9:26
  • I assumed that you do have an older system generation in grub that does know how to mount it. – Vladimír Čunát Mar 10 at 10:02
  • I imagine it 'knew' in the sense it managed to boot... but I ended up just formatting instead now. Thanks for your help! – Tycho Mar 11 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.