parted(8)
Create, resize, and manage disk partitions interactively or via command line.
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
| Flag | What it does |
|---|---|
-l, --list | List all recognized block devices and their partitions |
-i, --interactive | Operate in interactive mode (prompts before dangerous operations) |
-s, --script | Execute commands non-interactively; suppress warnings |
-a, --align [none|cylinder|minimal|optimal] | Set partition alignment (optimal is default for modern drives) |
-m, --machine | Output machine-parseable format instead of human-readable |
--version | Display parted version and exit |
--help | Show help message and exit |
Examples
List all disks and their partition tables
parted -lEnter interactive mode for /dev/sda; use 'help' to see available commands
parted /dev/sdaDisplay the partition table of /dev/sda without entering interactive mode
parted /dev/sda printCreate a new GPT partition table on /dev/sda (destroys existing partitions)
parted -s /dev/sda mklabel gptCreate 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 12GBResize partition 1 to end at 50GB (interactive confirmation required)
parted /dev/sda resizepart 1 50GBGet machine-readable details of partition 1 for scripting
parted -m /dev/sda print | grep '^1:'