Using Parted for Linux GPT Partition Tables
The parted (GNU Parted) utility in the Linux operating
system is a command-line tool designed to create, resize, delete, and
manage disk partitions, with primary support for modern GUID Partition
Table (GPT) layouts. This article explains how parted
handles GPT disks, why it is essential for modern storage
administration, and the core commands required to manage GPT drives
effectively.
Understanding GPT and the Role of Parted
Historically, Linux disks relied on the Master Boot Record (MBR) partition table, which has a 2 TiB storage limit and supports only four primary partitions. GPT replaces MBR to address modern storage requirements, supporting storage drives well into the zettabyte range, allowing virtually unlimited partitions, and providing data redundancy via backup partition headers at the end of the disk.
While traditional tools like standard fdisk historically
focused on MBR (though modern versions support GPT), parted
was built to natively handle both MBR and GPT partition schemes without
conversion bugs or structural incompatibilities.
Core Uses of Parted with GPT
Administrators primarily use parted to perform the
following operations on GPT disks:
1. Initializing a GPT Partition Table
Before creating partitions on a new disk, you must initialize the
disk label. parted assigns the GPT format to a raw disk
using the mklabel command:
parted /dev/sdX mklabel gptThis writes the primary GPT header and partition table at the start
of /dev/sdX and sets up the backup table at the end of the
disk.
2. Creating Partitions
Because GPT does not rely on extended or logical partitions, every
partition is treated as an independent entity. With parted,
creating a partition requires defining the filesystem type, start point,
and end point:
parted /dev/sdX mkpart primary ext4 1MiB 50GiBAligning the partition to 1MiB boundaries ensures optimal performance on modern Advanced Format (4Kn and 512e) drives and SSDs.
3. Displaying Partition Information
To inspect a GPT disk layout, partition flags, unique partition
GUIDs, and drive geometry, parted provides the
print command:
parted /dev/sdX printThis confirms that the Partition Table: gpt scheme is
active and lists all configured partitions.
4. Resizing Partitions
When storage requirements change, parted allows you to
adjust partition boundaries non-destructively:
parted /dev/sdX resizepart 1 100GiBThis updates the GPT boundary, allowing you to subsequently grow the
underlying filesystem using tools like resize2fs or
xfs_growfs.
5. Assigning Partition Names and Flags
GPT allows partitions to have human-readable names and functional
flags (such as boot, esp for UEFI boot
partitions, or raid):
parted /dev/sdX name 1 "SystemRoot"
parted /dev/sdX set 1 boot on6. Deleting Partitions
Partitions can be removed cleanly from the GPT table by specifying their partition number:
parted /dev/sdX rm 1Scripting and Automation
Unlike interactive utilities, parted features a
non-interactive batch mode (invoked using the -s or
--script flag), making it the standard choice for automated
deployment scripts, cloud initialization sequences, and provisioning
tools that require rapid creation of GPT layouts on Linux systems.