When is a reboot necessary after auto-upgrade?

Hey all,

we enabled auto-upgrade on all our servers. But how do we know if a reboot is necessary?

Maybe you can compare some files in “/run/current-system/” with “/run/booted-system/”, like comparing “/run/current-system/kernel” with “/run/booted-system/kernel”.

1 Like

Not the OP but I asked myself the same thing…

@ilkecan you mean for detecting kernel changes? But is the current-system's kernel package updated when you do a nixos-rebuild switch? If so then this could indeed work…

It is, I do exactly this on my systems, I basically compare the two following strings:

$(readlink /run/booted-system/{initrd,kernel,kernel-modules})
$(readlink /run/current-system/{initrd,kernel,kernel-modules})

and I reboot the servers when the strings are different.


Or just diff <(readlink /run/booted-system/{initrd,kernel,kernel-modules}) <(readlink /nix/var/nix/profiles/system/{initrd,kernel,kernel-modules}). No output, no problem :slight_smile: