Open nh2 opened 5 years ago
Thank you for your contributions.
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:
What would be a way to fix this issue ? What should be done to not rely on the cache of blkid or force it to refresh, is there a flag we could use ? Or a kernel module to reload to refresh blkid's cache ?
Maybe using, the -g
flag ?
I can make a PR for that if you think, it would fix this issue.
Issue description
nixos-generate-config
does not correctly determine current UUID of the root device, due to its reliance on cached information in/dev/disk/by-uuid
(as opposed to e.g.blkid
). This leads to machines not booting afternixos-install
in many situations.If you create a new file system on some block device using
mkfs
, it gets a new UUID.If that block device already had a UUID before,
/dev/disk/by-uuid
will continue to show the old UUID until you runudevadm trigger
.nixos-generate-config
relies on/dev/disk/by-uuid
here:https://github.com/NixOS/nixpkgs/blob/07fdacf9f9811c78804ce782a25e448fbb0ad946/nixos/modules/installer/tools/nixos-generate-config.pl#L296-L305
This means
nixos-generate-config
will put a wrong (no-longer-existent) UUID intohardware-configuration.nix
, and the machine will fail to boot.Workaround
Run
udevadm trigger
between yourmkfs
andnixos-generate-config
.Real fix
nixos-generate-config
should runudevadm trigger
or use an uncached source (likeblkid
orlsblk
) to obtain the file system UUID.Technical details
NixOS 19.03.
Found with the help of @cleverca22.
From IRC for further info:
Here is a shell session that shows how
/dev/disk/by-uuid
shows outdated info: