LinuxCommandLibrary

parted.interactive

Manage disk partitions interactively

TLDR

Start interactive mode with the specified disk selected

$ sudo parted [/dev/sdX]
copy

[Interactive] Show partition information in interactive mode
$ print
copy

[Interactive] Select a disk in interactive mode
$ select [/dev/sdX]
copy

[Interactive] Create a 16 GB partition with the specified filesystem in interactive mode (GPT partition table)
$ mkpart [partition_name] [btrfs|ext2|ext3|ext4|fat16|fat32|hfs|hfs+|linux-swap|ntfs|reiserfs|udf|xfs] [0%] [16G]
copy

[Interactive] Create a 16 GB partition with the specified filesystem in interactive mode (MBR partition table)
$ mkpart [primary|logical|extended] [btrfs|ext2|ext3|ext4|fat16|fat32|hfs|hfs+|linux-swap|ntfs|reiserfs|udf|xfs] [0%] [16G]
copy

[Interactive] Resize a partition in interactive mode
$ resizepart [/dev/sdXN] [end_position_of_partition]
copy

[Interactive] Remove a partition in interactive mode
$ rm [/dev/sdXN]
copy

[Interactive] Display help
$ ?
copy

SYNOPSIS

parted [options] [device]

PARAMETERS

-h, --help
    Display brief usage information.

-l, --list
    List partitions on all block devices.

-m, --machine
    Output in machine-parseable format.

-s, --script
    Run non-interactively; skip confirmations (requires readline).

--align-check optimal|none|minimal type comparison-file
    Verify partition alignment against a file.

-a alignment-type, --align alignment-type
    alignment-type: none|cylinder|minimal|optimal. Ensures optimal alignment for mkpart/resizepart.

-v, --version
    Show version information.

DESCRIPTION

The parted command in interactive mode provides a command-line interface for creating, resizing, deleting, and managing disk partitions on Linux systems. Invoke it by running parted <device> (e.g., parted /dev/sda), which drops you into the (parted) prompt. From here, use commands like print to list partitions, mklabel to set partition table type (e.g., gpt, msdos), mkpart to create new partitions, resizepart to resize, and rm to delete.

It supports various filesystems and partition tables, including GPT and MBR. Key advantage: non-destructive resizing for ext2/3/4, FAT, and others via libparted library. However, it's low-level and powerful, making it ideal for complex tasks like converting MBR to GPT or aligning partitions for SSDs.

Interactive mode is scriptable with --script, but prompts are skipped only with readline support. Exit with quit or Ctrl+D. Always verify with print before committing changes. Essential for server admins, rescue disks, and advanced partitioning beyond GUI tools.

CAVEATS

Extremely dangerous: can cause irreversible data loss. Always backup data and verify with print. Not for beginners; prefer fdisk or GUI tools for simple tasks. Some operations (e.g., resizing) require unmounted filesystems.

COMMON INTERACTIVE COMMANDS

print: Show partition table.
mklabel gpt: Create GPT label.
mkpart primary ext4 1MiB 100%: Make partition.
resizepart 1 100%: Resize partition 1.
quit: Exit.

UNITS SUPPORT

Uses suffixes like MiB, GiB, % for human-readable input. Default: cylinders (legacy).

HISTORY

Developed by Andrew Clausen starting 1998 as part of GNU Parted project. Reached version 3.4 in 2021. Evolved from partition resizing tools; now uses libparted for broad filesystem support. Widely used in installers like Debian.

SEE ALSO

fdisk(8), cfdisk(8), gdisk(8), sfdisk(8), partprobe(8)

Copied to clipboard