How to Create and Format Disk Partitions Using the GNU Parted Command in Linux

Why Use Parted Over Fdisk?

The traditional fdisk utility in Linux is excellent for managing smaller hard drives, but it uses the older MBR (Master Boot Record) partitioning scheme, which physically cannot address disks larger than 2 Terabytes. The GNU Parted command supports the modern GPT (GUID Partition Table) standard, allowing you to manipulate massive enterprise storage arrays and drives exceeding the 2TB limit seamlessly from the command line.

Step 1: Identify the Target Disk

Before making any changes, you must identify the device name of the newly installed hard drive. Use the lsblk command to list all block devices:

lsblk

Identify your new, unpartitioned disk (e.g., /dev/sdb or /dev/nvme1n1) based on its size.

Step 2: Launch Parted and Create a GPT Label

Start the interactive parted utility targeting your specific disk (requires root privileges):

sudo parted /dev/sdb

You will enter the parted interactive shell (indicated by the (parted) prompt). First, you must assign a partition table type. To support drives over 2TB, create a GPT label:

(parted) mklabel gpt

Warning: This command will instantly destroy any existing partition table and data on the disk.

Step 3: Create the Partitions

Now you can carve up the unallocated space. The syntax for the mkpart command is mkpart [partition-type] [start-point] [end-point].

To create a single primary partition that consumes the entire disk, it is best practice to start at 0% (to ensure optimal sector alignment) and end at 100%:

(parted) mkpart primary 0% 100%

Alternatively, to create a 50GB partition starting at the beginning of the disk, run: mkpart primary 0% 50GB.

Step 4: Verify and Exit

To verify that the partition was created successfully and is properly aligned, use the print command:

(parted) print

You should see your new partition listed. Type quit to exit the parted interactive shell and return to your standard bash prompt. Unlike fdisk, parted writes changes to the disk immediately; there is no “write” command.

Step 5: Format and Mount the Partition

Your new partition (now named /dev/sdb1) exists, but it has no file system. Format it using the ext4 file system:

sudo mkfs.ext4 /dev/sdb1

Finally, create a mount point directory and mount the formatted partition so the operating system can use it:

sudo mkdir -p /mnt/data

sudo mount /dev/sdb1 /mnt/data

Your large drive is now ready to store data!

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.