fdisk Command
Advanced Disk & Storage man(1)Partition table manipulator for Linux
👁 8 views
📅 Updated: Mar 15, 2026
SYNTAX
fdisk [OPTION]... [DEVICE]
What Does fdisk Do?
fdisk is a dialog-driven partition table manipulator. It creates, deletes, resizes, and manages disk partitions. fdisk supports MBR and GPT partition tables.
fdisk is essential for disk preparation — creating partitions before formatting them with mkfs. It can display current partition layouts, create new partitions, delete existing ones, and change partition types.
fdisk requires root privileges. For GPT partition tables on modern systems, gdisk or parted are often preferred, but fdisk handles both MBR and GPT on modern Linux.
fdisk is essential for disk preparation — creating partitions before formatting them with mkfs. It can display current partition layouts, create new partitions, delete existing ones, and change partition types.
fdisk requires root privileges. For GPT partition tables on modern systems, gdisk or parted are often preferred, but fdisk handles both MBR and GPT on modern Linux.
Options & Flags
| Option | Description | Example |
|---|---|---|
| -l | List partition tables for all devices | sudo fdisk -l |
| -l /dev/sdX | List partitions for specific device | sudo fdisk -l /dev/sda |
| /dev/sdX | Enter interactive mode for device | sudo fdisk /dev/sdb |
Practical Examples
#1 List all partitions
Shows partition tables for all disks.
$ sudo fdisk -l
Output:
Disk /dev/sda: 500 GiB
Device Start End Size Type
/dev/sda1 2048 1050623 512M EFI System
/dev/sda2 1050624 976773119 465G Linux filesystem
#2 List specific disk
Shows partitions for a specific disk.
$ sudo fdisk -l /dev/sdb#3 Interactive partitioning
Opens interactive mode. Commands: n=new, d=delete, p=print, w=write, q=quit.
$ sudo fdisk /dev/sdb#4 Create partition (interactive)
Steps to create a 100GB primary partition.
$ # In fdisk:
n (new partition)
p (primary)
1 (number)
(default start)
+100G (size)
w (write)#5 Check partition alignment
Verifies partition alignment for optimal performance.
$ sudo fdisk -l /dev/sda | grep -i sectorTips & Best Practices
Write only when sure: fdisk changes are not applied until you press 'w' (write). Press 'q' to quit without changes. Double-check with 'p' before writing.
Use parted for GPT: fdisk handles GPT on modern Linux, but parted/gdisk are purpose-built for GPT and offer more features.
Partition after fdisk: After creating a partition with fdisk, format it with mkfs: sudo mkfs.ext4 /dev/sdb1, then mount it.
Frequently Asked Questions
How do I partition a new disk?
sudo fdisk /dev/sdX. Then: n (new), p (primary), set size, w (write). Then format with mkfs and mount.
How do I see disk partitions?
sudo fdisk -l shows all partitions. Or use lsblk for a simpler view.
Can I resize partitions with fdisk?
fdisk cannot resize partitions directly. You must delete and recreate. Use parted or GParted for non-destructive resizing.
Related Commands
More Disk & Storage Commands
Master Linux with Professional eBooks
Curated IT eBooks covering Linux, DevOps, Cloud, and more
Browse Books →