Changes

Jump to: navigation, search

Dual Booting RHEL with Windows

8,623 bytes added, 18:27, 9 June 2019
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..."
{{#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 Linux Essentials|Table of Contents]]<td width="20%" align="right">[[Next]]</td>
<tr>
<td width="20%"><td align="center"><td width="20%" align="right"></td>
</table>
<hr>


<htmlet>rhel8</htmlet>


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:


[[File: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:


[[File: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:


[[File: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 on a Clean Disk Drive|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:


[[File: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:

<pre>
# 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
</pre>

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:

<pre>
#!/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.
</pre>

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

<pre>
menuentry &quot;Windows 10&quot; {
set root=(hd0,1)
chainloader +1
}
</pre>

Save the file and generate the boot menu as follows:

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

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


[[File: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:

<pre>
# dnf install fuse
# modprobe fuse
</pre>

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

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

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

<pre>
# dnf install fuse-ntfs-3g
</pre>

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'':

<pre>
# mkdir /mnt/windows
</pre>

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

<pre>
# 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
</pre>

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:

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

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

<pre>
# 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
</pre>

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

<pre>
/dev/sda2 /mnt/windows ntfs defaults 0 0
</pre>

To unmount the Windows file system at any time:

<pre>
umount /mnt/windows
</pre>

== 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.

Navigation menu