Allocating Windows Disk Partitions to RHEL 8

Revision as of 18:42, 9 June 2019 by Neil (Talk | contribs)

Revision as of 18:42, 9 June 2019 by Neil (Talk | contribs)

PreviousTable of ContentsNext
Dual Booting RHEL 8 with WindowsA Guided Tour of the RHEL 8 GNOME 3 Desktop


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


In the previous chapter we looked at how to install Red Hat Enterprise Linux 8 on the same disk as Windows. This so called “dual boot” configuration allows the user to have both operating systems installed on a single disk drive with the option to boot one or the other when the system is powered on.

This chapter is intended for users who have decided they like RHEL 8 enough to delete Windows entirely from the disk, and use the resulting space for Linux. In the following sections we will work through this process step by step.

Unmounting the Windows Partition

If the steps in the Dual Booting RHEL 8 with Windows chapter were followed to mount the Windows partition from within RHEL 8, steps should be taken to unmount the partition before continuing with this chapter. Assuming that the Windows partition was mounted as /mnt/windows, it can be unmounted as follows:

# umount /mnt/windows

The /etc/fstab file should also be edited to remove the /mnt/windows auto-mount if it was previously added.

Deleting the Windows Partitions from the Disk

The first step in freeing up the Windows partition for use by RHEL is to delete that partition. Before doing so, however, it is imperative that any data you need to keep is backed up from both the Windows and RHEL partitions. Having done that, it is safe to proceed with this chapter.

In order to remove the Windows partitions we first need to identify the disk on which they reside using the fdisk tool:

# fdisk -l
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors
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: dos
Disk identifier: 0xe3673009
 
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 example output the system contains one physical disk drive referenced by device name /dev/sda. On that disk drive are five partitions accessed via the device names /dev/sda1 through /dev/sda5 respectively. Based on the values in the System column, there are two NTFS partitions. The first is the Windows system partition while the second, much larger, NTFS partition is the Windows boot partition containing the Windows operating system and user data.

To remove the partitions, start the fdisk tool using the device name of the disk containing the partition (/dev/sda in this instance) and follow the instructions to once again display the partition and sector information:

# fdisk /dev/sda
 
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
 
Command (m for help): p
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors
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: dos
Disk identifier: 0xe3673009
 
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
 
Command (m for help):

Currently, the Windows system partition is listed as being the bootable partition. Since we will be deleting this partition, the Linux boot partition needs to be marked as bootable. In the above configuration, this is represented by /dev/sda3. Remaining within the fdisk tool, make this the bootable partition as follows:

Command (m for help): a
Partition number (1,3-5, default 5): 3
The bootable flag on partition 3 is enabled now.

Before proceeding, make a note of the start and end addresses of the partitions we will be deleting (in other words the start of /dev/sda1 and the end of /dev/sda2).

At the command prompt, delete the Windows partitions (these being partitions 1 and 2 on our example system):

Command (m for help): d
Partition number (1-5, default 5): 1
 
Partition 1 has been deleted.
 
Command (m for help): d 
Partition number (2-5, default 5): 2
 
Partition 2 has been deleted.

Now that we have deleted the Windows partitions we need to create the new RHEL partition in the vacated disk space. The partition number must match the number of the partition removed (in this case 2) and is going to be a primary partition. It will also be necessary to enter the Start and End sectors of the partition exactly as reported for the old partition (fdisk will typically offer the correct values by default, though it is wise to double check). If you are prompted to remove the NTFS signature, enter Y:

Command (m for help): n
Partition type
   p   primary (1 primary, 1 extended, 2 free)
   l   logical (numbered from 5)
Select (default p): p
Partition number (1,2, default 1): 1
First sector (2048-104857599, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-53655551, default 53655551): 
 
Created a new partition 1 of type 'Linux' and of size 25.6 GiB.
Partition #1 contains a ntfs signature.
 
Do you want to remove the signature? [Y]es/[N]o: y
 
The signature will be removed by a write command.

Having made these changes the next step is to check that the settings are correct (taking this opportunity to double check that the Linux boot partition is bootable):

Command (m for help): p
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors
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: dos
Disk identifier: 0xe3673009
 
Device     Boot    Start       End  Sectors  Size Id Type
/dev/sda1           2048  53655551 53653504 25.6G 83 Linux
/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
 
Filesystem/RAID signature on partition 1 will be wiped.

To commit the changes we now need to write the new partition information to disk and quit from the fdisk tool:

Command (m for help): w
The partition table has been altered.
Syncing disks.

Formatting the Unallocated Disk Partition

In order to make the new partition suitable for use by RHEL 8, it needs to have a file system created on it. The default file system type for the current release of RHEL is XFS and will be covered in greater detail in the chapter entitled “Adding a New Disk Drive to a RHEL 8 System”. Creation of the file system is performed using the mkfs.xfs command as follows:

# mkfs.xfs -f /dev/sda1
meta-data=/dev/sda1              isize=512    agcount=4, agsize=1676672 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=6706688, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=3274, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

Mounting the New Partition

Next, we need to mount the new partition. In this example we will mount it in a directory named /data. You are free, however, to mount the new partition using any valid mount point you desire or to use it as part of a logical volume (details of which are covered in the chapter entitled Adding a New Disk to a RHEL 8 Volume Group and Logical Volume). First we need to create the directory to act as the mount point:

# mkdir /data

Secondly, we need to edit the mount table in /etc/fstab so that the partition is automatically mounted each time the system starts. At the bottom of the /etc/fstab file, add the following line to mount the new partition (modifying the /dev/sda1 device to match your environment):

/dev/sda1 /data xfs  defaults 0 0

Finally, we can manually mount the new partition (note that on subsequent reboots this will not be necessary as the partition will automount as a result of the setting we added to the /etc/fstab file above).

# mount /data

To check the partition, run the following command to display the available space:

# df -h /data
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        26G  215M   26G   1% /data

Editing the Boot Menu

The next step is to modify the RHEL boot menu. Since this was originally a dual boot system, the menu is configured to provide the option of booting either Windows or RHEL. Now that the Windows partition is gone, we need to remove this boot option. Start by editing the /etc/grub.d/40_custom file and removing the Windows menu entry:

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

Save the file and use the grub2-mkconfig tool to generate the /boot/grub2/grub.cfg file as follows:

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

Next time the system restarts, the Windows 10 option will no longer be provided by the boot menu.

Summary

The Windows partitions in a dual boot configuration can be removed at any time to free up space for a RHEL system by identifying which partitions belong to Windows and then deleting them using the fdisk tool. Once deleted, the unallocated space can be used to create a new filesystem and mounted to make it available to the RHEL system. The final task is to remove the Windows option from the boot menu configuration.


PreviousTable of ContentsNext
Dual Booting RHEL 8 with WindowsA Guided Tour of the RHEL 8 GNOME 3 Desktop


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