Linux parted Command: Inspect and Manage Partitions

parted is a GNU tool that queries disk partition tables and creates, deletes, or resizes partitions. You must strictly separate the task of reading disk structures from the actual modification task.

What is the parted command?

print shows the current partition table, while print free also displays the free space between partitions. The interactive modification commands of parted can be applied to the disk immediately without waiting for a separate save button. resizepart changes partition boundaries, and resizing the file system is a separate procedure.

Basic syntax

parted [option] [disk] [command]

The installed implementation and options may vary depending on the distribution. Check the current system documentation with man parted.

Examples

Viewing all disk structures

Check the partition table for each disk recognized by the system.

sudo parted -l

Free space on a specific disk

View the target disk and partition boundaries in read-only mode.

sudo parted /dev/sdb unit MiB print free

Contrast with another tool

Check the device model and capacity along with the current mount status.

lsblk -o NAME,SIZE,MODEL,TYPE,MOUNTPOINTS

Distinguishing Partition Boundaries and File Systems

parted print shows the partition table type of the disk and the start and end positions of partitions. The inquiry command does not create partitions or format file systems.

sudo parted /dev/sdb print

Structure of the example output (numbers vary by device):

Model: ...
Disk /dev/sdb: 20.0GB
Partition Table: gpt
Number  Start   End     Size    File system  Name

Creating or resizing partitions is separate from changing the size of the file system. Changing boundaries in parted does not automatically and safely expand or shrink the existing file system. In particular, shrinking requires checking data backup, whether it can be unmounted, and tool support for each file system first.

Main Options and Format

Options/Format Description
-l List the partition tables of all devices.
-s Run in script mode. Verification procedures may be reduced during changes.
unit unit Set the display and input units.
print free Display partitions and free space.
resizepart number end Change the end boundary of the partition. The file system size is separate.

Precautions when using

mklabel replaces the existing partition table and rm deletes partition entries, so do not run without a backup. -s can reduce interactive protection during modification operations. When changing sizes, plan the order of file system, encryption, and LVM layers together, and follow maintenance procedures on disks used in real environments.

Frequently Asked Questions

Do changes need to be saved before quitting parted?

Interactive parted change commands are usually applied to the disk immediately. Thinking of it like fdisk, where you save at the end with w, is dangerous.

Official Documentation

The exact behavior of options and implementation differences can be checked in the official parted documentation.

More in This Category
Linux Tutorial / Hard Links vs. Symbolic Links in Linux: Differences and Examples

Linux Tutorial / Hard Links vs. Symbolic Links in Linux: Differences and Examples

Compare hard and symbolic links through inode and path behavior, then create both kinds of link and observe what happens when the original name changes.

Linux fmt Command: Reformat Plain-Text Paragraphs

Linux fmt Command: Reformat Plain-Text Paragraphs

Learn how to reformat Plain-Text Paragraphs with the Linux fmt command, including practical examples, key options, and important precautions.

Linux unxz Command: Decompress xz Files

Linux unxz Command: Decompress xz Files

Learn how to decompress xz Files with the Linux unxz command, including practical examples, key options, and important precautions.

Linux mkdir Command: Create Directories and Parent Paths

Linux mkdir Command: Create Directories and Parent Paths

Learn how to create directories with Linux mkdir, build missing parent paths, set permissions, understand umask behavior, and verify results in scripts.

Linux truncate Command: Shrink or Extend File Size

Linux truncate Command: Shrink or Extend File Size

Learn how to shrink or extend files with Linux truncate, adjust sizes relatively, match a reference file, and distinguish sparse logical size from disk usage.

Linux zypper Command: Manage Packages on openSUSE and SUSE

Linux zypper Command: Manage Packages on openSUSE and SUSE

Learn how to manage Packages on openSUSE and SUSE with the Linux zypper command, including practical examples, key options, and important precautions.

Linux timedatectl Command: Check Time Zone and Time Synchronization

Linux timedatectl Command: Check Time Zone and Time Synchronization

Learn how to check Time Zone and Time Synchronization with the Linux timedatectl command, including practical examples, key options, and important precautions.

Linux tracepath Command: Trace a Network Path and Path MTU

Linux tracepath Command: Trace a Network Path and Path MTU

Learn how to trace a Network Path and Path MTU with the Linux tracepath command, including practical examples, key options, and important precautions.

Linux sort Command: Sort Text Lines

Linux sort Command: Sort Text Lines

Learn how to sort text lines with the Linux sort command, including practical examples, key options, and important precautions.

Linux sed Command: Search and Replace Text Streams

Linux sed Command: Search and Replace Text Streams

Learn how to search and Replace Text Streams with the Linux sed command, including practical examples, key options, and important precautions.