Dual Booting Ubuntu 22.04 with Windows

Ubuntu, just like most Linux distributions, will happily co-exist on a hard disk drive with just about any version of Windows. This is a concept known as dual-booting. Essentially, when you power up your PC, you will be presented with a menu providing the option to boot either Ubuntu or Windows. Obviously, you can only run one operating system at a time, but it is worth noting that the files on the Windows partition of your disk drive will be available to you from Ubuntu regardless of whether your Windows partition was formatted using NTFS, FAT16 or FAT32.

During the installation process, the Ubuntu installer will detect the Windows installation on the drive and provide the option of deleting it and using the entire disk for Ubuntu or sharing the disk with Windows. In the latter case, you will be able to specify the percentage of the disk to be used for Ubuntu.

According to the Ubuntu documentation, a minimum of 25 GB of disk space is required for a full Ubuntu Desktop Edition installation and more space to store any files you may subsequently create. Once the disk space for Ubuntu has been selected, the installer will resize the Windows partition (without destroying any data) and use the remainder of the disk for Ubuntu.

This chapter will demonstrate how to set up a dual boot system with Ubuntu and Windows 10, change the system that boots by default when the computer system is powered on, and outline how to access files located on the Windows partition of the disk from within Ubuntu.

Within this chapter, the assumption is made that the steps outlined in the previous chapter have been followed to create a bootable Ubuntu installation USB drive using the Ubuntu Desktop installation image and that the system has been configured to boot from the USB drive when started.


You are reading a sample chapter from Ubuntu 22.04 Essentials. Buy the full book now in eBook ($24.99) format. Includes 36 chapters. Learn more.

Preview  Buy eBook 


Beginning the Ubuntu Installation

To start the installation, insert the Ubuntu USB drive and reboot your computer system. If the system loads Windows again, you will need to change the boot order in your system settings. Details on how to do this will be system specific and were covered briefly in the previous chapter.

Once Ubuntu has loaded, you will be presented with the screen shown in Figure 4-1.

Figure 4-1

Begin the installation by clicking on the Install Ubuntu button and wait for the initial screen of the installer to appear, as shown in Figure 4-2:

Figure 4-2

Either select your keyboard layout or, if you are unsure, click on the Detect Keyboard Layout button to work through some steps to identify your keyboard before clicking on Continue. On the next screen, choose whether to perform the Normal or Minimal installation:

Figure 4-3

Select the Normal option if you have plenty of disk space and want to explore the main applications and utilities included with Ubuntu without having to manually install them later, otherwise use the Minimal option.


You are reading a sample chapter from Ubuntu 22.04 Essentials. Buy the full book now in eBook ($24.99) format. Includes 36 chapters. Learn more.

Preview  Buy eBook 


The option is also available to update the software packages that comprise the Ubuntu distribution during the installation. If this option is selected and the system is connected to the internet, the installer will download any updates issued since the Ubuntu installation image was released and applies them to the system during installation. If you choose not to perform this update during the installation process, these updates may still be applied at any time after the installation completes. A second option provides the choice of whether to install 3rd party non-open source software to support specific hardware devices and the playback of proprietary media files on the system. Unless you prefer to avoid using non-open source software, use of this option is recommended.

Having made appropriate selections, click the Continue button to proceed to the disk allocation screen. At this point, the installer will have detected the presence of an existing Windows operating system on the target disk drive and will provide a number of options in terms of how the disk should be used to accommodate the Ubuntu installation:

Figure 4-4

Given that it is our intention to configure a dual boot system, the option to Install Ubuntu alongside Windows Boot Manager is the desired choice. With this option selected, click the Continue button to proceed. The subsequent screen allows the amount of disk space allocated to each operating system (in this case, Windows and Ubuntu) to be configured:

Figure 4-5

At this point it is necessary to decide how much of your Windows partition you wish to donate to the Ubuntu installation. Move the slider (positioned between the Windows and Ubuntu partitions in the diagram) until the Ubuntu partition allocation is a size you are comfortable with. At least 25GB of space should be made available for a full Ubuntu Desktop installation.

When you have selected the size of the Ubuntu partition, click the Install Now button to proceed with the installation. When the warning dialogs appears read them carefully and click Continue if you are sure you wish to proceed:


You are reading a sample chapter from Ubuntu 22.04 Essentials. Buy the full book now in eBook ($24.99) format. Includes 36 chapters. Learn more.

Preview  Buy eBook 


Figure 4-6

While the installation is in progress, the installer will ask for information about your geographical location in order to configure time zone settings:

Figure 4-7

Next, the installer will ask you to provide a username and password for the first account on the system:

Figure 4-8

The option is also provided to dictate whether the password must be specified each time the user wishes to log into the system. By default, each time Ubuntu starts, a login screen will be presented seeking username and password credentials. If you are the sole user of the system and would like to bypass this screen and be logged in automatically each time the system boots, be sure to set the Log in automatically checkbox before proceeding.

Once all the questions have been answered, the installer will simply proceed with the installation. Depending on the speed of your system and whether or not you opted to download updates during the installation, this process can take some time. For a more detailed view of the steps being performed by the installer, click on the status title located above the progress bar:

Figure 4-9

When the installation is complete, a dialog will appear to inform you the system is ready to be restarted:


You are reading a sample chapter from Ubuntu 22.04 Essentials. Buy the full book now in eBook ($24.99) format. Includes 36 chapters. Learn more.

Preview  Buy eBook 


Figure 4-10

When you are ready to reboot, press the Restart Now button. The installer may prompt you to remove the installation media, and the system will take a few moments to shut down. At this point, remove the USB flash drive and press the Enter key to proceed.

Booting Ubuntu for the First Time

When the system reboots, a screen similar to the one illustrated below will appear, providing the option to boot either Windows or Ubuntu:

Figure 4-11

Press Enter to boot Ubuntu. If you wish to boot Windows, use the keyboard arrow keys to select the Windows Boot Manager option. If you choose to boot Ubuntu, the operating system will load, and the Ubuntu login screen will appear (unless the automatic login option was selected). Enter the user name and password you set up during the installation process, and you will be logged into the Ubuntu Desktop environment.

Changing the Default Boot Option

When the system starts, the boot options screen will appear, and wait 10 seconds for the user to make an operating system choice. If no selection has been made before the timeout elapses, the default operating system will be started. On a newly configured system, the default operating system will be the standard Ubuntu image. This default can, however, be changed from within Ubuntu.

A range of boot configuration options (including the 10-second timeout and the boot settings outlined in Installing Ubuntu 22.04 on a Clean Disk Drive) are declared in the /etc/default/grub file, which reads as follows on a new installation:


You are reading a sample chapter from Ubuntu 22.04 Essentials. Buy the full book now in eBook ($24.99) format. Includes 36 chapters. Learn more.

Preview  Buy eBook 


GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX=""Code language: plaintext (plaintext)

The first step in changing the default boot system is to declare the GRUB_SAVEDEFAULT setting within this file and to change the GRUB_DEFAULT setting to saved:

.Code language: plaintext (plaintext)

This setting allows a new default value to be saved within the boot configuration. Next, run the grub-set-default command to change the default setting using a numbering system that counts the first option as 0. For example, if the Windows 10 option is position 5 in the menu, the command to make Windows 10 the default boot option would read as follows:

# grub-set-default 4Code language: plaintext (plaintext)

Check that the new setting has taken effect by running the following command:

# grub-editenv list 
saved_entry=4Code language: plaintext (plaintext)

Note that the saved_entry value is now set to 4. After changing the default, regenerate the boot configuration file as follows:

# grub-mkconfig --output=/boot/grub/grub.cfgCode language: plaintext (plaintext)

Reboot the system and verify that the boot menu defaults to the Windows 10 option and that Windows loads after the timeout expires.


You are reading a sample chapter from Ubuntu 22.04 Essentials. Buy the full book now in eBook ($24.99) format. Includes 36 chapters. Learn more.

Preview  Buy eBook 


Accessing the Windows Partition from the Command-line

When running Ubuntu in a dual boot configuration, it is still possible to access files located on the Windows partition. This can be achieved by manually mounting the partition from the command line or from the desktop using the Disks (gnome-disks) graphical utility.

When working from the command line, the first step in this process is to create a directory to use as the mount point for our Windows partition. In this example, we will create a directory named /mnt/windows:

# mkdir /mnt/windowsCode language: plaintext (plaintext)

In order to identify the device name that has been assigned to the Windows partition, use the fdisk command as follows:

# fdisk -l
Disk /dev/nvme0n1: 64 GiB, 68719476736 bytes, 134217728 sectors
Disk model: VMware Virtual NVMe Disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: F0D04B58-29F5-4B6B-B10F-07295BEF9AAC

Device             Start       End  Sectors  Size Type
/dev/nvme0n1p1      2048    206847   204800  100M EFI System
/dev/nvme0n1p2    206848    239615    32768   16M Microsoft reserved
/dev/nvme0n1p3    239616  80184560 79944945 38.1G Microsoft basic data
/dev/nvme0n1p4 132833280 134213631  1380352  674M Windows recovery environment
/dev/nvme0n1p5  80185344 132833279 52647936 25.1G Linux filesystem
.Code language: plaintext (plaintext)

In the above output, the main Windows partition containing the files we need access to is represented by /dev/nvme0n1p3. Next, we need to run the mount command (assuming the Windows partition is /dev/nvme0n1p3) as follows:

# mount /dev/nvme0n1p3 /mnt/windowsCode language: plaintext (plaintext)

Check that the mount was successful by listing the contents of the top-level directory of the mount point:


You are reading a sample chapter from Ubuntu 22.04 Essentials. Buy the full book now in eBook ($24.99) format. Includes 36 chapters. Learn more.

Preview  Buy eBook 


# ls /mnt/windows
'$Recycle.Bin'             pagefile.sys           swapfile.sys
'$WinREAgent'              PerfLogs              'System Volume Information'
'Documents and Settings'   ProgramData            Users
 DumpStack.log            'Program Files'         Windows
 DumpStack.log.tmp        'Program Files (x86)'
 OneDriveTemp              RecoveryCode language: PHP (php)

To automate the mount each time the system is booted, simply add the appropriate mount line to the /etc/fstab file:

/dev/nvme0n1p3 /mnt/windows ntfs defaults 0 0 Code language: plaintext (plaintext)

To unmount the Windows file system at any time:

# umount /mnt/windowsCode language: plaintext (plaintext)

Accessing the Windows Partition from the Desktop

The first step in mounting a partition using the desktop environment is to launch the disks utility. With the desktop loaded, right-click on the desktop background and select Open Terminal from the resulting menu. Within the terminal window, gain root privileges before launching the Disks utility as follows:

$ gnome-disksCode language: plaintext (plaintext)

Once the disks tool has launched, a window similar to that shown in Figure 4-12 will appear:

Figure 4-12

To view information about a partition, select it from the graphical representation in the Volumes section of the dialog. In the above example, the Windows system partition is selected and highlighted. To mount the partition so that the contents can be accessed from within Ubuntu, select the partition and click on the options button indicated in Figure 4-13 to display the menu:


You are reading a sample chapter from Ubuntu 22.04 Essentials. Buy the full book now in eBook ($24.99) format. Includes 36 chapters. Learn more.

Preview  Buy eBook 


Figure 4-13

From the menu, select Edit Mount Options… to display the dialog shown in Figure 4-14. Turn off the User Session Defaults switch and make sure that Show in user interface option is enabled. Within the Mount Point text field, change the path to /mnt/windows. If the partition needs to be automatically mounted each time the system reboots, also enable the Mount at system startup option:

Figure 4-14

With the changes made, click on the OK button to return to the main dialog. To mount the partition, simply click on the mount button highlighted in Figure 4-15 below:

Figure 4-15

Once the partition is mounted, exit from gnome-disks and note that an icon for the volume has appeared in the dock as shown in Figure 4-16 (note that if the Show in user interface option has been disabled, this icon would not be present):

Figure 4-16

Double click on the icon to browse the partition using the Files tool:

Figure 4-17


You are reading a sample chapter from Ubuntu 22.04 Essentials. Buy the full book now in eBook ($24.99) format. Includes 36 chapters. Learn more.

Preview  Buy eBook 


To unmount the partition, click on the mount button (which will have changed to a stop button), as shown in Figure 4-15 above.


Ubuntu can safely co-exist on the same disk drive as a Windows operating system by creating a dual boot environment. This involves shrinking the amount of space occupied by the Windows system to make room for Ubuntu during the installation. Once Ubuntu has been installed, the boot menu configuration can be modified to change the default operating system. The Windows partition on the disk drive may be accessed from Ubuntu either via the command line or using the Disks desktop utility.