Linux Command: parted
GPT and MBR partition management tool
The parted command is a disk partitioning tool that supports both GPT (GUID Partition Table) and MBR (Master Boot Record) partition schemes. Unlike fdisk which historically only supported MBR, parted handles GPT partitions natively, making it essential for modern systems with drives larger than 2TB. parted supports creating, resizing, moving, and deleting partitions on hard drives, SSDs, and other block devices. It can work in both interactive and scripted (non-interactive) modes, making it suitable for both manual administration and automated provisioning. One of parted's unique features is the ability to resize partitions โ growing or shrinking them without data loss (when combined with filesystem resize tools). This makes it invaluable for server administration where storage requirements change over time. For enterprise environments using LVM, RAID, or complex storage configurations, parted is typically the first step in preparing physical volumes before creating LVM physical volumes (pvcreate), volume groups, and logical volumes.
Syntax
parted [OPTIONS] [DEVICE] [COMMAND]Key Options
printโ Display partition table of a devicemklabel gptโ Create a new GPT partition tablemkpartโ Create a new partitionresizepart NUM ENDโ Resize a partition to new end positionrm NUMโ Delete a partition by numberset NUM FLAG on/offโ Set a flag on a partition (boot, lvm, raid)
Examples
View partition table
sudo parted /dev/sda printOutput: Model: ATA VBOX HARDDISK (scsi)\nDisk /dev/sda: 107GB\nPartition Table: gpt\n\nNumber Start End Size File system Name Flags\n 1 1049kB 538MB 537MB fat32 EFI boot,
Create GPT partition table on new disk
sudo parted -s /dev/sdb mklabel gptCreate a single partition using full disk
sudo parted -s /dev/sdb mkpart primary ext4 0% 100%Pro Tips
- Unlike fdisk which requires writing changes, parted applies changes IMMEDIATELY. There is no undo. Double-check the device path before any destructive operation.
- Use 0% and 100% instead of exact byte values for optimal partition alignment. This ensures partitions align to physical sector boundaries.
- Use GPT for disks larger than 2TB, UEFI systems, or when you need more than 4 primary partitions. MBR is only needed for legacy BIOS systems.
Learn more: Full parted reference โ