Master Linux Disk Partitioning with fdisk and parted: A Step‑by‑Step Guide
This tutorial walks you through Linux disk partitioning using fdisk and parted, covering MBR vs GPT limits, command syntax, interactive operations, example workflows for creating, listing, modifying, and deleting partitions, and essential safety warnings.
Linux provides dedicated partitioning tools fdisk and parted . fdisk is widely used but cannot handle partitions larger than 2 TB, while parted supports larger disks and GPT partitioning.
Traditional MBR partitioning allows up to four primary partitions per disk; additional space requires creating extended partitions with logical volumes.
fdisk Command
Basic usage:
[root@localhost ~]# fdisk -l # list system partitions
[root@localhost ~]# fdisk /dev/sdX # partition a diskDo not run fdisk on the active system disk, as it can erase the entire system; use a separate disk or a virtual machine.
The partition table output contains seven columns:
Device : partition device name.
Boot : indicates if it is a bootable partition.
Start : starting cylinder.
End : ending cylinder.
Blocks : size in KB.
Id : filesystem ID (viewable with the i command).
System : installed operating system.
Interactive commands example: [root@localhost omc]# fdisk /dev/sda2 Use p to list current partitions, then n to create new primary partitions, followed by w to write changes.
parted Command
The partprobe command forces the kernel to reread the partition table without rebooting.
parted works with GPT, which overcomes the four‑primary‑partition limit of MBR and provides redundant partition tables for safety.
Command syntax:
[root@localhost omc]# parted [options] /dev/sdX [command]1. View partition table
[root@localhost omc]# parted /dev/sdc print2. Create a partition
[root@localhost omc]# parted /dev/sdc mkpart primary ext3 1 2GThis creates a primary ext3 partition from 1 MB to 2 GB (size 2 GB).
[root@localhost omc]# parted /dev/sdc mkpart primary ext3 2G 4GCreates another 2 GB partition starting at 2 GB and ending at 4 GB.
3. Change partition table type
[root@localhost omc]# parted /dev/sdc mklabel gpt4. Delete a partition
[root@localhost omc]# parted /dev/sdc rm 2Beyond basic creation and deletion, parted can check partitions, resize them, and recover deleted partitions.
Source: WeChat public account "一口Linux"
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.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
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.
