09 November 2020

Dual Boot Win 10 and Ubuntu for system with (SSD + HDD) using UEFI - GPT method

Scenario:

My laptop uses Unified Extensible Firmware Interface (UEFI) and not the good old BIOS. I have a hybrid drive system in my machine, a mix of 256 GB SSD and 1 TB HDD. In my 256 GB SSD drive, I have my Win 10 operating system installed and main programs like Office , Chrome  etc. installed. I use the 1 TB HDD primarily to store data.

I intend to use a Linux based VPS to host my trading strategies on AWS. So how do I create a dual boot in my existing Win 10 machine ?

Step 1: Verify UEFI

Go to the Windows Run Command (Win + R) and type in MSINFO32. This will open up the System Information. Scroll down and check the  BIOS Mode. 


Step 2: Download Ubuntu

Download the latest Ubuntu 20.04.1 LTS . The LTS stands for long-term support — which means five years, until April 2025, of free security and maintenance updates, guaranteed.
You can either download this from the main site or choose the alternative downloads site and download with the help of torrent client. 

Step 3:  Create a bootable USB drive

Lets download Rufus which we will use to create a bootable USB drive. For this have a pendrive , preferably 8GB or more. Choose this device, set the partition scheme as GPT and the Target System as UEFI

Step 4: Disk Management

Go to the Run command and type in "compmgmt.msc". No click on Disk Management. From the 1 TB HDD, create some space where we can have Ubuntu. Right Click on the chosen Disk and click "Shrink Volume". This will help to get unallocated space. In this case I have chosen 207.88 GB of unallocated space which I intend to use for Ubuntu. If this step is done, then installer will automatically install the Ubuntu OS into the unallocated space when we choose "Install Ubuntu along with Windows Boot Manager". 




Step 5: Reboot the Laptop to USB drive and start installation

Now reboot the laptop to ensure that that we are booting into the newly created USB. In the event that you have not setup the start-up options to boot into USB, then you may have to do so manually. In my Asus Laptop, I need to press the escape button as soon as the laptop starts up. And then select UEFI: SanDisk, Partition 1




Now the installation of Ubuntu will begin. But first the installer will complete the initial verification. Then choose the language in which you want Ubuntu to be installed. And continue with the steps until you come to Installation Type. Here choose "Install Ubuntu along with Windows Boot Manager".


In case we choose "Something Else", then we have to manually select the partition where we want to install Ubuntu. If we choose "Install Ubuntu alongside Windows Boot Manager", then the installer will automatically create an EFI System Partition for  the Hard Disk. If on the other hand we choose "Something Else", we need to setup the EFI System Partition manually. Check the UEFI - Ubuntu Documentation for details.

Go through the rest of the installation process . Make sure to select "Download Updates while installing Ubuntu"  and "Install third party software for graphics and Wifi hardware and additional media formats" . If you do this one thing, it will save you a lot of hassles and free you from of trouble, in the event that your machine has Nvidia Graphics Card.


It is also important to select "Configure Secure Boot" and most importantly remember the password. You will need the password at the time of the next login. This will be used for the "Perform MOK Management".

MOK stands for Machine Owner Key. When Ubuntu tries to boot with third party codecs, Nvidia Driver etc., it will be blocked by the UEFI bios.  Select Enroll MOK and follow as shown below.






Also notice that the initial boot screen has changed.



Step 6: Verify where Ubuntu was installed. 

So now, let us log on back to Windows and check the Disk Management as described in Step 4. This is the screenshot.



If you notice, the 207.88 GB that was earlier unallocated has now been split into 513 MB of EFI system partition and 207.38 GB of primary partition.

Now Install Gparted in Ubuntu. Check the SSD labelled as /dev/sdb and this is how it looks


Check of the HDD which is labelled as /dev/sda.


Step 7: Fix Linux Time and Install Grub Customizer

Your computer stores the time in a hardware clock on its motherboard. The clock keeps track of time, even when the computer is off. By default, Windows assumes the time is stored in local time, while Linux assumes the time is stored in UTC time and applies an offset. This leads to one of your operating systems showing the wrong time in a dual boot situation. To fix this, I prefer to make Linux use local time.

timedatectl set-local-rtc 1 --adjust-system-clock

To check the current settings type in:
 
timedatectl

If you see "RTC in local TZ: yes”, Linux is set to use the local time zone instead of UTC.
Prior to  version Ubuntu 20.04, we had to add a PPA to install Grub Customizer. But the good news is that Grub Customizer is now a part of the default repository. So go to the Ubuntu Software Centre, type in Grub Customizer and install it. Or if you are the terminal person, type in  sudo apt install grub-customizer . 

The advantage of installing Grub Customizer is that, in case you want to change the default OS, you can do it. Also the default time to boot into the default OS can also be changed

Now lets say that I don't want Linux Ubuntu but am just happy with my Good Old Windows. So I want to delete and do away with the dual boot. Here is how it goes.

Step 8: Delete the Existing Linux Partition

Logon to Windows once again. Open the disk manager as mentioned in step 4. From Disk 0, delete the partition Healthy (Primary Partition) with size 207.38 GB . Also delete the partition Healthy (EFI System Partition) with size 513 MB. Now try deleting the Healthy (EFI System Partition) which has a size of 513 MB . 


Step 9: Delete Ubuntu folder from EFI using Command Prompt

Now Open the command prompt in admin mode. (Type cmd in search bar, right click on command prompt and click - Run as Administrator. Then type in Diskpart . Then type in list disk . This will list the disks connected to the system.


In my case, windows is installed in Disk 1 which is the SSD. Disk 0 is the HDD. Type in select disk 0. Next type in list disk. Next type in list partition. We are going to use the system partition to remove the grub bootloader from the drive. To do this type in select partition 3 . Next type in letter=x to mount this partition temporarily. Then Type in Exit to get out of the disk manager. Then type in x:  which will change the directory. Type in DIR to list the directories. Now type in cd EFI to get to the EFI directory. Here by typing in dir we get the directory listing. Delete the folder ubuntu by typing in rd ubuntu /s

This is the list of commands used in the command prompt.

C:\WINDOWS\system32>diskpart
DISKPART> list disk
DISKPART> select disk 0
DISKPART> list partition
DISKPART> select partition 3
DISKPART> assign letter=x
DISKPART> exit
C:\WINDOWS\system32>x:
X:\>dir
X:\>cd EFI
X:\EFI>DIR
X:\EFI>rd ubuntu /s

If we don't delete the Ubuntu folder above, then when we try to boot in, we get a message as shown below: 


Restart the computer and it should boot the system into Win 10. This is the method to undo the dual boot.

Now get back to Disk Management and see if the Healthy(EFI System Partition) of size 513 MB is gone (Check Step 6: Verify where Ubuntu was installed). If so good for you. If Not, then login to the Ubuntu Live USB, open Gparted, identify this partition and delete it. You should now have a clean boot as if you never installed Ubuntu on dual boot. If however you still face any issue, create a bootable USB media to install Win 10. Load into this bootable USB and repair the Master Boot Record(MBR).

Step 10: Verify if an Ubuntu has been installed in UEFI mode

Assuming that you have decided to stick with Ubuntu, it is necessary to verify if Ubuntu was installed in UEFI mode. This is necessary when we want to install proprietary drivers like Nvidia. 

From the installed Ubuntu, open a terminal and then type the following command:

$ sudo [ -d /sys/firmware/efi ] && echo "Installed in UEFI mode" || echo "Installed in Legacy mode"

Resources for Reference

I have faced multiple issues with secure boot, particularly with Nvidia drivers. But whether you want to continue with secure boot or not, it is up to you to take a call. Take a look at these resources and discussions:

Alternatives to Dual Boot


  • Use a Virtual Machine to run on your computer. Oracle Virtual Box is a most commonly used, although Hyper-V is comes built-in with Win 10 (need Win 10 Professional or Win 10 Enterprise)

  • Use a bootable flash drive. This is something to consider of you are not using Ubuntu as frequently as Windows or vice-versa. Will require to change the boot order in BIOS settings. A point to note is that the many flash drives have faster read-write compared to the HDD's.

  • Install Win10 and Linux on an independent Drive. In this case, you can first install Win 10 on a drive and remove it. Then install Ubuntu on a separate HDD/SSD as another independent entity. Then install both these drives into your computer  and set BIOS/UEFI to default to Windows drive. This method will also ensure that you can do away with Grub altogether (I couldn't find a better alternative !!!) .... Let us say that you already have two drives like me (SSD and HDD). Let us say that Win 10 is installed on the SSD. Remove the SSD, install Ubuntu on the HDD, then put the Windows drive back and in the BIOS choose which OS you want to boot into.

No comments:

Post a Comment