List, Create, and Delete Partitions on MBR and GPT Disks

Red Hat Enterprise LinuxBeginner
Practice Now

Introduction

Welcome to the disk partition management challenge! In this challenge, you'll get hands-on experience with fdisk, a standard command-line tool for managing disk partitions in Linux. You will practice listing, creating, and deleting partitions on a secondary disk, first with a Master Boot Record (MBR) partition table and then with a GUID Partition Table (GPT).

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 secondary block device /dev/nvme1n1.

Requirements

  • Use the fdisk command to manage partitions on the /dev/nvme1n1 disk.
  • Create a new primary partition with a size of 500M.
  • After creation, verify the new partition exists.

Example

Initially, the disk /dev/nvme1n1 has no partition table. After you create a new partition, the output of sudo fdisk -l /dev/nvme1n1 should look similar to this, showing the new /dev/nvme1n1p1 partition.

Disk /dev/nvme1n1: 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/nvme1n1p1       2048 1026047 1024000  500M 83 Linux

Convert to GPT and Create a Partition

Now, you will reinitialize the same disk, /dev/nvme1n1, with the modern GPT partition scheme and then create a new partition with fdisk.

Requirements

  • Use the fdisk command to manage partitions on the /dev/nvme1n1 disk.
  • Reinitialize the disk with a GPT partition table.
  • Create a new partition with a size of 1G.
  • After creation, verify the new partition.

Example

After reinitializing the disk to GPT and creating a new 1G partition, the output of sudo fdisk -l /dev/nvme1n1 should look similar to this:

Disklabel type: gpt

Device          Start     End Sectors Size Type
/dev/nvme1n1p1   2048 2099199 2097152   1G Linux filesystem

Delete All Partitions

In this final step, you will delete all partitions on /dev/nvme1n1 to clean up the disk. Since the disk now has a GPT partition table, you should continue using fdisk.

Requirements

  • Use the fdisk command to delete all partitions on the /dev/nvme1n1 disk.
  • After deletion, verify that no partitions remain.

Example

After deleting all partitions, the output of sudo fdisk -l /dev/nvme1n1 should show no partition entries, similar to this:

Disklabel type: gpt

Summary

In this challenge, you have successfully managed disk partitions with fdisk on both MBR and GPT partition tables. You started by creating a partition on an MBR-labeled disk, then reinitialized the disk with GPT and created a new 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/nvme1n1
## In fdisk prompt:
## o - to create a new empty DOS partition table
## w - to write and exit
✨ Check Solution and Practice✨ Check Solution and Practice✨ Check Solution and Practice