Wednesday, August 27, 2014

How to Dual-Boot Windows 8.1 and Linux

I just discovered something cool -- how to dual-boot Linux -- and want to document it.  It was way way WAY more complicated than it should have been.

1.  You have to learn how to hack into the Windows 8.1 boot process.  If you just restart Windows 8.1, there is no way to interrupt the process with F2 or whatever.  What you have to do is click Win-C to bring up the Charm bar, then click "Change PC Settings", then go to the bottom and click "Update & Recovery", then "Recovery", then "Advanced Startup", then "Troubleshoot", then "UEFI Firmware Settings".  Oh yeah somewhere in this step you have to turn off fast boot.

2. Learn how to change the UEFI (formerly known as BIOS) settings.  Turn off Secure Boot, and change the Boot Mode to "Legacy Support" (instead of UEFI), and the Boot Priority to "UEFI First", and then change the Boot Priority Order so it reads the CD/DVD drive first.  At this point, you have a stable system that run the Windows Boot Manager to load Windows.

3.  Now install Linux.  I'm skipping about 100 steps here but they are documented elsewhere.  Download Linux (I'm using Linux Mint 17, but I think the process is similar for any version) and burn the ISO image to a DVD.  You have to shrink the C drive in Windows to free up about 30 gigs.  Reboot and the Linux install DVD will run. As part of the process, you will create 3 partitions:  root ("/"), home, and swap. Important: on the screen where you create the partitions, it will ask for the device to boot from, and you will probably choose the default, which is "/dev/sda". (Note: as I will explain later, you should have chosen "/dev/sda2").  Towards the end, it will run a process called grub-install, which installs the Grub boot loader.

4.  Now, take a deep breath. You have just installed Linux Mint or whatever.  You can reboot, it will start Grub, and you can start up Linux.  But what happens when you choose Windows 8.1?  You get a bizarre error message.  Congratulations, YOU JUST BROKE WINDOWS.  Now calm down, nothing is lost, all your data is there, you just can't get to it.  How do you fix it?  Well, according to Microsoft, you should insert the first install disk and run troubleshooting.  But what if you don't have an install disk?  Well you can download if from Microsoft if you have the product key.  But what if you don't have the product key?  You should download the Windows 8 Recovery CD from https://neosmart.net/EasyRE/.  It costs $19.75 and it is worth every penny.  (I'm not affiliated with them).  Maybe there is another option, but that is what I did.  This will fix the Windows Boot Manager so you can get into Windows.

5.  But now you are locked out of Linux.  Now you may try to use a program called "EasyBCD", also from NeoSmart, to edit the Windows Boot Manager and add Linux.  But it doesn't work.   You can recover by booting up the Linux install disk as a LiveCD and using "sudo grub-install".  So now you can get back into Linux, but you are locked out of Windows again.  Go back to step 4.

6.  How to you get out of this mess?  EasyBCD doesn't work to edit the Windows Boot Manager to load Linux, and Grub doesn't load Windows.  You need to download a boot manager called Refind, available from http://www.rodsbooks.com/refind/.  Download the ISO, burn it to a CD and reboot.  This will bring up a menu letting you choose either Windows or Linux, and both work!  Go into Linux and run the "install.sh" script.  And then you have to copy the "refind_x64.efi" program to "EFI/Boot/bootx64.efi".  Now when you boot up, it will give you a few seconds to select the operating system or it will run Windows by default.  Beautiful.

7.  Some notes.  EFI is a word I had never heard of until yesterday.  It is like another mini-operating system that runs before the main operating system loads.  It has a shell interface that has lots of commands.  On Windows it is installed in a separate partition with about 260 megs, with the label SYSTEM_DRV.  To view it, you have to run a Command window with Admin privileges and do "mountvol S: /S" to mount it to drive S:. Then you can see what is in it.  The bootup file is the aforementioned bootx64.efi.

So there it is.  A technical writer should go through and document it.

No comments:

Post a Comment