$linuxjunkies
>

parted(8)

Create, resize, and manage disk partitions interactively or via command line.

UbuntuDebianFedoraArch

Synopsis

parted [OPTION]... [DEVICE [COMMAND [ARGS]...]...]

Description

parted is a partition editor that can create, resize, delete, and move partitions on a hard disk. It supports multiple partition table formats (MBR, GPT, etc.) and works with various filesystems. parted can be run interactively or accept commands directly from the command line.

Always back up your data before modifying partitions. parted requires root privileges and will warn you before making destructive changes. Use with caution on live systems.

Common options

FlagWhat it does
-l, --listList all recognized block devices and their partitions
-i, --interactiveOperate in interactive mode (prompts before dangerous operations)
-s, --scriptExecute commands non-interactively; suppress warnings
-a, --align [none|cylinder|minimal|optimal]Set partition alignment (optimal is default for modern drives)
-m, --machineOutput machine-parseable format instead of human-readable
--versionDisplay parted version and exit
--helpShow help message and exit

Examples

List all disks and their partition tables

parted -l

Enter interactive mode for /dev/sda; use 'help' to see available commands

parted /dev/sda

Display the partition table of /dev/sda without entering interactive mode

parted /dev/sda print

Create a new GPT partition table on /dev/sda (destroys existing partitions)

parted -s /dev/sda mklabel gpt

Create a single ext4 partition spanning the entire disk

parted -s /dev/sda mkpart primary ext4 0% 100%

Create a swap partition from 10GB to 12GB

parted -s /dev/sda mkpart primary linux-swap 10GB 12GB

Resize partition 1 to end at 50GB (interactive confirmation required)

parted /dev/sda resizepart 1 50GB

Get machine-readable details of partition 1 for scripting

parted -m /dev/sda print | grep '^1:'

Related commands