Forensicspartitiondiskfilesystemmanipulationgptdosresize

parted

GNU Parted is a program that allows you to create, destroy, resize, move, and copy disk partitions. It supports multiple partitioning formats and can detect various file systems.

Description

GNU Parted is a disk partition manipulator useful for creating space for new operating systems, reorganizing disk usage, and copying data to new hard disks. The main 'parted' package contains the binary and manual page, supporting DOS, Mac, Sun, BSD, GPT, MIPS, and PC98 partitioning formats, as well as loop (raw disk) type for RAID/LVM. It can detect and remove file systems like ASFS/AFFS/APFS, Btrfs, ext2/3/4, FAT16/32, HFS, JFS, linux-swap, UFS, XFS, and ZFS, though creating/modifying file systems is deprecated.

Parted operates in interactive mode or scripted mode with various options for alignment and output formats. Related packages include libparted2t64 (shared library), libparted-dev (development files), libparted-i18n (localization), libparted-fs-resize0t64 (FS resizing library), parted-doc (documentation), and partprobe (informs OS of partition changes). The tool warns that bugs could cause data loss, so backups are essential.

Partprobe utility notifies the operating system about partition table changes, with options for dry-run and summary.

How It Works

Parted manipulates disk partition tables by creating, resizing, moving, or destroying partitions using commands like mkpart, mklabel, and align-check. It supports multiple partition table types (DOS, GPT, etc.) and alignment options (none|cyl|min|opt). The tool reads/writes directly to block devices, detects file systems for partition operations, and uses libraries like libparted2t64. Partprobe triggers kernel re-reading of updated partition tables without rebooting.

Installation

bash
sudo apt install parted

Flags

-h, --helpdisplays this help message
-l, --listlists partition layout on all block devices
-m, --machinedisplays machine parseable output
-j, --jsondisplays JSON output
-s, --scriptnever prompts for user intervention
-f, --fixin script mode, fix instead of abort when asked
-v, --versiondisplays the version
-a, --align=[none|cyl|min|opt]alignment for new partitions
-d, --dry-rundo not actually inform the operating system (partprobe)
-s, --summaryprint a summary of contents (partprobe)

Examples

Display help message for parted
parted -h
List partition layout on all block devices
parted -l
Display machine parseable output of partitions
parted -m
Display JSON output of partition information
parted -j
Scripted mode: create GPT disklabel on /dev/sda
parted --script /dev/sda mklabel gpt
Check partition 1 for optimal alignment
parted /dev/sda align-check opt 1
Inform OS of partition table changes on all devices
partprobe
Print summary of partition contents
partprobe -s
Updated 2026-04-16kali.org ↗