Open 8573 opened 7 years ago
I think the current situation is a result of a mistake during one of the refactorings…
What makes you think the boot system is now garbage collected? It's still a GC root as far as I can tell:
$ nix-store --gc --print-roots
...
/run/booted-system -> /nix/store/6q49p3scv0nl859p8yswil2sywgfamnc-nixos-system-hagbard-16.09.1803.40de598
/run/current-system -> /nix/store/6q49p3scv0nl859p8yswil2sywgfamnc-nixos-system-hagbard-16.09.1803.40de598
It is a GC root, but at some point there was an entry «Previous boot» or something like that in GRUB — no longer. Apparently the generation used for the previous boot is also not guaranteed to be available under it number.
I don't remember that. In any case it wouldn't work very well, because after the next reboot, the "previous" configuration recorded in the GRUB menu could be garbage collected, leading to a broken menu entry.
Well, at least it did guarantee at least one known-booted version in the GRUB menu — now we don't have such a guarantee.
What makes you think the boot system is now garbage collected?
I noted that the store path referred to by /run/booted-system
is not itself garbage-collected; however, nix-collect-garbage -d
does remove the symlink to it from /nix/var/nix/profiles
(1), resulting in the next nixos-rebuild
that touches the boot menu removing the corresponding boot menu entry, hence my saying that garbage collection causes the boot menu entry to be removed, even though garbage collection does not itself remove the menu entry.
[…] after the next reboot, the "previous" configuration recorded in the GRUB menu could be garbage collected, leading to a broken menu entry.
It seems to me that, currently, nix-collect-garbage -d
garbage-collects all the system generations not corresponding to /run/booted-system
or /run/current-system
(2), leaving all corresponding boot menu entries broken until the next nixos-rebuild
rebuilds the boot menu; I wouldn't expect it to work any differently were nix-collect-garbage -d
to leave the booted-system
's /nix/var/nix/profiles
entry in place.
(1): Unless /run/booted-system
and /run/current-system
are the same.
(2): Or any others that happen to have GC roots.
What is the update on this issue?
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:
@stale: I still care about this.
I marked this as stale due to inactivity. → More info
It would be excellent to keep around the last successfully booted generation, selectable if booting a later generation fails, as a fallback.
I note that at one point, NixOS apparently prevented garbage-collection from causing the system profile corresponding to
/run/booted-system
— a known-bootable system generation — to be removed from the list of system generations presented to the user from which to choose on boot.As I note that NixOS no longer seems to do this, and I've failed to find any seemingly relevant issues between the aforelinked one and the present, I'd like to ask: when and why did NixOS stop keeping the last-booted system generation available for booting?