Created
June 8, 2018 12:07
-
-
Save mfocko/0c34ee75d257d88ddf22de6d980982b0 to your computer and use it in GitHub Desktop.
Acer UEFI workaround
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Checks for enforced Windows Boot Manager & updates it | |
[Service] | |
ExecStart=/usr/local/bin/update_uefi.sh | |
[Install] | |
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
check_bootmgfw() { | |
if [ -e /boot/efi/EFI/Microsoft/Boot/bootmgfw.efi ]; then | |
echo 1; | |
else | |
echo 0; | |
fi | |
} | |
move_bootmgfw() { | |
echo "==> Checking for existing windows.efi file"; | |
if [ -e /boot/efi/EFI/Microsoft/Boot/windows.efi ]; then | |
rm /boot/efi/EFI/Microsoft/Boot/windows.efi; | |
fi | |
echo "==> Moving bootmgfw.efi to windows.efi"; | |
mv /boot/efi/EFI/Microsoft/Boot/bootmgfw.efi /boot/efi/EFI/Microsoft/Boot/windows.efi; | |
} | |
update_uefi_settings() { | |
echo "==> Deleting Windows Boot Manager entry"; | |
efibootmgr -b $1 -B; | |
current_boot_order=$(efibootmgr | sed -rn 's/BootOrder:\ (.*)/\1/p'); | |
echo "==> Current boot order: $current_boot_order"; | |
echo "==> Creating Windows boot entry"; | |
efibootmgr -b $1 -c -l '/EFI/Microsoft/Boot/windows.efi' -L Windows; | |
echo "==> Changing boot order" | |
efibootmgr -o $current_boot_order,$bootmgfw_entry | |
} | |
if [ $(check_bootmgfw) -eq 1 ]; then | |
echo "==> bootmgfw.efi exists"; | |
bootmgfw_entry=$(efibootmgr | sed -rn 's/Boot(.{4})\*\ Windows\ Boot\ Manager/\1/p'); | |
echo "==> Windows Boot Manager entry: $bootmgfw_entry"; | |
move_bootmgfw; | |
update_uefi_settings $bootmgfw_entry; | |
else | |
echo "==> bootmgfw.efi doesn't exist... exiting"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment