Thursday 27 August 2015

Install Ubuntu with Windows 8 for dual boot

You can try updating grub after installing ubuntu by booting from ubuntu live CD/USB.
Open terminal and run following commands: -
If Linux's "/" on sda2 (second) (you can check it from Disks utility of ubuntu) partition. Run the following command.
$ sudo mount /dev/sda2 /mnt
$ sudo grub-install --root-directory=/mnt /dev/sda
The above commands will install GRUB. Now boot your system with the HardDisk. When the system is booted up open the terminal and run the following command.
$ sudo update-grub2
The above command will add an entry for windows  operating system in the grub config file.
But mostly (if you are not lucky) above steps will not work with Windows 8, then follow the following steps and you will have a dual boot machine

1. Back up Windows

There are two steps to backing up Windows:
  1. Create a recovery drive for backing up Windows 8.1
  2. Create a file history for backing up personal files

2. Be ready with a bootable Ubuntu USB drive

3. Shrink your Windows partition

Windows takes up the whole of the drive when it is first installed. In order to install Ubuntu you will need to make space for it. Press the "super key" (Windows key) on your keyboard and click the magnifying glass in the top right corner. In the search box start typing "Partitions". Click on the option called "Create and format partitions". This will bring up the "Disk Management" screen. 
 
 
To shrink the drive, right click on the "OS (C:)" volume and select "Shrink volume". A screen will appear showing how much you can shrink the drive by. Click "Shrink" to continue. When you are finished you will see that there is a lot of unpartitioned space. This is where Ubuntu will be installed.

4. Turn off fast boot

To be able to boot to your Ubuntu USB drive you will need to turn off the fast boot option. Press the "super" key (Windows key) and then click the magnifying glass in the top right corner. Enter "Control Panel". Click on the "Control Panel" option that appears. When the "Control Panel" appears click on the "System and Security" heading. Now click on "Power Options". On the following screen click on "Choose what the power button does". A screen will appear with the heading "Define power buttons and turn on password protection". Scroll down until you see "Shutdown Settings". An option should be available called "Turn on fast startup" (recommended). Uncheck this option. Click "Save Changes".

5. Turn off secure boot

Turn off secure boot from your BIOS setup.

6. Install Ubuntu

Boot from the USB drive into Ubuntu live and you should have a similar option available to you. 
 
 
In “INSTALLATION TYPE ” Window select “Something else” 
create partitions for boot and root folders.

7. Boot Repair

Restart now and your computer booted straight into Windows without giving the option for Ubuntu. So reboot and choose to boot from USB again. You will now be booted back into the live session of Ubuntu. Make sure that Internet connection is on your computer, and open a terminal by pressing the "super" key (Windows key) and typing "term". Within the terminal window enter the following commands one by one.
sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo sh -c "sed -i 's/trusty/saucy/g' /etc/apt/sources.list.d/yannubuntu-boot-repair-trusty.list"
sudo apt-get update
sudo apt-get install -y boot-repair && boot-repair
Eventually the boot repair screen will appear.

Click on the "Recommended repair".
A message stating "EFI is detected" may appear. This is just an informational message as far as I am concerned because it is perfectly fine to install Ubuntu with EFI turned on. After clicking "OK" to the EFI detected message the utility performed a few tasks and then asked me to select some text and run it in a terminal window. If you are asked to do this open a new terminal window (press the "super" key, enter "term" into the Dash and click on the icon that appears). Copy the text from the boot repair window by selecting it with the mouse. Press CTRL and C and then right click in the terminal window and select paste. Make sure all the commands have run correctly. You may need to press return to get the last command to run. Now click on the "Forward" button within the boot repair application. You may be asked to copy and paste more text. Repeat the process of selecting all the text, press CTRL and C and then right click in the terminal window and select paste. Make sure the commands run. Keep following through on the process until the boot repair finishes.

8. Fix the boot loader

Reboot your computer.
Unless you are lucky it will still boot straight into Windows and actually this is ok because we are going to use Windows to fix the boot loader. Log into Windows and make sure you are viewing the desktop and not the tiles screen. Hover the mouse in the bottom left corner and right click. You should see an option for the administrator's command prompt. Click on this option. Within the administrator's command prompt type the following command:
bcdedit /set "{bootmgr}" path \EFI\ubuntu\grubx64.efi
Exit the command prompt.

9. Reboot into Ubuntu

Reboot your computer. This time when the computer boots you should see 4 options.
1. Ubuntu
2. Ubuntu (advanced)
3. Windows (might say something similar like Windows boot options).
4. Setup

Choose option 1.
Ubuntu should now appear.

10. Reboot into Windows

Reboot your computer (click the symbol in the top right corner, click shutdown and restart). This time when the boot menu appears click on the Windows option. Your computer should boot back into Windows 8.