Modify Grub EFI file location with Multi-Boot OS

New to Debian (Or Linux in general)? Ask your questions here!

Re: Modify Grub EFI file location with Multi-Boot OS

Postby LechonLover » 2019-07-05 23:08

I didn't see any error messages when performing the command. I used powershell, and opened it as administrator.

I did it again, and took a screenshot this time. I entered the following bcdedit /set "{bootmgr}" path "\EFI\Debian\grubx64.efi
Unfortunately it will not let me attach the file, it says the board attachment quota has been reached. Anyway it said, operation completed successfully.

I have tried most of what p.H. has suggested other than the last part, where he pointed out what might be the problem with the UEFI, but I am not quite sure how to resolve. (See Below)

Here are possible causes I can think of that the UEFI firmware always boots Windows boot manager and the expected solutions :
- ignores EFI boot entries and uses the "removable device path" -> replace /EFI/BOOT/bootx64.efi (with grub-install --removable)
- uses the boot entry labelled "Windows Boot Manager" regardless of boot order -> bcdedit
- uses the hardwired Windows boot manager pathname -> replace /EFI/Microsoft/bootmgfw.efi
LechonLover
 
Posts: 13
Joined: 2019-06-07 03:16

Re: Modify Grub EFI file location with Multi-Boot OS

Postby Head_on_a_Stick » 2019-07-06 08:38

LechonLover wrote:I entered the following bcdedit /set "{bootmgr}" path "\EFI\Debian\grubx64.efi

That is incorrect, the debian directory does not start with a capital D. Try again with the correct path.

If it still doesn't work then the only option left to try is the last one.

Mount the ESP:
Code: Select all
# mount /dev/sda1 /mnt

Backup the Windows EFI loader:
Code: Select all
# cp /mnt/EFI/Microsoft/Boot/bootmgfw.efi{,.bak}

Then copy grubx64.efi to the Windows EFI loader location:
Code: Select all
# cp /mnt/EFI/debian/grubx64.efi /mnt/EFI/Microsoft/Boot/bootmgfw.efi

If you're using Debian 10 and want Secure Boot support then copy over shimx64.efi instead and also place grubx64.efi in the same directory:
Code: Select all
# cp /mnt/EFI/debian/shimx64.efi /mnt/EFI/Microsoft/Boot/bootmgfw.efi
# cp /mnt/EFI/debian/grubx64.efi /mnt/EFI/Microsoft/Boot

And finally create a file at /boot/grub/custom.cfg with the following content to boot the renamed Windows EFI loader:
Code: Select all
menuentry 'Windows (renamed)' {
   set root=(hd0,1)
   chainloader /EFI/Microsoft/Boot/bootmgfw.efi.bak
}

But it may be better to use the UUID to set the root for that stanza:
Code: Select all
   search --set=root --UUID $uuid --hint hd0,1

Replace $uuid with the actual UUID of the EFI system partition (which can be found with the blkid command).

EDIT: corrected path to bootmgfw.efi
Last edited by Head_on_a_Stick on 2019-07-07 07:27, edited 1 time in total.
Don't break DebianHow to report bugs

SharpBang GNU/Linux — a pre-configured Openbox/Tint2 desktop running on Debian stable
User avatar
Head_on_a_Stick
 
Posts: 10688
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Modify Grub EFI file location with Multi-Boot OS

Postby LechonLover » 2019-07-07 05:43

Head_on_a_Stick - Thank you very much, you solved my problem :D

I first tried as you suggested, and performed the bcdedit command, but this time using lowercase for debian. I restarted the computer, but unfortunately, it went to booting windows again.

I then followed through the steps you provided. My bootmfgw.efi was in a different location than you suggested but I was able to figure it out by opening nautilus /dev/sda1

Here is a copy of my entries from terminal.

simon@HP-X360:~$ mount /dev/sda1 /mnt
mount: only root can do that
simon@HP-X360:~$ sudo mount /dev/sda1 /mnt

simon@HP-X360:~$ cp /mnt/EFI/Microsoft/bootmgfw.efi{,.bak}
cp: cannot stat '/mnt/EFI/Microsoft/bootmgfw.efi': No such file or directory
simon@HP-X360:~$ sudo nautilus /dev/sda1

** (nautilus:2029): WARNING **: 23:08:35.702: Unable to get contents of the bookmarks file: Error opening file /root/.gtk-bookmarks: No such file or directory
^C
simon@HP-X360:~$ cp /mnt/EFI/Microsoft/Boot/bootmgfw.efi{,.bak}
cp: cannot create regular file '/mnt/EFI/Microsoft/Boot/bootmgfw.efi.bak': Permission denied
simon@HP-X360:~$ sudo cp /mnt/EFI/Microsoft/Boot/bootmgfw.efi{,.bak}

simon@HP-X360:~$ sudo cp /mnt/EFI/debian/grubx64.efi /mnt/EFI/Microsoft/Boot/bootmgfw.efi

simon@HP-X360:~$ sudo nano /boot/grub/custom.cfg
simon@HP-X360:~$ sudo nano /boot/grub/custom.cfg
simon@HP-X360:~$ sudo nautilus /dev/sda1

** (nautilus:2114): WARNING **: 23:12:49.757: Unable to get contents of the bookmarks file: Error opening file /root/.gtk-bookmarks: No such file or directory
^C

simon@HP-X360:~$ sudo blkid
/dev/sda1: UUID="8CAE-E7EB" TYPE="vfat" PARTLABEL="sda1 - EFI" PARTUUID="041dbf90-92cc-4b19-b0bb-89ccf64084c1"
/dev/sda3: LABEL="Windows 10" UUID="06723A41723A35B1" TYPE="ntfs" PARTLABEL="sda3 - Windows 10" PARTUUID="6a82e000-fded-47cb-8038-d8473743df3f"
/dev/sda4: LABEL="Elementary" UUID="a1f7d01d-91b7-4b08-85e7-69ac72fabb52" TYPE="ext4" PARTLABEL="sda4 - Elementary" PARTUUID="d326b1ba-a74c-4580-af2a-12e7a0f691bf"
/dev/sda6: LABEL="Windows RE tools" UUID="ECF8B1E1F8B1AA6A" TYPE="ntfs" PARTLABEL="sda6 - Windows RE Tools" PARTUUID="ef33b516-2e42-409d-b518-aa467cd03a38"
/dev/sda7: LABEL="RECOVERY" UUID="98D4C6C6D4C6A63A" TYPE="ntfs" PARTLABEL="sda7 - HP Recovery" PARTUUID="70e6d463-2315-43eb-8c1a-c07679ea38d6"
/dev/sda8: LABEL="Debian" UUID="d63f60dc-8071-4bca-8bbc-f6e12a8617f0" TYPE="ext4" PARTLABEL="sda8 - Debian" PARTUUID="036b1a85-f238-4f13-823b-2cbc5c203568"
/dev/sda9: LABEL="Linux-Shared" UUID="722354ff-0b40-48cf-a216-d0234f49a027" TYPE="ext4" PARTLABEL="sda9 - Linux Shared" PARTUUID="12338744-674a-4ae6-a75d-fa79f139095f"
/dev/sda10: UUID="5ce96ea1-da8a-46ed-a3f1-d1d2214732c7" TYPE="swap" PARTUUID="3b21eed8-4332-44d5-a698-1775ab31ca74"
/dev/sda11: LABEL="Linux Mint" UUID="612e050e-f46b-4120-8d1a-869e3f82d0b7" TYPE="ext4" PARTLABEL="sda11 - Linux Mint" PARTUUID="5a3d6491-1be1-4ccc-8eb6-52151f96e529"
/dev/sda2: PARTLABEL="sda2 - Microsoft Reserved" PARTUUID="d5b4e36a-5a0f-432f-8036-ec42aad6d5cc"

simon@HP-X360:~$ sudo nano /boot/grub/custom.cfg
simon@HP-X360:~$ sudo nano /boot/grub/custom.cfg
simon@HP-X360:~$ sudo reboot


After the rebooot, it went straight to debian bootloader.

I can't believe, it is fixed. Thank you so much, this has problem has been bugging me for so long.

Thank you for your time, and have a great day,
Simon
LechonLover
 
Posts: 13
Joined: 2019-06-07 03:16

Re: Modify Grub EFI file location with Multi-Boot OS

Postby p.H » 2019-07-07 07:03

Head_on_a_Stick wrote:The bcdedit command wasn't passed successfully because the Windows boot entries should point to the Debian .efi loader

Boot0004 is a Windows boot entry pointing to the Debian boot loader. But it is not in the BootOrder, and other Windows boot entries pointing to Windows boot manager exist.

Head_on_a_Stick wrote:That is incorrect, the debian directory does not start with a capital D

AFAIK, FAT and EFI are case insensitive.

OP : note that this workaround is a last-resort hack and may be overwritten after any Windows update.
p.H
 
Posts: 1182
Joined: 2017-09-17 07:12

Re: Modify Grub EFI file location with Multi-Boot OS

Postby Head_on_a_Stick » 2019-07-07 09:09

p.H wrote:Boot0004 is a Windows boot entry pointing to the Debian boot loader.

Damn, I missed that :oops:

@OP: can you add that entry to the boot order?
Code: Select all
# efibootmgr -o 4,6

If that works it would be a better solution than renaming bootmgfw.efi, which might interfere with Windows.

p.H wrote:FAT and EFI are case insensitive

Yes of course, how silly of me. Thanks for the corrections.

p.H wrote:OP : note that this workaround is a last-resort hack and may be overwritten after any Windows update.

+1
Don't break DebianHow to report bugs

SharpBang GNU/Linux — a pre-configured Openbox/Tint2 desktop running on Debian stable
User avatar
Head_on_a_Stick
 
Posts: 10688
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Modify Grub EFI file location with Multi-Boot OS

Postby LechonLover » 2019-07-17 02:57

Thanks for the reply. I do understand this last attempt I did is a workaround, and doesn't quite solve the problem. From what I understand, we renamed bootmfgw.efi and then replaced that with the debian grubx64. So, since the laptop automatically keeps loading the windows bootmgr efi, the system is now displaying debian as the default.

I ran the following code as suggested, here is my output below:

simon@HP-X360:~$ efibootmgr
BootCurrent: 0000
Timeout: 0 seconds
BootOrder: 2001,0000,3000,0001,2002,2004
Boot0000* Windows Boot Manager
Boot0001* ubuntu
Boot0003* sparky
Boot0004* Windows Boot Manager
Boot0005* UEFI Hard drive
Boot0006* debian
Boot000A* Manjaro
Boot000C* MX18.3
Boot000D* feren
Boot2001* EFI USB Device
Boot3000* Internal Hard Disk or Solid State Disk

simon@HP-X360:~$ sudo efibootmgr -o 4,6
[sudo] password for simon:
BootCurrent: 0000
Timeout: 0 seconds
BootOrder: 0004,0006
Boot0000* Windows Boot Manager
Boot0001* ubuntu
Boot0003* sparky
Boot0004* Windows Boot Manager
Boot0005* UEFI Hard drive
Boot0006* debian
Boot000A* Manjaro
Boot000C* MX18.3
Boot000D* feren
Boot2001* EFI USB Device
Boot3000* Internal Hard Disk or Solid State Disk



I will restart the system, and see what happens.
LechonLover
 
Posts: 13
Joined: 2019-06-07 03:16

Previous

Return to Beginners Questions

Who is online

Users browsing this forum: 3rdOstrige and 8 guests

fashionable