Introduction
Welcome to the disk partition management challenge! In this challenge, you'll get hands-on experience with fdisk and gdisk, the standard command-line tools for managing disk partitions in Linux. You will practice listing, creating, and deleting partitions on a disk, first with a Master Boot Record (MBR) partition table, and then converting it to a GUID Partition Table (GPT) to perform similar tasks.
Mastering these skills is fundamental for any system administrator and is a key topic in the RHCSA (Red Hat Certified System Administrator) exam.
Create a Partition on an MBR Disk
First, you will work with the traditional MBR partition scheme. Your task is to use the fdisk utility to create a new primary partition on the available block device /dev/vdb.
Requirements
- Use the
fdiskcommand to manage partitions on the/dev/vdbdisk. - Create a new primary partition with a size of 500M.
- After creation, verify the new partition exists.
Example
Initially, the disk /dev/vdb has no partition table. After you create a new partition, the output of sudo fdisk -l /dev/vdb should look similar to this, showing the new /dev/vdb1 partition.
Disk /dev/vdb: 40 GiB, 42949672960 bytes, 83886080 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: 0x85191cd4
Device Boot Start End Sectors Size Id Type
/dev/vdb1 2048 1026047 1024000 500M 83 Linux
Convert to GPT and Create a Partition
Now, you will convert the same disk, /dev/vdb, to the modern GPT partition scheme and perform partitioning tasks using the gdisk utility. gdisk will automatically detect the old MBR format and offer to convert it, preserving the partition you created in the previous step.
Requirements
- Use the
gdiskcommand to manage partitions on the/dev/vdbdisk. - When prompted, allow
gdiskto convert the MBR disk to GPT. - Create a new partition with a size of 1G.
- After creation, verify the new partition.
Example
After converting the disk to GPT, the original partition is preserved. When you create a new 1G partition, the disk will have two partitions. The output of sudo gdisk -l /dev/vdb should look similar to this:
Number Start (sector) End (sector) Size Code Name
1 2048 1026047 500.0 MiB 8300 Linux filesystem
2 1026048 3123199 1024.0 MiB 8300 Linux filesystem
Delete All Partitions
In this final step, you will delete all partitions on /dev/vdb to clean up the disk. Since the disk now has a GPT partition table, you should use gdisk.
Requirements
- Use the
gdiskcommand to delete all partitions on the/dev/vdbdisk. - After deletion, verify that no partitions remain.
Example
After deleting all partitions, the output of sudo gdisk -l /dev/vdb should show no devices listed, similar to this:
Number Start (sector) End (sector) Size Code Name
Summary
In this challenge, you have successfully managed disk partitions using both fdisk for MBR and gdisk for GPT. You started by creating a partition on an MBR-labeled disk, then converted the disk to GPT and created another partition. Finally, you cleaned up the disk by deleting all partitions. This hands-on experience is invaluable for managing local storage on Linux systems and is excellent practice for the RHCSA exam.
You can re-initialize the disk at any time by simply writing a new MBR or GPT partition table to it. For example, to quickly reset the disk to a clean MBR state, you can use:
sudo fdisk /dev/vdb
## In fdisk prompt:
## o - to create a new empty DOS partition table
## w - to write and exit



