Dual Booting RHEL 8 with Windows

Revision as of 18:27, 9 June 2019 by Neil (Talk | contribs) (Created page with "{{#pagetitle: Dual Booting RHEL 8 with Windows }} <table border="0" cellspacing="0" width="100%"><tr> <td width="20%">[[|Previous]]<td align="center">Red Hat Enterprise Linu...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Revision as of 18:27, 9 June 2019 by Neil (Talk | contribs) (Created page with "{{#pagetitle: Dual Booting RHEL 8 with Windows }} <table border="0" cellspacing="0" width="100%"><tr> <td width="20%">[[|Previous]]<td align="center">Red Hat Enterprise Linu...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
PreviousTable of ContentsNext


You are reading a sample chapter from the Red Hat Enterprise Linux 8 (RHEL 8) Essentials book.

Purchase a full copy of Red Hat Enterprise Linux 8 (RHEL 8) Essentials in eBook ($9.99) or Print ($36.99) format

Red Hat Enterprise Linux 8 Essentials Print and eBook (ePub/PDF/Kindle) editions contain 31 chapters and over 250 pages

Buy Print Preview Book


Red Hat Enterprise Linux 8, just like most Linux distributions, will happily co-exist on a hard disk drive with just about any version of Windows up to and including Windows 10. This is a concept known as dual-booting. Essentially, when you power up the system, you will be presented with a menu providing the option to boot either your RHEL 8 installation 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 RHEL 8 regardless of whether your Windows partition was formatted using NTFS, FAT16 or FAT32.

This installation method involves shrinking the size of the existing Windows partitions and then installing RHEL 8 into the reclaimed space. This chapter will assume that RHEL 8 is being installed on a system currently running Windows 10.

Partition Resizing

In order to accommodate RHEL on a disk drive that already contains a Windows installation, the first step involves shrinking the Windows partition to make some room. The recommended course of action is to use the Windows Disk Management interface to reduce the size of the partition before attempting to install RHEL 8.

Windows 10, right-click on the Start menu and select Disk Management from the resulting menu as highlighted in Figure 4-1:


Rhel 8 win 10 disk management start.png


Figure 1-1

Once loaded, the Disk Management tool will display a graphical representation of the disk drives detected on the system:


Rhel 8 win 10 disk management main.png


Figure 1-2

Right-click on the partition you wish to reduce in size and select Shrink Volume... from the popup menu. The tool will calculate the maximum amount by which the volume size can be reduced without data loss (a process that can take several minutes depending on the overall size of the partition). Once this analysis is complete, a dialog similar to the one in Figure 4-3 below will appear:


Rhel 8 win 10 disk management shrink.png


Figure 1-3

Enter the new target size for the partition into the Total size after shrink in MB field and click on the Shrink button to proceed. Once the resizing operation is complete, reboot using the RHEL 8 installation media (as outlined in Installing RHEL 8 on a Clean Disk Drive) and proceed with the installation making use of the new free space.

Editing the RHEL 8 Boot Menu

Once installation of RHEL onto the disk is complete and the system has restarted, the standard RHEL boot menu will appear:


Rhel 8 dual boot no windows.png


Figure 1-4

At this point, the boot menu only provides the option to boot the RHEL 8 system. Clearly an option also needs to be added so that the Windows system is still accessible. These steps will need to be taken from within the RHEL 8 system, so start the system and log in as root.

The first step is to identify the Windows boot partition on the disk drive using the fdisk command as follows:

# fdisk -l
.
.
Device     Boot    Start       End  Sectors  Size Id Type
/dev/sda1  *        2048   1126399  1124352  549M  7 HPFS/NTFS/exFAT
/dev/sda2        1126400  53655551 52529152   25G  7 HPFS/NTFS/exFAT
/dev/sda3       53655552  55752703  2097152    1G 83 Linux
/dev/sda4       55752704 104857599 49104896 23.4G  5 Extended
/dev/sda5       55754752 104857599 49102848 23.4G 8e Linux LVM

In the above output /dev/sda3 through to /dev/sda5 are clearly the RHEL 8 partitions. The smaller /dev/sda1 partition is the Windows system partition, leaving /dev/sda2 as the Windows boot partition.

The RHEL 8 boot system works using partition indexes where the first partition is partition 0, the second is partition 1 and so on. As such, the Windows boot partition from the point of view of the boot menu is located on hard disk 0 at partition index location 1 and is defined in the boot configuration as “hd0,1”.

The boot menu configuration settings are stored in the /boot/grub2/grub.cfg file which is generated using the grub2-mkconfig tool based on the content of the configuration files located in the /etc/grub.d directory. To add the Windows boot option to the configuration, edit the /etc/grub.d/40_custom file which should read as follows:

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the ‘exec tail’ line above.

Edit the file to add the following entry to the end of the 40_custom file:

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

Save the file and generate the boot menu as follows:

# grub2-mkconfig --output=/boot/grub2/grub.cfg
Generating grub configuration file ...
done

On the next reboot, Windows will now be included as a boot option as shown in Figure 4-5:


Rhel 8 dual boot windows added.png


Figure 1-5


Accessing the Windows Partition from RHEL 8

When running RHEL 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. Before doing so, however, some additional packages need to be installed on the system. First the fuse kernel module needs to be downloaded and installed:

# dnf install fuse
# modprobe fuse

Next, the EPEL) repository needs to be added to the system as follows:

# dnf install wget
# wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# rpm -ivh epel-release-latest-7.noarch.rpm

With the EPEL repository added, the driver can now be installed:

# dnf install fuse-ntfs-3g

Once the requisite packages are installed, the next step 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/windows

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

# fdisk -l
.
.
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      102400    7  HPFS/NTFS
/dev/sda2              13        1400    11141120    7  HPFS/NTFS
/dev/sda3            1400        1464      512000   83  Linux
/dev/sda4            1464        2611     9214976    5  Extended
/dev/sda5            1464        2611     9213952   8e  Linux LVM

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

mount –t ntfs-3g /dev/sda2 /mnt/windows

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

# ls /mnt/win
‘$Recycle.Bin’             ProgramData            swapfile.sys
‘Documents and Settings’  ‘Program Files’        ‘System Volume Information’
 pagefile.sys              ‘Program Files (x86)’   Users
 PerfLogs                  Recovery               Windows

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

/dev/sda2 /mnt/windows ntfs defaults 0 0

To unmount the Windows file system at any time:

umount /mnt/windows

Summary

RHEL 8 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 RHEL 8 before performing the installation. Once RHEL has been installed, the boot menu configuration must be modified to include the option to boot from Windows. To access the Windows filesystem from within RHEL, the Fuse NTFS driver needs to be installed and used to mount the Windows partitions.