Failed to install bootloader warning: error(s) occurred while switching to the new configuration

My /boot is full. When I initially created my NixOS drive, I configured my EFI Boot to be 512MBs (wish I made it 1024MB)

I’ve ran the following procedures in attempt to clear out the EFI Boot’s:

sudo nix-env --delete-generations -p /nix/var/nix/profiles/system +3 && sudo nix-store --gc && sudo nix-store --optimise && sudo nix-collect-garbage --delete-older-than 30d

As of now, when I run sudo nixos-rebuild switch, I’m met with the following output:

[nprevail@nixos:~]$ sudo nixos-rebuild boot
[sudo] password for nprevail: 
building Nix...
building the system configuration...
evaluation warning: The option `hardware.pulseaudio' defined in `/etc/nixos/configuration.nix' has been renamed to `services.pulseaudio'.
evaluation warning: The option `services.locate.locate' defined in `/etc/nixos/configuration.nix' has been renamed to `services.locate.package'.
updating systemd-boot from 255.9 to 257.8
Failed to copy data from "/nix/store/iq67az90s1wh3962rnja9cpvnzfh8kpg-systemd-257.8/lib/systemd/boot/efi/systemd-bootx64.efi" to "/boot/EFI/systemd/.#systemd-bootx64.efi94fd24d48c192f00": No space left on device

Failed to copy data from "/nix/store/iq67az90s1wh3962rnja9cpvnzfh8kpg-systemd-257.8/lib/systemd/boot/efi/systemd-bootx64.efi" to "/boot/EFI/BOOT/.#BOOTX64.EFI475f472953e1155a": No space left on device
Failed to copy data from "/nix/store/iq67az90s1wh3962rnja9cpvnzfh8kpg-systemd-257.8/lib/systemd/boot/efi/systemd-bootx64.efi" to "/boot/EFI/BOOT/.#BOOTX64.EFI1744ce9a7639b29f": No space left on device
Traceback (most recent call last):
  File "/nix/store/d9rdn0wqjb6xz3p2l9m780kc4h0ba7iq-systemd-boot/bin/systemd-boot", line 431, in <module>
    main()
  File "/nix/store/d9rdn0wqjb6xz3p2l9m780kc4h0ba7iq-systemd-boot/bin/systemd-boot", line 414, in main
    install_bootloader(args)
  File "/nix/store/d9rdn0wqjb6xz3p2l9m780kc4h0ba7iq-systemd-boot/bin/systemd-boot", line 348, in install_bootloader
    run(
  File "/nix/store/d9rdn0wqjb6xz3p2l9m780kc4h0ba7iq-systemd-boot/bin/systemd-boot", line 58, in run
    return subprocess.run(cmd, check=True, text=True, stdout=stdout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/vxl8pzgkkw8vdb4agzwm58imrfclmfrx-python3-3.12.11/lib/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/nix/store/iq67az90s1wh3962rnja9cpvnzfh8kpg-systemd-257.8/bin/bootctl', '--esp-path=/boot', 'update']' returned non-zero exit status 1.
Failed to install bootloader
warning: error(s) occurred while switching to the new configuration

So far, I haven’t been able to clear out my /boot directory. Any tips?

Yes it’s not ideal but you have to literally manually delete files in /boot, and not even with nix, as the first step.

So, systemd-boot-builder.py is the script that manages this process, and it is actually supposed to remove old kernels / initrds before adding new ones. But I guess the problem in this instance is that even before it removes old files it tries to update the boot loader itself, and it doesn’t have space for the new files. So I guess we should modify the script to remove old generations before updating the boot loader.

Yes it’s not ideal but you have to literally manually delete files in /boot, and not even with nix, as the first step.

So, I can literally input:
sudo rm /boot/*?
This would delete EFI and loader directories.

Sorry if I sound skeptical. It just seems like a serious thing to do. In fact, to be more careful, I may just run dolphin in “administrative mode” and delete contents inside /boot from the file browser.

I was not intending to be that haphazard.

In /boot/EFI/nixos/ you will see kernels and initrds.
I manually delete the older versions in that directory, then delete some old NixOS generations + gc using sudo nix-collect-garbage --delete-older-than <whatever>, then sudo nixos-rebuild boot.

Funnily enough, it would actually be fine though. :stuck_out_tongue: As long as they did another nixos-rebuild before rebooting everything would have been repopulated.

Not if they’re dual-booting :smile: and they use other bootloaders.

Noted! I’ll make sure to run rebuild before shutting down.

Been there, done that. In the process my laptop battery died :joy: Quite annoying to recover though.