Master Linux Disk Partitioning with fdisk and parted
This guide explains the differences between MBR and GPT, shows how to list, create, modify, and delete partitions using fdisk for smaller disks and parted for larger than 2 TB, and provides practical command examples and safety tips.
Linux provides two main partitioning tools: fdisk for MBR-style partitions (limited to disks ≤2 TB) and parted for GPT partitions, which support larger disks and more flexible layouts.
MBR limitations and extended partitions
Traditional MBR allows up to four primary partitions; additional space requires creating an extended partition that can hold multiple logical partitions. Diagrams illustrate the primary and extended partition structures.
Using fdisk
Basic commands:
[root@localhost ~]# fdisk -l # list all partitions
[root@localhost ~]# fdisk /dev/sdX # start interactive mode for a deviceThe output includes seven columns (Device, Boot, Start, End, Blocks, Id, System) describing each partition. Important safety note: never run fdisk on the active system disk; use a separate drive or a virtual machine.
Typical interactive steps:
Press p to print the current partition table.
Press n to create a new partition (choose primary or logical).
Follow prompts to set start and end cylinders.
Use w to write changes.
Example screenshots demonstrate creating two primary partitions and the resulting table.
Using parted
partedworks with GPT and can immediately apply changes using partprobe without rebooting.
Command syntax:
[root@localhost ~]# parted [options] /dev/sdX [command]Key operations:
Show partition table: parted /dev/sdc print Create a partition: parted /dev/sdc mkpart primary ext3 1 2G (creates a 2 GB primary ext3 partition starting at 1 MB).
Change table type to GPT: parted /dev/sdc mklabel gpt Delete a partition: parted /dev/sdc rm 2 Additional capabilities include resizing, checking, and recovering deleted partitions.
Safety and best practices
Always verify the target disk, back up data, and prefer using a non‑system disk or VM for experimentation. After modifying partitions, run partprobe or reboot to ensure the kernel recognises the new layout.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
