-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/systemd-boot: Simpler windows dual booting #344327
Conversation
b1f9b9b
to
f15c446
Compare
@JulienMalka I'm tagging you as maintainer of the memtest and netboot tests, @r-vdp as you added the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Diff LGTM!
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-already-reviewed/2617/1980 |
3fc05ed
to
e713dd1
Compare
@ofborg build systemd-boot.edk2-uefi-shell systemd-boot.windows Edit: whoops wrong command 👀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works on my machine
LGTM
@ofborg test systemd-boot.edk2-uefi-shell systemd-boot.windows |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/prs-already-reviewed/2617/2031 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Diff generally LGTM and having the option makes sense.
Btw, whatever autoformatter you used, it's not nixfmt-rfc-style. I'd recommend you fix that as that will be the only valid one in the not too distant future.
We already have a edk2-uefi-shell package in nixpkgs, but adding it to systemd-boot was somewhat tedious. Now it's a single line of nix.
When installing NixOS on a machine with Windows, the "easiest" solution to dual-boot is re-using the existing EFI System Partition (ESP), which allows systemd-boot to detect Windows automatically. However, if there are multiple ESPs, maybe even on multiple disks, systemd-boot is unable to detect the other OSes, and you either have to use Grub and os-prober, or do a tedious manual configuration as described in the wiki: https://wiki.nixos.org/w/index.php?title=Dual_Booting_NixOS_and_Windows&redirect=no#EFI_with_multiple_disks This commit automates and documents this properly so only a single line like boot.loader.systemd-boot.windows."10".efiDeviceHandle = "HD0c2"; is required. In the future, we might want to try automatically detecting this during installation, but finding the correct device handle while the kernel is running is tricky.
e713dd1
to
73011ba
Compare
Yeah I don't remember tbh, but I reformatted it with the latest version of nixfmt-rfc-style now. |
@ofborg test systemd-boot.edk2-uefi-shell systemd-boot.windows |
"windows_${winVersion}.conf" = '' | ||
title ${cfg.title} | ||
efi /${edk2ShellEspPath} | ||
options -nointerrupt -nomap -noversion ${cfg.efiDeviceHandle}:EFI\Microsoft\Boot\Bootmgfw.efi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this have been bootmgfw.efi
, lowercase? I know the ESP is usually case insensitive, but there have definitely been cases where that wasn't true, whether that's because of buggy firmware or custom UEFI FS drivers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, on my PC at least the path is created by Windows exactly like this, in capital case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, interesting. On mine it's lower case. I wonder why
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might it be mounted case-insensitively on your machine and case-sensitively on mine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It definitely is mounted case-insensitively on my machine, but I'm pretty sure that doesn't affect the case of the file names you see when listing directories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you add boot.loader.systemd-boot.edk2-uefi-shell.enable = true;
to your config and boot into the edk2 shell, and then run map -c
first and then for each of the device handles run ls HD0c1:\EFI
, do the paths show up as case-sensitive then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Show up as case-sensitive" doesn't really make sense. FAT does store file names with their casing, and listing a directory will show the case that was used to create the files in it. It's just that accessing files will match file names case insensitively. And indeed, listing the \EFI\Microsoft\Boot\
directory shows bootmgr.efi
as all lower case, meaning that is how the file is actually stored, but I can also access the file no matter the case I use for the whole path.
Like I said, it's unlikely to be an issue because accessing FAT files is case insensitive. But some implementations don't do that correctly, and it's even possible to use case-sensitive file system drivers with EFI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I didn't know that was the case.
Now that NixOS/nixpkgs#344327 was merged.
Description of changes
When installing NixOS on a machine with Windows, the "easiest" solution
to dual-boot is re-using the existing EFI System Partition (ESP),
which allows systemd-boot to detect Windows automatically.
However, if there are multiple ESPs, maybe even on multiple disks,
systemd-boot is unable to detect the other OSes, and you either have to
use Grub and os-prober, or do a tedious manual configuration as
described in the wiki:
https://wiki.nixos.org/w/index.php?title=Dual_Booting_NixOS_and_Windows&redirect=no#EFI_with_multiple_disks
This commit automates and documents this properly so only a single line
like
is required.
In the future, we might want to try automatically detecting this
during installation, but finding the correct device handle while the
kernel is running is tricky.
This is not something we can rely on systemd-boot to fix, the issue about this has been open for years.
In addition, this PR also adds an option to add a boot-entry for edk2-uefi-shell, which is required to find the correct value for
efiDeviceHandle
and is generally useful for debugging and tinkering.I also took the liberty of autoformatting, which was done in a separate commit to make review easier.
I'm uncertain if this change is significant enough to warrant a release-note.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.