parted (partition editor) — Partition creation and resizing
Linux / File and disk management / parted.html
A non-interactive partition editor for creating, deleting and resizing partitions on GPT and MBR disks.
Basic Information
| Command Name | parted (partition editor) |
|---|---|
| One-line Introduction | A non-interactive partition editor for creating, deleting and resizing partitions on GPT and MBR disks. |
| Provided by | GNU Parted |
| Official Documentation | https://man7.org/linux/man-pages/man8/parted.8.html |
| Supported Operating Systems | Linux, WSL |
| Installation Status | Usually preinstalled or install the parted package |
| Category | Linux file and disk management (tags: partition, resize, GPT, parted) |
What is this command?
parted manages partition tables with single commands. Unlike fdisk it can also resize partitions and create file systems in one step, which makes it popular in automation scripts.
Every change is applied to the disk immediately with no separate save step, so always confirm the target device and partition number before running it.
What problems does it solve?
- You need to grow or shrink a partition
- A script must configure partitions automatically
- You are initializing a new GPT disk
- You need to check partition alignment
Key features
Non-interactive editing
Subcommands such as mkpart, rm and resizepart run with inline arguments.
- When to use: You configure disks with repeatable scripts
- What you get: Partition changes applied immediately
- Limitations: There is no confirmation step to undo mistakes.
Resize partitions
resizepart moves partition boundaries; the file system must then be grown too.
- When to use: You expanded a virtual disk or LVM volume
- What you get: A partition that uses the new space
- Limitations: Shrinking risks file system damage and requires a backup.
Create file systems
The mkfs subcommand creates ext4, xfs, fat32 and others.
- When to use: You want a new partition ready to mount
- What you get: A formatted partition
- Limitations: All existing data is erased.
Installation and usage
Check whether it is installed
parted --version
sudo apt install parted # Debian/Ubuntu sudo dnf install parted # Fedora
Real-world examples
List partitions
Prints the partition table and alignment of the device.
sudo parted /dev/sdb print
Create a GPT label and partition
Initialize the disk as GPT and create partition number 1.
sudo parted /dev/sdb --script mklabel gpt
sudo parted /dev/sdb --script mkpart primary ext4 1MiB 100%
Grow a partition
Extend the partition boundary to the end of the disk.
sudo parted /dev/sdb --script resizepart 1 100%