Last active
October 1, 2015 01:10
-
-
Save zhlinh/a4d1d5e396284de549c2 to your computer and use it in GitHub Desktop.
windows_uefi, copy to /etc/grub.d, chmod +x, sudo echo GRUB_DISABLE_OS_PROBER=true >> /etc/default/grub and sudo update-grub
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/sh | |
set -e | |
# Probe for UEFI entries in EFI system partition | |
prefix="/usr" | |
exec_prefix="${prefix}" | |
datarootdir="${prefix}/share" | |
export TEXTDOMAIN=grub | |
export TEXTDOMAINDIR="${datarootdir}/locale" | |
. "${datarootdir}/grub/grub-mkconfig_lib" | |
found= | |
bcd=/boot/efi/EFI/Microsoft/Boot/BCD | |
if [ -n "$bcd" ]; then | |
if grep -qs "W.i.n.d.o.w.s. .8" "$bcd"; then | |
long="Windows 8 (loader)" | |
elif grep -qs "W.i.n.d.o.w.s. .7" "$bcd"; then | |
long="Windows 7 (loader)" | |
elif grep -qs "W.i.n.d.o.w.s. .V.i.s.t.a" "$bcd"; then | |
long="Windows Vista (loader)" | |
elif grep -qs "W.i.n.d.o.w.s. .S.e.r.v.e.r. .2.0.0.8. .R.2." "$bcd"; then | |
long="Windows Server 2008 R2 (loader)" | |
elif grep -qs "W.i.n.d.o.w.s. .S.e.r.v.e.r. .2.0.0.8." "$bcd"; then | |
long="Windows Server 2008 (loader)" | |
elif grep -qs "W.i.n.d.o.w.s. .R.e.c.o.v.e.r.y. .E.n.v.i.r.o.n.m.e.n.t" "$bcd"; then | |
long="Windows Recovery Environment (loader)" | |
elif grep -qs "W.i.n.d.o.w.s. .S.e.t.u.p" "$bcd"; then | |
long="Windows Recovery Environment (loader)" | |
else | |
long="Windows Vista (loader)" | |
fi | |
found=true | |
gettext_printf "Found %s on %s\n" "${long}" "UEFI ESP" >&2 | |
cat << EOF | |
menuentry "${long}" { | |
insmod search_fs_uuid | |
insmod chain | |
EOF | |
DEVICE=`cat /etc/mtab | grep /boot/efi | cut -f 1 -d ' '` | |
prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" | |
cat << EOF | |
chainloader /EFI/Microsoft/Boot/bootmgfw.efi | |
} | |
EOF | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment