/boot 97% filled with kernels

My system complains with 0 bytes available in /boot.

Looks like I have 40 items filling 97% of /boot in /boot/kernels.

Last thing I tried was adding:

boot.loader.grub.configurationLimit=4
``` to my nixos/configuration.nix file... but it did not seems to have changed anything.

Still having generations 8..36 in advanced grub.

Before I tried:  # nix-collect-garbage -d

Thinking of "randomly" erasing init and kernel files.

tried https://gist.githubusercontent.com/Bondrake/27555c9d02c2882fd5e32f8ab3ed620b/raw/e1e5dd68761a7f7e6a253fcb64905466104b9df9/trim-generations.sh
but got:

[root@nixos:/home/paul/Downloads]# ./trim-generations.sh 
Keeping default: 10 generations OR 7 days, whichever is more
Operating on profile: 	 /nix/var/nix/profiles/default

./trim-generations.sh: line 94: nixGens[0]: unbound variable

[root@nixos:/home/paul/Downloads]# 

I think I am in a similar case as https://www.reddit.com/r/NixOS/comments/xg2lmy/comment/iowsnaa/

Oh, maybe I can’t because of:

[root@nixos:/home/paul/Downloads]# sudo nixos-rebuild boot
building Nix...
building the system configuration...
updating GRUB 2 menu...
cannot copy /nix/store/0vg550136ac5jzcaagq7cjjdvrgcmv2r-initrd-linux-6.1.42/initrd to /boot/kernels/0vg550136ac5jzcaagq7cjjdvrgcmv2r-initrd-linux-6.1.42-initrd.tmp: No space left on device
warning: error(s) occurred while switching to the new configuration

So maybe I need to erased at least one or 2 entries manually.

Have you tried nix-collect-garbage?

You can also just… delete old kernels, it’s fine

Did you rebuild your system afterwards? That option’s script runs on system activation. If you can’t rebuild due to disk space issues, you can indeed remove old kernels manually, it should no longer be necessary in the future.

nix-collect-garbage does not touch the boot partition, it only cleans up /nix/store.

some sort of system generation trimmer service should really come standard and enabled with NixOS, this gun gets everyone’s feet at some point.

Yeah… after removing one specific version manually:

[root@nixos:/boot/kernels]# sudo nixos-rebuild boot
building Nix...
building the system configuration...
updating GRUB 2 menu...
removing obsolete file /boot/kernels/0gi04h8jd43a6vnagr609jmilhs7k87f-linux-5.15.85-bzImage
removing obsolete file /boot/kernels/1av0qkzy3zxy2nrkszhrxx9vg1ib35iv-linux-5.10.117-bzImage
removing obsolete file /boot/kernels/2jq3m7c2jx6lxipimw574k3pvd0ilsy7-initrd-linux-5.15.107-initrd
removing obsolete file /boot/kernels/2l05brrmb1ivggx7qb8x4ikm7zqwp37p-linux-6.1.31-bzImage
removing obsolete file /boot/kernels/3c4nygq9scyj32v45nkqyys3f1lsaisr-linux-5.15.114-bzImage
removing obsolete file /boot/kernels/6z7as9vhckxzlwal47yfb4cpicd8q8xg-initrd-linux-6.1.34-initrd
removing obsolete file /boot/kernels/9yr9xw0mla6hsvz0yci5jwfdgp1kp8wr-initrd-linux-5.15.68-initrd
removing obsolete file /boot/kernels/bdjhxgkw9h0awpv9nkpqxr84scvh6cz0-linux-5.10.122-bzImage
...

default for boot.loader.grub.configurationLimit is 100… but maybe 30 would be more correct to avoid the 500 Mb limit.

1 Like