In the previous chapter, we looked at installing Rocky 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 Rocky Linux 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 Rocky Linux 9 with Windows chapter were followed to mount the Windows partition from within Rocky Linux 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:
# umount /mnt/windows
Code language: Shell Session (shell)
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 Rocky 9 is to delete that partition. Before doing so, however, any data you need to keep must be backed up from both the Windows and Rocky 9 partitions. Having done that, it is safe to proceed with this chapter.
You are reading a sample chapter from Rocky Linux 9 Essentials. Buy the full book now in eBook or Print format.
Full book includes 34 chapters and 290 pages. Learn more. |
To remove the Windows partitions, we first need to identify the disk on which they reside using the fdisk tool:
# 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: 7A38CD86-091E-4781-BFB0-928FD383C935
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 49362943 49123328 23.4G Microsoft basic data
/dev/nvme0n1p4 132933632 134213631 1280000 625M Windows recovery environment
/dev/nvme0n1p5 49362944 51460095 2097152 1G Linux filesystem
/dev/nvme0n1p6 51460096 132933631 81473536 38.8G Linux LVM
Code language: plaintext (plaintext)
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:
# fdisk /dev/nvme0n1
Welcome to fdisk (util-linux 2.37.4).
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/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: 7A38CD86-091E-4781-BFB0-928FD383C935
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 49362943 49123328 23.4G Microsoft basic data
/dev/nvme0n1p4 132933632 134213631 1280000 625M Windows recovery environment
/dev/nvme0n1p5 49362944 51460095 2097152 1G Linux filesystem
/dev/nvme0n1p6 51460096 132933631 81473536 38.8G Linux LVM
Partition table entries are not in disk order.
Command (m for help):
Code language: plaintext (plaintext)
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 Rocky Linux 9 Essentials. Buy the full book now in eBook or Print format.
Full book includes 34 chapters and 290 pages. Learn more. |
Command (m for help): d
Partition number (1-6, default 6): 2
Partition 2 has been deleted.
Command (m for help): d
Partition number (1,3-6, default 6): 3
Partition 3 has been deleted.
Command (m for help): d
Partition number (1,4-6, default 6): 4
Partition 4 has been deleted.
Code language: plaintext (plaintext)
Now that we have deleted the Windows partitions, we must create the new Rocky 9 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:
Command (m for help): n
Partition number (2-4,7-128, default 2): 2
First sector (206848-134217694, default 206848):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (206848-49362943, default 49362943):
Created a new partition 2 of type 'Linux filesystem' and of size 23.4 GiB.
Command (m for help):
Code language: plaintext (plaintext)
Having made these changes, the next step is to check that the settings are correct:
Command (m for help): p
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: 7A38CD86-091E-4781-BFB0-928FD383C935
Device Start End Sectors Size Type
/dev/nvme0n1p1 2048 206847 204800 100M EFI System
/dev/nvme0n1p2 206848 49362943 49156096 23.4G Linux filesystem
/dev/nvme0n1p5 49362944 51460095 2097152 1G Linux filesystem
/dev/nvme0n1p6 51460096 132933631 81473536 38.8G Linux LVM
Code language: plaintext (plaintext)
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.
Code language: Shell Session (shell)
Formatting the Unallocated Disk Partition
To make the new partition suitable for use by Rocky Linux 9, it needs to have a file system created on it. The recommended file system type for the current release of Rocky Linux is XFS which will be covered in greater detail in the chapter entitled Adding a New Disk Drive to a Rocky Linux 9 System. Creation of the file system is performed using the mkfs.xfs command as follows:
# mkfs.xfs -f /dev/nvme0n1p2
meta-data=/dev/nvme0n1p2 isize=512 agcount=4, agsize=1536128 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=1 inobtcount=1
data = bsize=4096 blocks=6144512, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=3000, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
Code language: Shell Session (shell)
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 Rocky Linux 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 Rocky Linux 9 Essentials. Buy the full book now in eBook or Print format.
Full book includes 34 chapters and 290 pages. Learn more. |
# mkdir /data
Code language: Shell Session (shell)
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):
/dev/nvme0n1p2 /data xfs defaults 0 0
Code language: Shell Session (shell)
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):
# mount /data
Code language: Shell Session (shell)
To check the partition, run the following command to display the available space:
# df -h /data
Filesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p2 24G 200M 24G 1% /data
Code language: Shell Session (shell)
Summary
The Windows partitions in a dual boot configuration can be removed anytime to free up space for a Rocky Linux 9 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 Rocky 9 system.