Sunday, June 25, 2017

Dual Booting - Ubuntu w/Windows 10 Easy

How to dual boot an existing Windows 10 with an external hard drive.

Tested on the ASUS E200HA / Windows 10 / Ubuntu 17.04. 

First download and create a bootable USB drive with Ubuntu 17.04 (tested)
or whatever your favorite Linux distro that has UEFI support is;
this tutorial will reference Debian commands, map them as necessary.

Step 1 - Enter the BIOS - Keep tapping F2 when the computer first starts -- otherwise, if it still boots Windows 10 go to Settings->Update & security->
Recovery->Advanced startup->Restart Now ->Troubleshoot->Advanced Options->UEFI Firmware Settings->Restart

Step 2 - In the BIOS, disable Fast Boot and disable Windows from the
Boot Priority List (anything else or bust)

Step 3 - Insert the USB and when the computer starts enter the BIOS
(hit F2 when starting on the Asus E200HA) Select from the
Override Boot Manager options the USB stick and boot your Linux distro,
get wifi set up and run $> sudo apt-get update

Step 4 - Attach the external hard drive, format as necessary with an
ext 4 partition for the Linux installation, or you can wait and allow
the installation software do it for you.

Step 5 - Install Linux to the external hard drive, on the screen where
it asks where you want to put the software on the Ubuntu installation
install workflow -- select SOMETHING ELSE (so you can get to the disk
formatting screens) IMPORTANT -- where it says "Device for bootloader
installation", look at the list of drives above and select from the drop
down list the same partition that has the label in the list above of
Windows Boot Manager efi. That's the partition we need to install our
bootloader to. Make sure you have at least one formatted ext4 partition
and have the mount point /. Finish installing Linux to your external
hard drive.

Step 6 - After the installation completes, type $> mount to see where
your external hard drive is mounted if it's not /target, then unmount it
$> sudo umount /dev/sda1 (if that's what it is). If it's not already mounted
on /target create a new directory on the root /:
Note: If you created other partitions make sure to unmount them and move
all the mounts to under /target (so the chroot kernel can see them).
$> sudo mkdir -p /target
Then mount sda on /target:
$> sudo mount /dev/sda1 /target
Then bind mount the critical directories:
$> for a in /sys /proc /run /dev; do sudo mount --bind "$a" "/target${a}"; done
Then mount the EFI directory, use gparted to locate the
Windows Boot Manager efi partition :
$> sudo mount /dev/sdXY /target/boot/efi
Chroot to the new install:
$> sudo chroot /target
On chroot:
$> sudo apt-get update
$> sudo apt-get install grub2
$> sudo update-grub2
$> exit
Reboot:
$> echo Cross fingers =\) && reboot

Step 7 -- Quickly yank the USB thumbdrive out before the computer gets
started (to make sure the USB hardware addresses don't screw anything
up). Your computer should hopefully automatically bring you back into
Ubuntu this time on the external hard drive no longer the USB thumbdrive.
Re-run an update of grub2:
$> sudo apt-get update
$> sudo update-grub2
DONE.

Step 8 - You should now be able to reboot with the external hardrive attached and it will go to the Ubuntu Grub2 bootloader, thereafter that you can select Windows Boot Manager and get into Windows 10 if you need to. If you don't have your external hard drive then you can still get to Windows 10 by going into the BIOS (hit F2) and select from the Boot Override options the Windows Boot Manager. Enjoy.