Nixos old generations useup all sapce on boot partition

clean boot partion on nixos due to multiple old generations

How can I free up space on the boot partition in NixOS? The nixos-rebuild switch command creates entries in the boot partition, which is usually 512 MB in size and can hold around 40 previous generations. When testing frequently, this space fills up quickly. Is there a way to manage this, such as cleaning up old generations or selecting specific generations to keep?

If possible, please provide a solution or guidance.

You can use nix-collect-garbage to delete old generations, after which nixos-rebuild should clean up the old boot entries. If /boot is already out of space then nixos-rebuild might fail - see How can I clean up /boot, without a reboot

If you don’t want to remove all previous generations, I’d suggest to simply prune the /nix/var/nix/profiles/system* symlinks manually. (I really do like to keep some “selection” of past systems around.)

1 Like