Chris Xiao

DevOps & Systems Engineer

Chris Xiao

DevOps & Systems Engineer

#SwitchToLinux: How to Dual-boot

A step-by-step guide to dual-boot a Linux distro and Windows on a UEFI-based computer.

Last updated on Apr 22, 2019

title

Disclaimer

  • This tutorial is for dual-booting ONLY. If you’d like to erase Windows and use Linux as your only operating system, you don’t need this tutorial. Just follow the guides provided by your Linux distro of choice.
  • If this article seems complicated to you, you’re not alone. Dual booting can get overwhelming, and if you don’t want to deal with dual-booting, you may want to consider erasing Windows completely. Simply follow the guides provided by your Linux distro of choice.
  • The content of this tutorial has been tested and is fully functional on my machine, but I cannot guarantee that the tutorial will work for you.
  • If you follow this tutorial closely, your data should remain intact. However, there is a chance of data loss, so be sure to back up EVERYTHING on your machine to an external drive.

Before you start

Again, this tutorial is for UEFI-based systems ONLY. If you’re computer doesn’t support UEFI, this tutorial isn’t for you. This tutorial is also NOT for Apple computers.

Check if your computer is UEFI-capable

If your computer manufactured after 2012 and ships with Windows 8 (or newer) preinstalled, your computer is probably UEFI-capable.

To check if Windows is running in UEFI mode:

  • Open the Start Menu, type in msinfo32 and press Enter. System Information should appear on-screen.

System Information on Windows 10

  • Look for BIOS Mode. If it says UEFI, your system is UEFI-capable. If it says Legacy, your current Windows installation is not running in UEFI mode.

To check if Linux is running in UEFI mode:

  • Open a terminal, and type ls /sys/firmware/efi.
  • If you see No such file or directory after running this command, your system isn’t running in UEFI mode. Otherwise, you’re good to go.

If your current operating system isn’t running in UEFI mode, search online for UEFI capability for your computer (or your motherboard if you built your own PC).

If you’re sure that your computer is UEFI-capable, continue reading. Otherwise, this guide is not for you.

Get BitLocker recovery key

Even if you haven’t set up BitLocker drive encryption manually, your computer may automatically encrypt your drive during the initial setup process. Be sure to check if your Windows partition is encrypted. If so, save the recovery key in a safe place. You’ll need this to get back into Windows after installing Linux.

To check if you’re drive is BitLocker-encrypted:

  • Open This PC (or Computer), and check if there’s a padlock on the Windows partition (usually the C: drive).
  • If there is, BitLocker is enabled. Otherwise, you may skip this section.

To get BitLocker’s recovery key:

  • Open the Start Menu, type in cmd, right-click on the first result, and select Run as Administrator.
  • In the Command Prompt, type manage-bde -protectors C: -get. You’ll see something like this:

manage-bde output on Windows 10

  • Look for Numerical Password in the output, write down the 36-character recovery key after Password. Keep this in a safe place.

Pick a Linux distro

Linux is NOT difficult to use at all. There are many easy-to-use and user-friendly Linux distros out there.

For people with little to no Linux experience, you should choose a Ubuntu-based distro, because of their good software support and active community. Check out the following Ubuntu-based distros:

Linux Mint & Elementary OS & Pop!_OS

  • Linux Mint: Windows-like desktop and intuitive interface. Based on Ubuntu LTS.
  • Elementary OS: Elegant MacOS-like desktop and great application store. Based on Ubuntu LTS.
  • Pop!_OS by System76: Newer versions of system software with the popular GNOME Desktop. Based on Ubuntu LTS or non-LTS.

Since all of these distros are based on Ubuntu, you can take advantage of all the great Ubuntu resources, such as the Ubuntu Forum, Ask Ubuntu, and r/linux4noobs, when you have questions or run into issues.


Preparation

Make a bootable USB

  • Find a USB drive that’s larger than the ISO image you just downloaded. Plug it into your computer
  • Back up EVERYTHING important on it. The following steps will ERASE the USB drive.
  • Download and install Balena Etcher.
  • Open it, select the ISO image you just downloaded and the USB drive you want to write the image to. Confirm all selections are correct, then flash the image.

Balena Etcher

Make backups

Make a FULL BACKUP of your computer! Even the chance of data loss is very small, data loss is still possible. Copy everything you want to save to an external drive, and make sure EVERYTHING is present on the backup drive.

Shrink Windows partition

  • Open the Start Menu and type in diskmgmt.msc and press Enter. Disk Management should appear on-screen.
  • Find your Windows partition (usually the C: drive), right-click on it, and select Shrink Volume.
  • Enter the desired size of your new Linux partition (in MB, 1GB=1024MB) in the Enter the space to shrink in MB box, and click OK.
  • Wait for the operation to complete. It should take less than a minute.

Check SATA Mode

In your computer’s UEFI BIOS settings, change SATA Mode to AHCI. If you’ve configured storage using Intel Rapid Storage Technology (RST), configure every drive as individual drives in RST settings before doing this.

Secure Boot

TL;DR: If you decide to run a distro based on Ubuntu, RedHat or SUSE, this is OPTIONAL. If you have trouble booting your bootable USB or installed system, disable Secure Boot in your UEFI BIOS settings.

Secure Boot is a part of UEFI designed to protect against boot environment tampering. Linux distros based on Ubuntu, RedHat, or SUSE have out-of-box support for Secure Boot, but many other Linux distros don’t have full support for Secure Boot. Even if you choose a distro that supports Secure Boot, it can potentially cause issues, especially when you’re installing extra drivers or manually upgrading kernel. Therefore, you may want to disable Secure Boot to make your life easier.

Look for Secure Boot in your computer’s UEFI BIOS settings. If you don’t know how to do this, consult your computer manufacturer or motherboard manual, since different manufacturers can be different.


Install Linux

Now you’re finally ready to install Linux, but make sure Windows is fully installed first. The Windows installer assumes that Windows is your only operating system and overrides your boot configuration, but Linux installers usually let you install Linux alongside Windows just fine.

Boot to Linux USB

Boot your computer to the Linux USB you just created. Be sure to boot in UEFI mode. Press Enter when you see the Linux boot menu to boot using the default option.

Check partitioning

Open GParted from the applications menu. If you can’t find it, open a terminal and type in sudo gparted.

Once you’re in GParted, make sure your partition layout ends with unallocated space, as shown here:

Partition layout before installation

If there’s a small partition (less than 1GB) at the end of your partition table, move that partition by right-clicking on it, select Change/Move Partition. Make sure Space preceding partition is 0MB, like this:

Move recovery partition

Click OK to close the dialog, then click on the check mark on the top bar to perform this operation.

Create new partitions in the installer

NOTE: images shown in this section are from the Linux Mint 19.1 “Tessa” installer. Different distros have different installers, and the exact process may be different, but the partitioning guidelines apply to all distros.

Open the installer on the desktop, select your language and keyboard layout, connect to a network, and check the box for installing third-party software.

When you’re asked to select an installation type, choose Something else, like this:

Select “Something else” in installer

Now you’re creating new partitions for Linux. Look for a partition with type efi in the list, and remember that partition’s identifier (such as /dev/sda1). Set Device for bootloader installation to this partition.

  • Create a /boot partition

    • Select the free space at the end of the partition table. Click on the + icon in the bottom-left corner.
    • Set Size to 200 MB.
    • Select Ext4 journaling filesystem for Filesystem.
    • Set Mount point as /boot.
    • The “Create partition” dialog should look like the image below. Click OK to confirm the operation.

    "/boot" settings

  • Create an encrypted filesystem

    • Select the free space at the end of the partition table. Click on the + icon in the bottom-left corner.
    • Leave Size untouched.
    • Set Physical volume for encryption as Filesystem.
    • Set a passphrase to unlock this partition. A secure passphrase should be 20 characters or longer. DO NOT FORGET this passphrase, otherwise you won’t be able to access data on this partition.
    • The “Create partition” dialog should look like the image below. Click OK to confirm the operation.

    "/boot" settings

  • Create a / partition

    • Select the partition labeled /dev/mapper/VolumeID_crypt in the list.

    Select /dev/mapper/VolumeID_crypt

    • Click on Change in the bottom-left corner.
    • Make sure Filesystem is Ext4 journaling filesystem.
    • Set Mount point to /.
    • The “Edit partition” dialog should look like the image below. Click OK to confirm the operation.

    "/" settings

After you’ve finished, your partition table should look like this:

Partition table with encryption

Don’t encrypt system

  • Create the / partition
  • Select the free space at the end of the partition table. Click on the + icon in the bottom-left corner.
  • Leave Size untouched.
  • Select Ext4 journaling filesystem for Filesystem.
  • Set Mount point as /.
  • The “Create partition” dialog should look like the image below. Click OK to confirm the operation.

"/" settings

After you’ve finished, your partition table should look like this:

Partition table without encryption

Complete installation

Just click Install now, choose your timezone, select your keyboard layout, create a user, and the installer will automatically install Linux onto your computer. When installation finishes, reboot your computer.

If your Windows partition is BitLocker-encrypted, boot to Windows after reboot and reset BitLocker.

Reset BitLocker

Right after you installed Linux, Windows will ask for your recovery key. Once you’re at the Windows desktop, reset the BitLocker protectors:

  • Open the Start Menu, type in cmd, right-click on the first result, and select Run as Administrator.
  • In the Command Prompt, type manage-bde -protectors C: -get. You’ll see something like this:

manage-bde output on Windows 10

  • Find the TPM protector and copy its ID, including curly braces
  • Type manage-bde -protectors -delete C: -ID {XXXXX} into the Command Prompt. Replace {XXXXX} with the ID you just copied.
  • Type manage-bde -protectors -add C: -TPM

Note: if your BitLocker protector isn’t TPM, replace TPM in the steps above with the protector you see. See Microsoft’s documentation for more details.

Reboot your computer, and follow Booting to Windows to get back into Windows without the recovery key.


Booting to Linux

Linux should be your default OS, and a boot selection menu (called the GRUB Menu) should show. Press Enter to boot into the default OS, which should be Linux.

If you encrypted your Linux partition, enter the passphrase you set during installation when prompted.


Booting to Windows

Not BitLocker-encrypted

If your Windows partition is not BitLocker-encrypted, just use arrow keys select Windows Boot Manager in the GRUB Menu and press Enter to confirm. You’ll boot to Windows.

BitLocker-encrypted

Don’t use the Windows Boot Manager option in the GRUB Menu, as Windows wants your recovery key every time you do this.

Use your computer’s UEFI BIOS’s one-time boot menu (enter by pressing ESC or F12 when you see manufacturer’s logo) to boot to Windows Boot Manager. This should not require your recovery key.


Final words

Sorry about the length of this article. I understand this process is quite involved, but I’ve successfully done this a few times with different Linux distros, and I tried my best to document this process step-by-step. If you have any questions or you experience issues, just remember Google (DuckDuckGo or Startpage for the privacy-minded) is your friend.

If you need more help, many online communities, such as the Ubuntu Forum, Manjaro Forum, Ask Ubuntu, and r/linux4noobs, are friendly and willing to help you out.


CC BY-SA 4.0 Written By Human Not By AI