Parted Command - Linux Disk Partitioning Tool

Learn to use the parted command for Linux disk partitioning. Create, resize, and manage MBR/GPT partition tables with this powerful command-line utility.

Parted Command - Linux Disk Partitioning

The parted command is a powerful and flexible disk partitioning utility for Linux systems. It allows users to manage partition tables, create, delete, resize, and move partitions on storage devices. Unlike older tools like fdisk, parted supports both MBR (Master Boot Record) and GPT (GUID Partition Table) partition schemes, making it suitable for a wide range of disk configurations and operating system requirements.

Creating Partition Tables with Parted

Initializing a disk with a new partition table is a fundamental operation. parted provides the mklabel command for this purpose. You can choose between the older MBR scheme, typically used for BIOS systems, or the modern GPT scheme, which is standard for UEFI systems and offers advantages like support for larger disks and more partitions.

# Create a new MBR/MSDOS partition table for BIOS systems
(parted) mklabel msdos

# Create a new GPT partition table for UEFI systems instead
(parted) mklabel gpt

Resizing Partitions

parted also excels at resizing existing partitions. The resizepart command allows you to extend or shrink a partition to a specified end point. This is particularly useful when you need to adjust disk space allocation without data loss, provided the filesystem on the partition is also capable of online resizing or is unmounted.

# Grow a partition to a new end point
(parted) resizepart ${number} ${end}

Additional Parted Operations

Beyond creating and resizing, parted offers commands for creating new partitions (mkpart), deleting partitions (rm), and printing partition information (print). Its interactive mode provides a command-line interface where you can execute these commands sequentially. For scripting, parted can also be used in non-interactive mode.

Understanding Partitioning Schemes

It's crucial to understand the difference between MBR and GPT. MBR has limitations on disk size (up to 2TB) and the number of primary partitions (four). GPT, on the other hand, supports much larger disks and a significantly higher number of partitions, making it the preferred choice for modern hardware and operating systems.

External Resources