Skip to content

Click on each book below to review & buy on Amazon.

As an Amazon Associate, I earn from qualifying purchases.

CompTIA Linux+ XK0-005 - 1.3 - Disk Partitioning

In the Comptia Linux+ exam, it is important to understand the concepts and tools related to disk partitioning. Disk partitioning involves dividing a physical disk into separate sections called partitions, which can be formatted with different file systems and used for various purposes. In this guide, we will explore three commonly used commands for disk partitioning: fdisk, parted, and partprobe. We will provide detailed explanations and command examples with outputs to illustrate their usage.



The fdisk command is a traditional disk partitioning tool that operates on MBR (Master Boot Record) partition tables. It allows you to create, modify, and delete partitions on a disk. This command cannot create partitions larger than 2TB. Here are the main steps to use fdisk:

List available disks and their partitions:

fdisk -l

Example output:

Disk /dev/sda: 250 GB, 250000000000 bytes

Disk /dev/sdb: 500 GB, 500000000000 bytes

Start fdisk for a specific disk (e.g., /dev/sdb):

fdisk /dev/sdb

Inside the fdisk prompt, to create a new partition, perform the following steps:

  • Type n and press Enter.
    • Specify the partition type. For example, primary partition (p) or extended partition (e).
    • Specify the partition number (e.g., 1 for the first partition).
    • Set the starting and ending cylinder values or use the default values to use the entire disk space.
    • Set the partition type (optional):
  • Type t and press Enter.
    • Enter the partition number for which you want to change the type.
    • Specify the partition type code. You can view a list of available partition types by typing L and pressing Enter.
  • Save changes and exit:
    • Type w and press Enter to write the changes to the disk.

Example interaction:

Welcome to fdisk (util-linux 2.36.2).
Changes will remain in memory only until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-976773167, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-976773167, default 976773167):
Created a new partition 1 of type 'Linux' and of size 465.8 GiB.
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Empty' to 'Linux LVM'.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

This example demonstrates creating a primary partition (p) with the default starting and ending values to utilize the entire disk space. The type chosen was 8e for Linux LVM.

Remember to adjust the disk device (/dev/sdb) and the partitioning options according to your specific requirements. Always review and double-check your actions before writing changes to ensure the desired partition layout is achieved.

Inside the fdisk prompt, you can perform various operations, such as:

  • Show the help menu (m)
  • Create a new partition (n)
  • Print the partition table (p)
  • List known partition types (l)
  • Save changes and exit (w)
  • Quit without saving (q)

It is important to be familiar with the specific commands and options available in the fdisk prompt for the desired operations.


parted is a modern disk partitioning utility that supports both MBR and GPT (GUID Partition Table) partitioning schemes. It provides more advanced features compared to fdisk and can handle larger disks. Unlike fdisk, parted does not have a quit without saving option so be careful. Here are the main steps to use parted interactively:

List available disks and their partitions:

parted -l

Example output:

Model: ATA HDD1 (scsi)
Disk /dev/sda: 250GB
Model: ATA HDD2 (scsi)
Disk /dev/sdb: 500GB

Start parted for a specific disk (e.g., /dev/sdb):

parted /dev/sdb

Inside the parted prompt, perform the following steps to create a new partition:

  • Type mkpart and press Enter.
    • Specify the partition type. For example, primary (primary) or logical (logical).
    • Specify the file system type (e.g., ext4, fat32) or set it as unformatted.
    • Specify the starting point and ending point of the partition using the available options (e.g., start, end, size).
  • Type name and press Enter.
    • Enter the partition number.
    • Specify a name for the partition.
  • Type quit and press Enter to exit the parted prompt.

Example interaction:

GNU Parted 3.4
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mkpart
Partition type? primary/extended? primary
File system type? [ext2]? ext4
Start? 0%
End? 100%
(parted) name
Partition number? 1
File system name? mypartition
(parted) quit

This example demonstrates creating a primary partition with the entire disk space (0% to 100%) and assigning it the name "mypartition" using the ext4 file system.

Remember to adjust the disk device (/dev/sdb) and the partitioning options according to your specific requirements.

parted also supports scriptable command mode, allowing you to automate partitioning operations.


The partprobe command is used to inform the operating system about the changes made to the partition table without requiring a system reboot. It ensures that the updated partition information is recognized by the system. Here's an example:

partprobe /dev/sda

After modifying disk partitions using tools like fdisk or parted, running partprobe on the appropriate device will update the partition information and make it immediately available to the system.


Disk partitioning is a fundamental aspect of managing storage devices in Linux. The fdisk, parted, and partprobe commands provide powerful tools for creating, modifying, and updating disk partitions. By mastering these commands, you gain the ability to efficiently allocate disk space, configure partition types, and ensure the system recognizes partition changes without rebooting.

It is crucial to exercise caution when working with disk partitioning tools, as modifying partitions can lead to data loss if not performed carefully. Always double-check your actions before applying changes to ensure the integrity and safety of your data. Additionally, understanding the differences between MBR and GPT partitioning schemes and the limitations of each is important for making informed partitioning decisions.

By having a solid understanding of disk partitioning concepts and the tools available, you will be well-equipped to manage disk partitions effectively in a Linux environment.

Support DTV Linux

Click on each book below to review & buy on Amazon. As an Amazon Associate, I earn from qualifying purchases.

NordVPN ®: Elevate your online privacy and security. Grab our Special Offer to safeguard your data on public Wi-Fi and secure your devices. I may earn a commission on purchases made through this link.