Quick take: The parted command manages partitions, including GPT for disks over 2 TB. sudo parted /dev/sdX print lists the layout, and its interactive mode creates, resizes, and removes partitions. Partition changes can destroy data, so confirm the device first.

Introduction

The parted command is a more capable partitioning tool than classic fdisk, with first-class support for the GPT partition table required by disks larger than 2 TB, and the ability to resize partitions. It can run interactively or be scripted, making it the modern choice for serious disk work — used carefully, since partitioning is destructive.

This guide covers listing partitions, creating a GPT table and partitions, and the safety practices that matter when changing a disk's layout.

Syntax

The basic syntax of the parted command is:

parted [OPTIONS] DEVICE [COMMAND]

Common Options and Parameters

The most useful options and parameters for the parted command:

OptionDescription
printShow the partition table of the disk.
mklabel gptCreate a new GPT partition table (erases the disk).
mkpartCreate a partition (name, filesystem, start, end).
rm NRemove partition number N.
resizepart N ENDResize a partition to a new end point.
-lList partitions on all devices.
unit UNITSet the unit (GB, MiB, %) for sizes.

Practical Examples

Real parted commands you can run today:

# List partitions on all disks
sudo parted -l
# Print one disk's layout
sudo parted /dev/sdb print
# Create a GPT label (erases the disk!)
sudo parted /dev/sdb mklabel gpt
# Create a partition spanning the disk
sudo parted /dev/sdb mkpart primary ext4 0% 100%
# Open interactive mode
sudo parted /dev/sdb
# Confirm the device first
lsblk

Tips and Best Practices

  • parted can apply changes immediately (unlike fdisk's deferred write), so verify the device with lsblk before each command.
  • Use parted (with GPT) for disks larger than 2 TB, where the older MBR scheme cannot address the full capacity.
  • After creating a partition with parted, put a filesystem on it with mkfs and then mount it.

Final Thoughts

parted is the modern partitioning tool, handling GPT and large disks and able to resize partitions — capabilities classic fdisk lacks. Its commands can take effect immediately, so confirming the device with lsblk is essential. Use it to lay out big disks, then create filesystems with mkfs and mount them. For simple MBR disks, fdisk remains perfectly adequate.

FAQ: parted Command in Linux

What is the difference between parted and fdisk?+

parted supports GPT and very large disks, can resize partitions, and can be scripted, while classic fdisk focused on MBR (modern versions add GPT too). parted is preferred for large disks and advanced operations; fdisk is simple for standard ones.

How do I create a GPT partition table?+

Use sudo parted /dev/sdX mklabel gpt. This creates a GPT table and erases the disk, so confirm the device with lsblk and back up any data first.

How do I list partitions with parted?+

Run sudo parted -l to list all disks, or sudo parted /dev/sdX print for one disk's partition table including sizes and filesystem types.

How do I partition a disk larger than 2 TB?+

Use parted with a GPT label, since the older MBR scheme cannot address beyond 2 TB. Create the GPT table with mklabel gpt, then add partitions with mkpart.

Is parted safe to use?+

Listing with parted -l is safe, but creating, removing, or resizing partitions changes the disk and can destroy data, sometimes immediately. Always verify the device with lsblk and back up important data before making changes.

Need help with Linux servers or infrastructure?

Work directly with Muhammad Irfan Aslam for Linux, Ubuntu, Docker, DevOps, cloud, CI/CD, or infrastructure support.

Hire Me for Support