Saturday, January 7, 2017

How to install Ubuntu 16.04 alongside Windows 10 (dual boot)

Let's be honest here—who actually likes messing with partition tables? I know I don't, and every time I have to install a new Unix-based OS alongside a pre-installed Windows partition, I get a little nervous. Therefore, I thought it's never too late to write a step-by-step tutorial on how to install Ubuntu 16.04 alongside Windows 10 without falling for the common pitfalls (Secure Boot, partitioning, missing GRUB entry, etc.).


Step 1: Prepare your Windows machine for dual boot

This guide assumes that you perform the installation on a machine that comes pre-installed with Windows 10 (or an older version thereof). The first thing you need to take care of is to make sure both Secure Boot and Fast Boot are disabled, otherwise the installation might fail.

Microsoft Secure Boot is a component of Windows 8 and 10 that relies on the UEFI specification's secure boot functionality to help prevent malicious software applications and "unauthorized" operating systems from loading during the system start-up process. If your hardware supports the UEFI specifications, you need to disable Secure Boot:

  1. Open the BIOS menu. You can often access this menu by pressing a key during the bootup sequence, such as F1, F2, F12, or Esc. Or, from Windows, hold the Shift key while selecting Restart from the Start Menu. Go to Troubleshoot > Advanced Options: UEFI Firmware Settings.
  2. Find the Secure Boot setting, and if possible, set it to Disabled. This option is usually in either the Security tab, the Boot tab, or the Authentication tab.
  3. Save changes and exit. Let the PC reboot.

Fast Boot (or Fast Startup) is another potential culprit that needs to be disabled. The reason is that hibernation may maintain the structure of your file system even when you reboot the machine, so if you try to save a file from Linux into the NTFS partition it will get lost on Windows reboot as it only remembers the old file structure. In general: If a disc is mounted when using fast boot, Windows puts this disc and its content in a hiberfile. Any changes made to the system are gone when the hiberfile is restored. This includes mounted external discs. Ubuntu will refuse to mount a disc that has a hiberfile.

You can disable fast startup in Windows 10 with the following procedure:

  1. Search for and open “Power options” in the Start Menu.
  2. Click “Choose what the power buttons do” on the left side of the window.
  3. Click “Change settings that are currently unavailable.”
  4. Under “Shutdown settings” make sure “Turn on fast startup” is enabled.

Step 2: Allocate some free space for the new Linux partition

Next, we want to allocate some free space on the hard disk to make room for the Ubuntu installation. This is easy to do in Windows. Log in to your Windows machine with an administrative account and right click on the Start Menu, then select Command Prompt (Admin) to enter the Windows Command Line Interface (CLI).

Once in CLI, open the Disk Management Utility by typing diskmgmt.msc and hitting Enter. From here, right click on the C: partition and select Shrink Volume in order to resize the partition:

Now enter a value on space to shrink in MB (use at least 20000 MB depending on the C: partition size) and hit Shrink to start partition resize as illustrated below.

Once the space has been resized you will see a new unallocated space on the hard drive. This is where you will install Ubuntu 16.04.

Step 3: Download Ubuntu 16.04

Now it’s time to install Ubuntu 16.04. Go to Ubuntu's Download page and grab the Ubuntu Desktop 16.04 ISO Image.


Step 4: Create a bootable Ubuntu USB drive

Download Rufus, an open-source tool to create a bootable USB drive using the Ubuntu ISO disk image you download above. No installation is necessary, just download and run it.

More info here.

Burn the image to a DVD or create a bootable USB stick using a utility such as Universal USB Installer (BIOS compatible) or Rufus (UEFI compatible). Place the USB stick or DVD in the appropriate drive, reboot the machine and instruct the BIOS/UEFI to boot from the DVD/USB by pressing a special function key (usually F12, F10 or F2 depending on the vendor specifications).

Once the media boot up, a new grub screen should appear on your monitor. From the menu select Install Ubuntu and hit Enter to continue.

Step 4: Start the installation of Ubuntu 16.04

On the Launcher hit on the second icon from top, Install Ubuntu 16.04 LTS, and the installer utility will start. Choose the language you wish to perform the installation and click on Continue button to proceed further.

When it is time to select an Installation Type, you can either choose to "Install Ubuntu alongside Windows Boot Manager", which will automatically take care of all the partition steps, or you can do the partitioning yourself by choosing "Something Else". Then hit Continue.

Step 5: Create a custom partition layout

This is where things can get tricky. If you're like me, you will get a little nervous whenever you have to mess with partitions. If you're not careful, you can seriously mess up your system, and there will be no popup that reads "Are you completely and absolutely sure you know what you're doing here? Microsoft is not going to pay for this..." to save you.

Ready?

Sure?

OK then. :-) It's probably a good idea to create two partitions, one for root holding all system files, and one for home holding all account data. Swap partitions seem to be going away (or ar at least controversial), with some people saying they are really only required if you have limited RAM resources. You will have the option to create a swap partition below anyway.

To create the root partition, select the free space (i.e., the shrink space we created earlier in Windows) and hit the + icon. In the partition settings, use the following configurations and hit OK to apply the changes:

  • Size: at least 20000 MB
  • Type for the new partition: Primary
  • Location for the new partition: Beginning
  • Use as: EXT4 journaling file system
  • Mount point: /

If you decide you need a swap partition, create it with the following settings:

  • Size: see below
  • Type for the new partition: Logical
  • Location for the new partition: Beginning
  • Use as: swap area

If you have 8GB to 64GB of RAM, the rule of thumb is to set the size of your swap space to half of your RAM (e.g., 16GB swap for 32GB RAM) if you don't want to use hibernation mode, and 1.5 times the amount of RAM (e.g., 48GB swap for 32GB RAM) if you want to use hibernation mode.

Then, create the home partition using the same steps and the following partition settings:

  • Size: all remaining free space
  • Type for the new partition: Primary
  • Location for the new partition: Beginning
  • Use as: EXT4 journaling file system
  • Mount point: /home

When finished, hit the Install Now button in order to apply changes to disk and start the installation process. If you didn't create a swap partition, a popup window should appear informing you about your decision. Ignore the alert by hitting Continue.


Step 6: Finish installing Ubuntu 16.04

Next a new pop-up window will ask you if you agree with committing changes to disk. Hit Continue again and the installation process will now start.

Continue to pick a nearby city and an appropriate keyboard layout. Then pick a username, password, and a name for your computer. Then hit Continue to finalize the installation. From here on the installation process will run automatically until it reaches the end.

After that, a pop-up window will appear after which the computer will reboot. From here on out, the machine will boot into the Grub menu, where for ten seconds, you will be presented to choose what OS you wish to use further: Ubuntu 16.04 or Microsoft Windows.

Step 7: After the installation

After Ubuntu finishes loading, login with the credentials created during the installation process, and have fun!

It's possible that after successful installation of Ubuntu, Windows 10 will not show up in the grub menu. If you're convinced that the disk is correctly partitioned, you can add the entry manually.

The first step is to edit "/etc/grub.d/40_custom" (using sudo) and add the following lines to the bottom of the file:

menuentry 'Windows 10' {
set root='(hd0,msdos1)'
chainloader +1
}

In this case my bootloader was in "/dev/sda1" hence the 1 at the end of msdos. After this run sudo update-grub2 and you should be good to go.