parted
Overview
parted creates and modifies partition tables (GPT/MSDOS) on block devices. Prefer it for GPT disks and scripted partitioning; fdisk remains common for interactive MBR/GPT on small admin tasks. Mistakes destroy data — work on the correct device only.
Syntax
sudo parted [options] device [command...]
sudo parted device printCommon Commands (interactive or CLI)
| Command | Description |
|---|---|
print |
Show partition table |
mklabel gpt\|msdos |
Create new disklabel (wipes) |
mkpart |
Create partition |
rm N |
Delete partition number N |
resizepart |
Resize partition boundary |
unit GiB |
Display/input units |
align-check |
Alignment check |
Safety
- Double-check
lsblk/by-idpaths before anymklabelorrm.
mklabeldestroys the existing table.
- After partitioning, create filesystems with
mkfsand updatefstabby UUID.
- On disks with LVM/RAID, coordinate with
pvcreate/mdadmfirst.
Examples with Explanations
Print table
lsblk -o NAME,SIZE,TYPE,FSTYPE,UUID
sudo parted /dev/sdb print
sudo parted -lGPT with one partition (scripted)
sudo parted -s /dev/sdb mklabel gpt
sudo parted -s /dev/sdb mkpart primary ext4 1MiB 100%
sudo parted /dev/sdb align-check optimal 1
sudo mkfs.ext4 /dev/sdb1Interactive
sudo parted /dev/sdb
# (parted) unit GiB
# (parted) print
# (parted) quitNotes & Pitfalls
- Kernel may need
partprobeor a re-plug to re-read tables.
- NVMe partitions look like
/dev/nvme0n1p1(note thep).
- Cloud disks often already have GPT — don’t re-label casually.
Additional Resources
man parted
info parted