Tuesday, September 23, 2014

Dual Booting Ubuntu 14.04 and Windows 8

Although there have been many, many posts, questions (Ubuntu Forums, Ask Ubuntu)and tutorials (Ubuntu.com) on this subject the solution is still elusive and complex.  Also some background information is needed before delving into the black art of modern boot loaders.  Also note that this article is focusing on having Windows as the primary boot loader and having it delegate to GRUB2 to boot Ubuntu.  This is the focus as Windows 8 will rewrite it's boot loader if it isn't the first OS to boot, wiping out GRUB boot info entirely.

Safety First

On the Ubuntu.com tutorial above it details backing up your entire system and creating recovery disks in case something goes wrong.  It would be a shame to have to reinstall your entire TWO OS's because of a couple of bad files.

A Brief History of Boot Loading

Booting up has a long and venerable history.  For the Microsoft family of OSs (DOS and Windows) the old scheme was to use the Master Boot Record (MBR) located on C:\boot.ini (as a hidden file).  There is also a good Manjaro Wiki  However this had the limitation of "only" being able to index 2 TB of data on a single volume so a new system was devised to future-proof Windows Vista and on, i.e. Windows 8, against truly massive drives.  This scheme is called Unified Extended Firmware Interface (UEFI) and instead of using a single file it uses an entire partition.  You will need to determine your boot loader scheme on Windows.  The scheme to edit UEFI is called the Boot Configuration Data Editor (BCD).  There is a Windows Help article about the back-story and another on the bcdedit utility.  The important take away point is that now a Windows Vista / Windows 8 system can boot up EITHER with UEFI OR the MBR and BCD was created to abstract away this underlying complexity.  This results in either having BCD with UEFI or BCD with the MBR.  However this turns out to be a leaky abstraction.


As a rule of thumb, a computer bought after Windows Vista came out (2008?) will support UEFI.  Also you can dig around in the BIOS during boot up (to bring it up you may have to press F1, F10 or F12) looking for boot information.  In the BIOS MBR may be referred to as "legacy boot" or something similar.  Alternately you can just use msinfo32.

Pick Your Poison

Install and Fix

To modify the new UEFI scheme you need to use either the Windows utility command-line program bcdedit (run from the native shell, NOT a replacement like Console2, and as Administrator), the free-for-non-commercial-use easyBCD or the also free-for-commercial-use BootNext utility.  Unfortunately easyBCD only works with BCD over the MBR and BootNext requires you to register on the blog site to download.  The good news is that easyBCD is easy to use.

Using easyBCD (BCD / MBR)

After much searching and consternation I found an Ask Ubuntu post on how to dual boot Windows and Linux as well as an in depth walk-through on the easyBCD site.  Basically you install normally with the Advanced Partitioning, and then tell Windows how to find Ubuntu.  These posts let me boot to Ubuntu after poking through the boot menu after an error about being unable to find the /NST/AutoNeoGrub0.mbr file.  This happens when you use easyBCD with UEFI.

Using BootNext (BCD / UEFI)

While BootNext supports UEFI it appears to only have a help file for installing with Windows 7.  Also the method is complex as you have to load your Ubuntu partition under Windows and then copy 512 bytes of the boot sector.  This leads us to the option of having UEFI and installing it right to begin with.

Install it Right

It turns out that there was a hard-to-find article on installing Ubuntu alongside another OS with UEFI enabled at help.ubuntu.com and is far easier to understand than a similar Q&A page.  The critical part of this article is that when you install Ubuntu in "Advanced" mode to manage your system partitions you need to find your UEFI partition and mount it at /boot/efi.  You can find this partition by going into the Windows' Disk Management utility and look for a partition with a Status of "Healthy (EFI System Partition)" and note which partition this is (in my case, it was the second partition on the disk).  Remember to create a SWAP partition (1x or 2x as large as your RAM, see the FAQ) as well as your main Ubuntu partition (20 GB or more).


So, in this article we have seen the history of boot loaders, the different kinds of boot loaders and tools to work with them as well as how to install Ubuntu and then tell Windows about it or installing Ubuntu correctly in the first place.  This has been one of the more difficult articles that I have written and I hope that I distilled my research over about 30 different tutorials and Q&A pages into an easy to understand format.