Allocating Windows Disk Partitions to RHEL 9

In the previous chapter, we looked at installing Red Hat Enterprise Linux 9 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 9 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 9 with Windows chapter were followed to mount the Windows partition from within RHEL 9, 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:

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, any data you need to keep must be backed up from both the Windows and RHEL partitions. Having done that, it is safe to proceed with this chapter.

 

You are reading a sample chapter from Red Hat Enterprise Linux 9 Essentials. Buy the full book now in eBook or Print format.

Includes 34 chapters and 290 pages. Learn more.

Preview  Buy eBook Buy Print

 

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

In the above example output, the system contains one physical disk drive referenced by device name /dev/nvme0n1. On that disk drive are six partitions accessed via the device names /dev/ nvme0n1p1 through /dev/nvme0n1p6, respectively. Based on the values in the Types column, three Windows-related partitions exist. The first is the Windows system partition, while the second, much larger, partition is the Windows boot partition containing the Windows operating system and user data, followed by the Windows recovery partition.

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

Before proceeding, note the start and end addresses of the partitions we will be deleting (in other words, the start of /dev/nvme0n1p2 and the sector before the start of /dev/nvme0n1p5).

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

 

You are reading a sample chapter from Red Hat Enterprise Linux 9 Essentials. Buy the full book now in eBook or Print format.

Includes 34 chapters and 290 pages. Learn more.

Preview  Buy eBook Buy Print

 

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 first partition removed (in this case, 2). It will also be necessary to enter the Start and End sectors of the partition precisely 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:

Having made these changes, the next step is to check that the settings are correct:

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

Formatting the Unallocated Disk Partition

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

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 9 Volume Group and Logical Volume). First, we need to create the directory to act as the mount point:

 

You are reading a sample chapter from Red Hat Enterprise Linux 9 Essentials. Buy the full book now in eBook or Print format.

Includes 34 chapters and 290 pages. Learn more.

Preview  Buy eBook Buy Print

 

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/nvme0n1p2 device to match your environment):

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

Allocating Windows Disk Partitions to RHEL 9 To check the partition, run the following command to display the available space:

Summary

The Windows partitions in a dual boot configuration can be removed anytime to free up space for an RHEL system by identifying which partitions belong to Windows and then deleting them. 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.


Categories