Dual Boot Ubuntu and Windows 
Tags: beginners, ubuntu, tutorial, opensource
Published: 2021-10-19 13:10:30


## How to Dual Boot - Ubuntu and Windows?

This is a brief tutorial on what all to do to get a successful dual boot capable system. Also, I'll be putting up some fixes for issues I've faced after installing Ubuntu (you're not likely to have any issues unless you've my same configuration).

Here, I'll be discussing about systems with UEFI boot and GPT partioning systems. I've a single disk system and is not encrypted with bitlocker.

## Keep a backup of Windows system

I'd always advice you to start with backing up your data onto a storage device/cloud. Keeping a windows recovery disk ready can also avoid unncessary panic attacks if something goes wrong. 

## Download Ubuntu 

You can download Ubuntu installation iso file from the official site of [Ubuntu](https://ubuntu.com/download/desktop). The file size is of 2.86 gb so if you have an unsteady internet connection, you can also download it using [torrent](https://ubuntu.com/download/alternative-downloads).

## Create a bootable usb drive

For doing this, I'll suggest you to use a free software like [Rufus](https://rufus.ie/en/). Download it from its official site and run it. 

![screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ql0is03udv79ptg94qf.png)

<i> You can refer the attached screenshots for guidance. </i>

- Select the iso file from its location, select partitioning scheme as GPT and target system UEFI (non CSMI) and click start.

## Assigning partition for Ubuntu

Go to Disk Management and select a drive with enough space for a partition. You can choose the partition size as per your needs. I recommend keeping 50gb - 80gb.
For an ideal storage amount, 
30 gb for root + twice the size of your ram as swap area ( if ram is greater than 4gb, keep atleast the same size) + 20 gb for home . This will come around 60gb or above. 


## Boot from Ubuntu Usb Drive

Now it's time that you boot from the Ubuntu drive you've made using Rufus. 
- For this, go to the search bar and type in uefi. 
- Select "Change Advanced Startup Options"
- Under the Advanced Startup, Select Restart now.
- Select "Use a device" and then the name of your connected usb drive (can also be displayed as EFI USB Drive).
-Wait till the system restarts and shows up a black screen with multiple options - you may select **Ubuntu/Install Ubuntu** from the list.


## Dual boot installation of Ubuntu

These are the most important steps in this procedure. 
 
 - Select the language and choose normal installation ( It's better you keep the download updates and install third party software options unchecked) and continue.
 - Here, I ask you to proceed with the "Something Else" option so that you can manually assign the storage for root, swap and home.
 - Select the free space option and click on '+' icon. 
 - Leave the type and location of partion as **primary** and **beginning of this space** respectively in all the steps. 
 - For root
      - Enter the storage you wish to assign for root (30gb seems a good amount).
     - select use as "Ext4 journaling file system" and mount point as "/" ( **/** - means root directory) and continue.
  - For swap area
       - Enter the storage you wish to assign for swap area (twice the amount of your ram if ram less than 8gb else keep the same size as of your ram).
       - select use as "swap area" and then continue.
  - For home
      - assign rest of the free space for home.
      - select use as "Ext4 journaling file system" and mount point as "/home" and continue.
      
      Now you can click on Install now. Select a timezone and fill up the required credentials like username, computer's name and password. Continue and your installation takes place. It may take some time. After installation, a dialogue box appears and you can click on the **Restart Now** option. 

It's time that your system will ask you to unmount the usb drive connected. So you can remove it. 

A grub screen appears with options including **Ubuntu** and **Windows Boot Manager**. You can select the OS you want to use when the system boots. 

# Some Fixes

These are some fixes for issues I've encountered. It's not likely you'll have any of these but if at all something like this comes up, you can try this out. 

## Different time in Ubuntu and Windows

Our system has two clocks: one is the hardware clock and the other is system clock.  Interference of this two in different OS'es brings up this problem. 

By default, Windows interprets the time in hardware clock as local time and Linux assumes the time in hardware clock as UTC. 

We can solve this problem by making Linux use local time as hardware clock. 

The steps are:
   - Go into your terminal (Ctrl+Alt+T)

    - Type in the following command and enter.

```bash
  timedatectl set-local-rtc 1
```

  Now try logging in both the OS and you'll find the time to be same and correct. 
 
## No WiFi Support 

This is for people with **Mediatek MT7921** or **Mediatek MT7961** Wi-Fi lan card (which comes in some of the latest laptops). 
Linux kernel from version 5.12 only has support for the drivers of this WiFi card. So you're required to update the version of Linux kernel with the help of the following commands. 

- First check the current kernel version:

```bash
uname  -r

5.11.0-36-generic
```
Here, our driver is of 5.11 but we need atleast 5.12 kernel to support the WiFi version. So we're updating the kernel.

- To download and install the ubuntu-mainline-kernel.sh script:

```bash

wget https://raw.githubusercontent.com/pimlie/ubuntu-mainline-kernel.sh/master/ubuntu-mainline-kernel.sh

sudo  install  ubuntu-mainline-kernel.sh /usr/local/bin/
```
- To install the kernel version v5.12.11
 
 You can install any of the latest version kernels but I recommend you to go with this version.

```bash
sudo ubuntu-mainline-kernel.sh -i 5.12.11
```
After completion of this you can restart your system in the updated kernel. 

### Invalid signature - Ubuntu in Grub Screen

This mostly happens when we manually update the kernel like in the above case. 
To overcome this you can go into your BIOS settings and turn off **secure boot**. Now boot in the updated kernel version.

- Install the firware files

```bash
sudo apt install firmware-misc-nonfree
```



## No Brightness Control

This has been reported with the my same laptop models - Lenovo Legion-5-Pro-16ACH6H and here's what worked for me. 

- Go to your BIOS settings and keep the graphics type as **Dynamic** (keep integrated graphics over discrete)
- Make some tweaks in the grub like given below: 
   - Open terminal

```bash
  sudo nano /etc/default/grub
```
- Edit value like below

```bash
  GRUB_CMDLINE_LINUX_DEFAULT="quiet splash amdgpu.backlight=0"
```
```bash
  sudo update-grub
```
- Reboot the laptop and you'll find the brightness slider available.

## Acknowledgement 

The fixes given above are all from so many fellow members out here in the Internet helping each other. So I'll leave the links to all those posts so you can check it out and leave your comments there. 

[1. Wrong Time Displayed in Windows-Linux Dual Boot Setup? Here’s How to Fix it ](https://itsfoss.com/wrong-time-dual-boot/)

[2. How to install driver for Wi-Fi Mediatek MT7921 and Mediatek MT7961 in Linux](https://miloserdov.org/?p=6899)

[3. Lenovo legion 5 Ubuntu 20.04 FINAL GUIDE: DREAM LAPTOP!](https://www.reddit.com/r/linux_gaming/comments/mmptqi/lenovo_legion_5_ubuntu_2004_final_guide_dream/)