How to add Windows 8 to grub on a UEFI system

As if the Secure Boot that Windows 8 requires on UEFI systems isn't already causing enough problems and general annoyance, Windows 8 can also be a real pain in the behind to add to grub on a system with UEFI and the GPT partition table. I'll show you how it worked for me and I hope it will work for you too.

Step 1: Find your EFI Boot partition

It isn't really as hard as I made it sound, once you know how you do it. First, we'll find your EFI Boot partition. Open a terminal window and type sudo parted /dev/sda print | grep -i efi. Remember the first number on the line it outputs, which should be something like this:

1      1049kB  53.5MB  52.4MB  fat32        EFI System Partition  boot
That first number is the partition number.

*If your operating systems are not on sda, don't put sda, put sdb or sdc or whatever it is.

Step 2: Open the file

Grub now suggests that you not directly edit your grub.cfg so instead, with adminidtrator rights (sudo), create a file called 30_windows in your /etc/grub.d directory.

Open the file with the editor of your choice. I personlly suggest nano or gedit. Make sure to open it with root privilages (sudo) so we can save it back to the same place.

Step 3: Add the Windows 8 entry

In the file, write this:

#!/bin/bash
cat << EOF
menuentry "Windows 8" {
	insmod part_gpt
	insmod chain
	set root='(hd0,gpt1)'
	chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
EOF

Where hd0 is the first hard drive, if your operating systems are on the second put hd1, and gpt1 is the first partition so if your partition number from step one is anything other than 1, put gpt[whatever number it is], ex. gpt2, gpt3.

Step 4: Update grub

In a Terminal, type sudo update-grub.

Step 5: Reboot

The menu entry should be there, so reboot and when the grub menu appears, pick Windows 8 and you're set!

If you have any questions or comments or you need assistance, send me an email at site@timmeredith.com