Operations 5 min read

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.

Open Source Linux
Open Source Linux
Open Source Linux
Master Linux Disk Partitioning with fdisk and parted: A Step‑by‑Step Guide

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 disk

Do 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 print

2. Create a partition

[root@localhost omc]# parted /dev/sdc mkpart primary ext3 1 2G

This creates a primary ext3 partition from 1 MB to 2 GB (size 2 GB).

[root@localhost omc]# parted /dev/sdc mkpart primary ext3 2G 4G

Creates 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 gpt

4. Delete a partition

[root@localhost omc]# parted /dev/sdc rm 2

Beyond basic creation and deletion, parted can check partitions, resize them, and recover deleted partitions.

Source: WeChat public account "一口Linux"
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxMBRSystem AdministrationGPTdisk partitioningfdiskparted
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.