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.









