I keep filling up /boot
with old kernels, at which point nixos-rebuild switch --upgrade
will download a bunch of derivations only to eventually fail when installing the new kernel (or initrd) because there is insufficient space on /boot
.
One option is to run nix-collect-garbage -d
, but that can be extremely slow and can result in needing to download the newly downloaded versions all over again.
Sometimes deleting old kernels seems to help (until /boot
fills up again), whereas other times, manually picking a few generations to delete from ls /nix/var/nix/profiles/system-??-link
has worked better.
Is there a better approach to deal with /boot
filling up? (Particularly for when I want to upgrade and use the new system right away.)
There is a longstanding bug report about this problem when
/boot
fills up. The situation has improved, but reading through all the comments takes a while, so I will attempt to summarize.If you are using GRUB, set
boot.loader.grub.configurationLimit = 42;
(or pick a better number depending on how much space you have in/boot
) so that older kernels will be automatically cleaned up. The existing old kernels will be cleaned up on the nextnixos-rebuild switch
, though you may need to manually delete some first, since the install-grub.pl script will first attempt to copy the new kernels before deleting old ones.If you are using systemd-boot (formerly Gummiboot), as of NixOS 19.03 (thanks domenkozar), set
boot.loader.systemd-boot.configurationLimit = 42;
(or pick a suitable number depending on how much space you have in/boot
), and the nextnixos-rebuild switch
should automatically clean up old kernels.Note that you will want to run
nix-collect-garbage
eventually, before (or when)/nix
fills up. This can also be set to run automatically by settingnix.gc.automatic = true
and related options.