Wednesday, October 23, 2013

Dual Booting Ubuntu and Windows 8

This blog post commemorates the better part of a work day I spent installing a dual boot of Ubuntu Linux 13.10 and Windows 8 on my Lenovo X230 Thinkpad. I did not expect to have such trouble, but I did, and once I came out in the open about it on Facebook and Twitter I heard from many others who have fought the good fight--and given up. So maybe this post will be helpful to some of you.

If you're looking for quick instructions for adding an Ubuntu partition to a machine with Windows 8 installed, here they are:
  1. Manually partition your memory on your Windows 8 operating system. Go to the Control Panel, go to Disk Management, and create a new partition from your main partition. (More information here.)
  2. Acquire an Ubuntu installation mechanism, either from Ubuntu or by downloading a disk image and burning it onto a flash drive or CD.
  3. When starting up your computer, press "Enter" to interrupt the normal boot sequence. Press F12 to get into the boot menu. Select the option to boot from the flash/CD drive. Follow the directions to install Ubuntu.
  4. The Ubuntu install will mess up your boot loader and prevent you from loading Windows properly. To fix this, install Boot Repair on your Linux system and select "Recommended Repair." This will reinstall your GRUB and do some other things.
  5. The final piece of what you'll need to do is disable Secure Boot in your BIOS. Windows 8 uses it to make sure the pre-OS environment is secure. You can do it by pressing "Enter" at startup, getting into the BIOS options, and selecting "Disable" for the Secure Boot option. (More here on Secure Boot and here on disabling it.)
Read on for the full story.

The first question to address is why the dual boot. Linux is non-negotiable for coding. Besides feeling somewhat like it would be a waste to wipe out Windows, Windows is pretty useful for programs like Powerpoint, SolidWorks, and the new software that came with my drawing tablet (Autodesk, ArtRage, and Photoshop). Why don't I just get a Mac, you might ask. Maybe I'm waiting for free software to get good enough that I don't have to use Windows anymore. Or maybe I just haven't... yet...

The second question to address is why the dual boot and not virtual machines. At one point I was running a Windows virtual machine on Linux to use Powerpoint. And then my Windows decided to install updates... for ten minutes... during the beginning of my Research Qualifying Exam. After that, I decided dual boot was the better way to go. I hear having Windows as the host is better, but I mostly spend my time in Linux anyway. Windows is just for the special stuff every now and then.

Now for the story. I went on the Ubuntu website, downloaded a disk image, and burned it onto a disk as I normally do, expecting to be able to boot off the disk as usual. Ha. I tried turning on my computer a couple of times, thinking the system would detect the disk and boot off of it. That didn't work, I had thought because the boot order was not in my favor. I then wondered if I could take the easy route and use WUBI, the Ubuntu Windows installer, which was also part of the Ubuntu disk image. It looked like I was getting a little bit far in my Ubuntu installation: the system told me it succeeded and I even got a pretty "which OS do you want, Ubuntu or Win 8?" screen. But every time I tried to select the "Ubuntu" option I got a black screen of death saying my \ubuntu\winboot\wubuildr.mbr file was missing. A quick internet search revealed that WUBI is not to be used in conjunction with Windows 8 or UEFI hardware. (Okay, here I'll admit I tried reburning the CD at least once before doing this...) Apparently WUBI doesn't work with UEFI, the Universal Extensible Firmware Interface, because it uses grub4dos, which doesn't support GPT (GUID partition table) disks, which is a more flexible disk partitioning mechanism associated with UEFI.

I tried a little harder to boot off the disk and discovered that pressing "Enter" got me out of the normal boot sequence and F12 allowed me to boot off the disk. It looked like I successfully installed Linux again, until I shut down and tried to enter my Windows partition. There I got an equally scary screen saying my Windows couldn't be accessed anymore. I searched the error on Google and it said that I could probably address my boot issues using Boot Repair. I installed it, and during installation it reinstalled the GRUB (GNU GRand Unified Bootloader) and told me I needed to disable Secure Boot. Wondering if the second part was really true, I tried starting up Windows without disabling Secure Boot. No luck. It turns out that if Secure Boot is enabled, Windows 8 expects it to report back on certain properties that the dual boot breaks. (More here.) I went into the BIOS, found the Secure Boot [Enabled] option on the right-most screen, and set it to [Disabled]. (Apparently Linux systems can support Secure Boot now, but--unless I'm missing something--not for dual booting.)

And... then... it... worked! Now I have a working dual-boot of Windows 8 and Ubuntu 13.10. My usage of Windows 8 has been an endless source of amusement for my office friend Rishabh. ("Why do you have to do this just to get that to work?") Perhaps this can be the subject of a future blog post.