LinuxCommandLibrary

parted-interactive

Manage disk partitions interactively

TLDR

Start interactive mode with the specified disk selected

$ sudo parted [/dev/sdX]
copy

Show partition information in interactive mode
$ print
copy

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

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

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

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

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

Display help
$ ?
copy

SYNOPSIS

parted [DEVICE]

PARAMETERS

DEVICE
    The disk device (e.g., `/dev/sda`, `/dev/nvme0n1`) to be operated on. If omitted, `parted` may prompt for a device or use the first available.

`-h`, `--help`
    Displays a help message and exits.

`-v`, `--version`
    Displays version information and exits.

`-s`, `--script`
    Operates in script (non-interactive) mode. This option is explicitly against the interactive usage but is a fundamental command-line option for `parted`.

`-l`, `--list`
    Lists partition tables and partitions on all block devices. Can be used interactively or non-interactively.

DESCRIPTION

The term `parted-interactive` typically refers to running the GNU `parted` command in its default interactive mode, rather than a separate distinct binary. `parted` is a powerful command-line utility used for managing disk partitions. In interactive mode, `parted` presents a prompt (e.g., `(parted)`) where users can enter commands sequentially to perform various disk operations. This mode is particularly useful for tasks such as creating, deleting, resizing, copying, and checking partitions, as well as modifying partition table types (like MBR or GPT). Its interactive nature allows for immediate feedback and step-by-step execution of commands, providing granular control over disk layout. However, this also means it carries a significant risk of data loss if not used carefully, as changes are often applied directly to the disk without an "undo" option.

CAVEATS

Data Loss Risk: `parted` is extremely powerful and dangerous. Mistakes can lead to irreversible data loss. Always back up critical data before using.
Root Privileges: Requires root (sudo) privileges to operate on disk devices.
Device Naming: Be absolutely certain of the correct device name (e.g., `/dev/sda`, `/dev/sdb`) to avoid modifying the wrong disk.
No Undo: Most changes are applied immediately to the disk; there is no "undo" button.
Filesystem Integrity: Modifying partitions with active filesystems can lead to corruption; unmount filesystems before modifying their partitions.

COMMON INTERACTIVE COMMANDS

Once in interactive mode, `parted` offers a range of commands:
select DEVICE: Selects the disk device to operate on (e.g., `select /dev/sdb`).
print: Displays the current partition table and partitions of the selected device.
mklabel LABEL_TYPE: Creates a new partition table (e.g., `gpt`, `msdos`). WARNING: This will erase all existing partitions on the device!
mkpart PART_TYPE [FS_TYPE] START END: Creates a new partition. `PART_TYPE` can be `primary`, `logical`, `extended`. `FS_TYPE` is optional (e.g., `ext4`, `fat32`). `START` and `END` define the partition's size in MB, GB, etc.
rm NUMBER: Deletes the specified partition by its number.
resizepart NUMBER END: Resizes a partition to a new end position.
quit: Exits the `parted` interactive prompt.

HISTORY

GNU Parted was developed as part of the GNU project with the goal of providing a free and open-source utility for disk partition management. It was designed to handle various partition table types, including the traditional Master Boot Record (MBR) and the newer GUID Partition Table (GPT), which offers more flexibility and support for larger disks. Due to its power and flexibility, `parted` has become a widely used and essential tool in Linux distributions for both manual and automated disk management tasks.

SEE ALSO

fdisk(8), gdisk(8), sfdisk(8), mkfs(8), mount(8), lsblk(8), df(1)

Copied to clipboard