You are not logged in.
I boot into my main linux system with systemd-boot and I also want to boot into windows from an external drive, if the drive is connected.
I want to use systemd-boot to (1) detect if the external drive (/dev/sdb) is connected and if so boot into Windows otherwise when the drive is not connected boot into arch.
# blkid -o list
device fs_type label mount point UUID
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/dev/nvme0n1p1 vfat /efi C8A0-8368
/dev/nvme0n1p2 ext4 / ee8fa627-41d1-4cc8-80a8-8dd3110891b2
/dev/sdb2 (not mounted)
/dev/sdb3 ntfs Going Merry (not mounted) 9ABE1D42BE1D1879
/dev/sdb1 vfat (not mounted) 1407-2E24
/dev/sda3 ext4 /home ef298253-56eb-4697-883e-67d752a58f6a
I installed edk2-shell and ran
cp /usr/share/edk2-shell/x64/Shell.efi /efi/EFI/BOOT/shellx64.efi
echo "9ABE1D42BE1D1879:EFI\Microsoft\Boot\Bootmgfw.efi" >> /efi/windows.nsh
Output of bootctl list:
#bootctl list
type: Boot Loader Specification Type #1 (.conf)
title: Windows
id: windows.conf
source: /efi//loader/entries/windows.conf
efi: /efi//EFI/BOOT/shellx64.efi
options: -nointerrupt -noconsolein -noconsoleout windows.nsh
type: Boot Loader Specification Type #1 (.conf)
title: Arch Linux (arch.conf) (default) (selected)
id: arch.conf
source: /efi//loader/entries/arch.conf
linux: /efi//EFI/arch/vmlinuz-linux
initrd: /efi//EFI/arch/initramfs-linux.img
options: root=UUID=ee8fa627-41d1-4cc8-80a8-8dd3110891b2 rw >
type: Boot Loader Specification Type #1 (.conf)
title: Arch Linux (arch-fallback.conf)
id: arch-fallback.conf
source: /efi//loader/entries/arch-fallback.conf
linux: /efi//EFI/arch/vmlinuz-linux
initrd: /efi//EFI/arch/initramfs-linux-fallback.img
options: root=UUID=ee8fa627-41d1-4cc8-80a8-8dd3110891b2 rw >
type: Automatic
title: Windows Boot Manager
id: auto-windows
source: /sys/firmware/efi/efivars/LoaderEntries-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
type: Automatic
title: Reboot Into Firmware Interface
id: auto-reboot-to-firmware-setup
source: /sys/firmware/efi/efivars/LoaderEntries-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
When I select Windows (top most) on the systemd-boot's boot-menu, the menu sort of refreshes and does not boot into the connected drive. I am essentially stuck in the systemd-boot menu unless I choose arch. Also notice I have "Windows Boot Mangaer" as "type: automatic" listed above; it appears as "Windows 11" on the systemd-boot menu and if I select that, a Windows 11 error message appears that says "BCD files missing or corrupted" and I cannot boot from the drive. However, if I select the "Windows boot Manager" from the BIOS I can boot into Windows all right.
Contents of /efi//loader/entries/windows.conf
title Windows
efi EFI/BOOT/shellx64.efi
options -nointerrupt -noconsolein -noconsoleout windows.nsh
Furthermore, I have these files inside /efi
# ls /efi/
Boot bootmgr BOOTNXT EFI loader windows.nsh
# ls /efi/EFI/
arch BOOT Linux Microsoft systemd
How can I boot from the external drive?
Last edited by nikinbaidarr (2024-01-07 14:28:07)
Offline
You've used the UUID as an identifier in windows.nsh, it should be the PARTUUID.
EDIT: just out of curiosity, does this work if placed in a file called startup.nsh on the ESP root (replace $partuuid with the actual PARTUUID):
if exist $partuuid:\EFI\Microsoft\Boot\bootmgfw.efi
goto FOUNDIMAGE
endif
If so I can add it to the wiki as an alternative method.
Last edited by Head_on_a_Stick (2024-01-07 13:35:10)
Para todos todo, para nosotros nada
Offline
Output of bootctl list:
#bootctl list ... type: Automatic title: Windows Boot Manager id: auto-windows source: /sys/firmware/efi/efivars/LoaderEntries-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
...
Also notice I have "Windows Boot Mangaer" as "type: automatic" listed above; it appears as "Windows 11" on the systemd-boot menu and if I select that, a Windows 11 error message appears that says "BCD files missing or corrupted" and I cannot boot from the drive.
I managed to fix this BCD error from a windows installation drive and now from the systemd-boot menu I can select this to boot into windows when I have the drive connected.
About the windows.nsh, I tried
$ sudo blkid -s PARTUUID -o value /dev/sdb3
[sudo] password for nikin:
e2e72074-a04d-49ec-9842-492a6b52fca1
$ sudo blkid -o list
device fs_type label mount point UUID
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/dev/sdb3 ntfs Going Merry (not mounted) 9ABE1D42BE1D1879
/dev/nvme0n1p1 vfat /efi C8A0-8368
/dev/nvme0n1p2 ext4 / ee8fa627-41d1-4cc8-80a8-8dd3110891b2
/dev/sdb2 (not mounted)
/dev/sdb1 vfat (not mounted) 1407-2E24
And my /efi/windows.sh looks like this:
e2e72074-a04d-49ec-9842-492a6b52fca1:EFI\Microsoft\Boot\Bootmgfw.efi
But if select the windows entry from the systemd boot manger it still does not work. The screen sort of refreshes and I am stuck in what appears a loop.
I dont' mind the former config with "Windows Boot Manager" so I will mark this thread as "partially SOLVED".
Offline