====== Dual Window Grub Bootloader ====== If Windows update overwrites the Grub bootloader. Simple way to restore is to copy the debian bootloader (grubx64.efi) over the windows bootloader. We do the following steps: - Save the bootloader installed by Windows: //copy E:\EFI\Microsoft\Boot\bootmgfw.efi E:\EFI\Microsoft\Boot\bootmgfw.efi.original// - Copy the debian grub bootloader over the bootloader installed by Microsoft (bootmgfw.efi). //copy E:\EFI\debian\grubx64.efi E:\EFI\Microsoft\Boot\bootmgfw.efi// - Add an entry in Grub boot menu to start the orginal windows loader. ==== Correct within Windows ==== Open CMD prompt as "Administrator" and mount the EFT partition as E: drive with: mountvol E: /S E:\EFI>dir Volume in drive E has no label. Volume Serial Number is 502B-5BC6 Directory of E:\EFI 06-12-2016 20:05 . 06-12-2016 20:05 .. 06-12-2016 20:05 Microsoft 13-02-2021 19:01 Boot 27-11-2021 20:18 HP 13-02-2021 08:35 debian 0 File(s) 0 bytes 6 Dir(s) 160.800.768 bytes free copy the debian grub bootloader over the bootloader installed by Microsoft (bootmgfw.efi). copy E:\EFI\debian\grubx64.efi E:\EFI\Microsoft\Boot\bootmgfw.efi ===== Add Windows enty in grub ===== Add the following lines to: **/etc/grub.d/40_custom** menuentry 'WIN 10 (on /dev/sda1)' --class windows --class os $menuentry_id_option 'Win10-efi-502B-5BC6' { insmod part_gpt insmod fat set root='hd0,gpt1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 502B-5BC6 else search --no-floppy --fs-uuid --set=root 502B-5BC6 fi chainloader /EFI/Microsoft/Boot/bootmgfw.efi.original.20221209 } ===== Change Bootorder ===== efibootmgr -v BootCurrent: 0001 Timeout: 5 seconds BootOrder: 0002,0001,3001,0000,2001,2002 Boot0000* Notebook Hard Drive - SAMSUNG MZNTY128HDHP-000H1 BBS(HD,Notebook Hard Drive - SAMSUNG MZNTY128HDHP-000H1,0x500)................-...........A.....................................'.|.......A......................... Boot0001* Windows Boot Manager HD(1,GPT,76a20ae2-4fb2-11ec-bae4-fc39c25e3ce4,0x800,0x82000)/File(\EFI\Microsoft\Boot\bootmgfw.efi)RC Boot0002* debian HD(1,GPT,76a20ae2-4fb2-11ec-bae4-fc39c25e3ce4,0x800,0x82000)/File(\EFI\debian\shimx64.efi) Boot2001* EFI USB Device RC Boot2002* EFI DVD/CDROM RC Boot3001* Internal Hard Disk or Solid State Disk RC Change the boot order: efibootmgr -o 0002,0001,3001,0000,2001,2002 ===== BCDedit ===== C:\WINDOWS\system32>bcdedit Windows Boot Manager -------------------- identifier {bootmgr} device partition=\Device\HarddiskVolume1 path \EFI\Microsoft\Boot\bootmgfw.efi description Windows Boot Manager locale nl-NL inherit {globalsettings} default {current} resumeobject {6beefd36-680a-11eb-ac07-a7444769703e} displayorder {current} toolsdisplayorder {memdiag} timeout 0 Windows Boot Loader ------------------- identifier {current} device partition=C: path \WINDOWS\system32\winload.efi description Windows 10 locale nl-NL inherit {bootloadersettings} recoverysequence {5c5834f8-aff6-11e9-ac26-ce270aa00281} displaymessageoverride Recovery recoveryenabled Yes isolatedcontext Yes allowedinmemorysettings 0x15000075 osdevice partition=C: systemroot \WINDOWS resumeobject {6beefd36-680a-11eb-ac07-a7444769703e} nx OptIn bootmenupolicy Standard bcdedit /set {bootmgr} path \EFI\debian\grubx64.efi bcdedit /set {bootmgr} path \EFI\Microsoft\Boot\bootmgfw.efi bcdedit /enum firmware bcdedit /timeout 10 bcdedit /copy {current} /d "Linux" Windows Boot Manager -------------------- identifier {6beefd39-680a-11eb-ac07-a7444769703e} device partition=\Device\HarddiskVolume1 path \EFI\Microsoft\Boot\bootmgfw.efi description Linux locale nl-NL inherit {globalsettings} default {current} resumeobject {6beefd36-680a-11eb-ac07-a7444769703e} displayorder {current} toolsdisplayorder {memdiag} timeout 10