From 20b023b5ea63a6513a4dce7f162736a00bce5cc8 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Sat, 22 May 2021 20:01:07 -0400 Subject: iso-image: Improve disk detection This should help in rare hardware-specific situations where the root is not automatically detected properly. We search using a marker file. This should help some weird UEFI setups where the root is set to `(hd0,msdos2)` by default. Defaulting to `(hd0)` by looking for the ESP **will break themeing**. It is unclear why, but files in `(hd0,msdos2)` are not all present as they should be. This also fixes an issue introduced with cb5c4fcd3c5d4070f040d591b2dd1da580f234d1 where rEFInd stopped booting in many cases. This is because it ended up using (hd0) rather than using the `search` which was happening beforehand, which in turn uses (hd0,msdos2), which is the ESP. Putting back the `search` here fixes that. --- nixos/modules/installer/cd-dvd/iso-image.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'nixos/modules/installer/cd-dvd/iso-image.nix') diff --git a/nixos/modules/installer/cd-dvd/iso-image.nix b/nixos/modules/installer/cd-dvd/iso-image.nix index 321a03a0f0c..c2836b5a9a1 100644 --- a/nixos/modules/installer/cd-dvd/iso-image.nix +++ b/nixos/modules/installer/cd-dvd/iso-image.nix @@ -182,6 +182,9 @@ let # Menu configuration # + # Search using a "marker file" + search --set=root --file /EFI/nixos-installer-image + insmod gfxterm insmod png set gfxpayload=keep @@ -252,6 +255,9 @@ let } '' mkdir -p $out/EFI/boot/ + # Add a marker so GRUB can find the filesystem. + touch $out/EFI/nixos-installer-image + # ALWAYS required modules. MODULES="fat iso9660 part_gpt part_msdos \ normal boot linux configfile loopback chain halt \ @@ -383,8 +389,10 @@ let ${lib.optionalString (refindBinary != null) '' # GRUB apparently cannot do "chainloader" operations on "CD". if [ "\$root" != "cd0" ]; then + # Force root to be the FAT partition + # Otherwise it breaks rEFInd's boot + search --set=root --no-floppy --fs-uuid 1234-5678 menuentry 'rEFInd' --class refind { - # \$root defaults to the drive the EFI is found on. chainloader (\$root)/EFI/boot/${refindBinary} } fi -- cgit 1.4.1