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 curl Command: Make URL Requests and Inspect HTTP Responses

Linux curl Command: Make URL Requests and Inspect HTTP Responses

Learn how to make URL Requests and Inspect HTTP Responses with the Linux curl command, including practical examples, key options, and important precautions.

Linux shutdown Command: Schedule a Shutdown or Restart

Linux shutdown Command: Schedule a Shutdown or Restart

Learn how to schedule a Shutdown or Restart with the Linux shutdown command, including practical examples, key options, and important precautions.

Linux Administration Memo: Essential Commands and System Checks

Linux Administration Memo: Essential Commands and System Checks

A compact Linux administration reference for checking system information, processes, storage, networking, users, permissions, services, and logs.

Linux clear Command: Clear the Terminal Display

Linux clear Command: Clear the Terminal Display

Learn how to use the Linux clear command to clear the visible terminal screen and understand scrollback behavior, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux ip Command: Inspect and Configure Network Interfaces and Routes

Linux ip Command: Inspect and Configure Network Interfaces and Routes

Learn how to inspect and Configure Network Interfaces and Routes with the Linux ip command, including practical examples, key options, and important precautions.

Linux Tutorial / File Types and Metadata: ls, file, stat, and readlink

Linux Tutorial / File Types and Metadata: ls, file, stat, and readlink

Learn what ls, file, stat, and readlink each reveal about a Linux file, including type, size, timestamps, and symbolic-link targets.

Linux alias Command: Create Command Shortcuts

Linux alias Command: Create Command Shortcuts

Learn how to use the Linux alias command to create, inspect, and make shell command aliases persistent, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux apt-get Command: Run APT Package Operations in Scripts

Linux apt-get Command: Run APT Package Operations in Scripts

Learn how to run APT Package Operations in Scripts with the Linux apt-get command, including practical examples, key options, and important precautions.

Linux xz Command: Compress a File in xz Format

Linux xz Command: Compress a File in xz Format

Learn how to compress a File in xz Format with the Linux xz command, including practical examples, key options, and important precautions.

Linux awk Command: Analyze Text by Fields

Linux awk Command: Analyze Text by Fields

Learn how to analyze Text by Fields with the Linux awk command, including practical examples, key options, and important precautions.