NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.16k stars 14.19k forks source link

When and why did NixOS stop keeping the booted-system bootable? #24158

Open 8573 opened 7 years ago

8573 commented 7 years ago

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?

7c6f434c commented 7 years ago

I think the current situation is a result of a mistake during one of the refactorings…

edolstra commented 7 years ago

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
7c6f434c commented 7 years ago

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.

edolstra commented 7 years ago

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.

7c6f434c commented 7 years ago

Well, at least it did guarantee at least one known-booted version in the GRUB menu — now we don't have such a guarantee.

8573 commented 7 years ago

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.

mmahut commented 5 years ago

What is the update on this issue?

stale[bot] commented 4 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:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.
8573 commented 4 years ago

@stale: I still care about this.

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

yesbox commented 2 years ago

It would be excellent to keep around the last successfully booted generation, selectable if booting a later generation fails, as a fallback.