After running Windows for years I decided I wanted to try out NixOS. I don’t want to lose Windows so I created an extra partition and installed NixOS on it. But after trying it out for a few days I keep running into issues with the boot partition of 100 MB becoming full. After running only 2 or 3 generations the partition is usually close to or at 100%. In the latter case I can’t build a new generation. With only my latest generation its at 60%. That is after garbage collecting.
This is what my partition table looks like according to GParted.
How can I properly clean it up or increase the size of the boot partition? With my limited knowledge I found 2 solutions for increasing the boot partition:
Move the boot partition to a new bigger partition. I’ve never done this, but with a clear guide I’m sure I’ll be able to do it.
Reinstall Windows and NixOS. A bit drastic maybe, but I don’t mind starting fresh. To me my current table partition looks like a mess and with NixOS in mind I can setup the partitions correctly from the start. In that case is there someone who can give a recommended partition table setup and some high level steps?
The reason you are running into a full boot partition is, because you are accumulating multiple kernels from various older generations, which require them.
To save space you could reduce the number of generations you keep, and enable automatic garbage collection.
I will enable these options, but as I mentioned, even with 1 generation it’s already at 60% and that is after garbage collecting. So there should be only 1 kernel. And only having 2 or 3 generations during an evening of tinkering, is not much right?
You could try creating another EFI partition specifically for NixOS.
It’s also possible to use GRUB, which takes less than 1M of space on EFI partition and can read kernel files from the root filesystem. Replace your systemd-boot options with something like this:
I haven’t run into this issue since my boot partition is large enough but I thought about that…
In case my boot is full but my root has still plenty of space, will nixos-rebuild fail (assuming that there is a kernel update)? Is then the recommendation to look into /boot/kernels and remove generations that use old *initrd (in case I want to remove the minimal number or generations that needs to be removed).
(I can’t store kernels on root since root is LUKSed)
if /boot is completely full, rebuild will at the end fail once it tries to add the generation to the boot entries, if theres no new kernel and the the inputs for the kernel havent changed u can have multiple generations in very little space, if the kernel changes a new generation takes a lot more space, old boot entries/kernels are automatically deleted on rebuild, after you deleted the generations
Using GRUB sounds like a nice solution. I wanted to experiment with it anyway. A few question though:
Which setting causes GRUB to read kernel files from the root filesystem? Or is this default GRUB behavior?
Edit: from what I understand kernels are read from /boot, which is part of the main partition if the actual boot partition is mounted to /boot/efi?
Will garbage collection clean up kernel files from the boot partition? And clean up the old ones in root?
Would this be the right order and the right commands to remount the boot partition?
Update configuration
umount /boot
mkdir -p /boot/efi
mount /dev/nvme0n1p2 -o auto /boot/efi
I notice I already have /boot/EFI. Not sure if that is an issue?
In hardware-configuration.nix I just have to change the /boot path to /boot/efi?
After this just a nixos-rebuild switch to apply the changes, and reboot to confirm?
You can have a single partition (root) and /boot is just a directory. Or you can have more partitions and one of them is mounted to /boot - that is requirement if your main partition is LUKS encrypted.
UEFI firmware systems:
You need to have EFI partition (FAT):
You can have root partition, and EFI mounted to /boot
You can have root partition, boot mounted to /boot and EFI mounted to /boot/efi
Thanks! Grub is installed successfully. However the Windows 11 option is not available. I tried the boot.loader.grub.useOSProber = true; but without success. Would it require a manual GRUB entry like it’s suggested on the wiki under EFI > Grub?
If I change this would it require another rm -rf /boot/efi/* and sudo nixos-rebuild switch --install-bootloader?
I’ve backed-up my original /boot directory just in case.