Linux – Dual-Boot Nasty Hack..
I am setting up an HP Z820 as – primarily – a video creating/editing/restoring system, but I need to be able to boot into Windows 7 Pro (for Vegas Pro, AviSynth, Prodrenalin, Mercalli, etc. etc..) and Linux (Fedora).. I had set up dual-boot systems before, and I am still using Windows 7 Pro SP1, but this time I am using uEFI..
The problem..
Set up dual boot as usual (install Win7, then ‘shrink’ disk partition, then install Fedora 27). First boot into Fedora brings up Grub2 menu correctly, with chainloader entry to boot Windows 7, but after subsequent reboot into Windows 7, only Windows 7 shows up, instead of Grub2. I had read up on many suggested ‘fixes’ but most of these were not very helpful.. I updated the Z820 bios to the very latest version, but this made no difference. The problem appears to be caused by Win7..
Fortunately, as I was using uEFI, I could use this from the Z820 setup UEFI menu option to select Grub2/Fedora manually (EFI- fedora – shimx64-fedora.efi), and still boot into Grub2/Fedora..
I did try one suggested fix, using efibootmgr to add back the ‘Fedora entry’, but after rebooting into Windows 7, this vanished again..
# efibootmgr Timeout: 2 seconds BootOrder: 0000,0004,0005,0008,0006,0009,0000 Boot0000* Windows Boot Manager Boot0001 IP6 Intel(R) 82579LM Gigabit Network Connection Boot0004* DTO UEFI USB Hard Drive Boot0005* DTO UEFI USB Floppy/CD Boot0006* Hard Drive Boot0008* DTO UEFI ATAPI CD-ROM Drive Boot0009* CD/DVD Drive
Add Fedora entry back to efi boot menu:
efibootmgr -c -w -d /dev/sda -p 1 -l '\EFI\fedora\shimx64-fedora.efi' -L "Fedora"
# efibootmgr Timeout: 2 seconds BootOrder: 0002,0000,0004,0005,0008,0006,0009,0000 Boot0000* Windows Boot Manager Boot0001 IP6 Intel(R) 82579LM Gigabit Network Connection Boot0002* Fedora Boot0004* DTO UEFI USB Hard Drive Boot0005* DTO UEFI USB Floppy/CD Boot0006* Hard Drive Boot0008* DTO UEFI ATAPI CD-ROM Drive Boot0009* CD/DVD Drive
Reboot into Windows 7, then Fedora (via uEFI menu!) and the Fedora entry has vanished:
# efibootmgr Timeout: 2 seconds BootOrder: 0000,0004,0005,0008,0006,0009,0000 Boot0000* Windows Boot Manager Boot0001 IP6 Intel(R) 82579LM Gigabit Network Connection Boot0004* DTO UEFI USB Hard Drive Boot0005* DTO UEFI USB Floppy/CD Boot0006* Hard Drive Boot0008* DTO UEFI ATAPI CD-ROM Drive Boot0009* CD/DVD Drive
After more trial-and-error, I came up with the following solution, and it is nasty, but it does work!
Boot into Fedora.
As root, go to /boot/efi/EFI/Microsoft/Boot
Rename bootmgfw.efi to bootmgfwin7.efi
Copy shimx64-fedora.efi and grub64.efi from /boot/efi/EFI/fedora
, and rename shimx64-fedora.efi to bootmgfw.efi
Run grub-customizer to edit Grub2 entry for ‘Windows Boot Manager‘:
change
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
to
chainloader /EFI/Microsoft/Boot/bootmgfwin7.efi
So.. Windows 7 thinks it is rebooting into Windows 7, but is in fact rebooting into Grub2..
Robert Gadsdon. March 14, 2018.
Comments
Linux – Dual-Boot Nasty Hack.. — No Comments