Preface #
NixOS1 is a declaratively configured system where the entire OS can be configured using declarative methods. When I first started using NixOS in 2023, I didn’t know about Disko2, so partitioning still required manually running commands. After using it for a while, I discovered the tmpfs as root approach, which was perfect for someone with severe OCD like me. I applied tmpfs as root to all my local devices. The experience was great, so I wanted to switch my servers to NixOS as well, and that’s when I encountered this problem that bothered me for months.
My local devices all use UEFI + systemd-boot, which has been working fine. But cloud servers typically boot with BIOS, and systemd-boot has some issues with BIOS3. I ultimately went with BIOS + GRUB, which is quite different from my local setup.
The Problem #
After running rebuild, I got the following error:
...
updating GRUB 2 menu...
updating GRUB 2 menu...
updating GRUB 2 menu...
Failed to get blkid info (returned 512) for / on tmpfs at /nix/store/nvycxmg4g2q5jyqdxfvkgi95sqs48iw3-install-grub.pl line 212.
warning: error(s) occurred while switching to the new configurationI searched for related issues on GitHub and tried many times but couldn’t resolve it. After more than a month of troubleshooting, I finally found the solution.
Solution #
Edit the hardware-configuration.nix file and add the following:
boot.loader.grub.enable = true;
boot.loader.grub.efiSupport = true;
boot.loader.grub.efiInstallAsRemovable = true;Save the file, run rebuild again, and it should work normally.