Published on Jun 23, 2025
Complete Guide to Using the Fdisk Command in Linux

Hard disk partition management is an important aspect of an operating system, especially on Unix/Linux-based systems. One of the most well-known and frequently used tools for managing partitions in Linux is fdisk. This article will thoroughly discuss the use of the fdisk command, including its functions, syntax, usage steps, and important tips to avoid fatal errors.
By understanding fdisk, Linux users will have full control over their data storage structure.
What is Fdisk?
fdisk is a command-line utility in Linux that is used to create, modify, and delete partitions on storage devices such as hard disks and SSDs. The name “fdisk” stands for fixed disk. Fdisk has become an integral part of many Linux distributions and is very suitable for disks with the MBR (Master Boot Record) partition scheme.
According to the official documentation of GNU Linux , “fdisk is one of the oldest and most reliable tools for manipulating MBR partition tables on Linux-based systems”.
When and Why to Use Fdisk?
Fdisk is very useful when:
- Installing a new operating system
- Reorganizing partition structure
- Deleting damaged partitions
- Preparing a new disk for use
- Creating a swap partition
Fdisk provides a simple yet effective interface for all of these processes, even though it is text-based.
How to Access and Run Fdisk
Before using fdisk, make sure you have root privileges because making changes to partitions requires administrative permissions.
sudo fdisk /dev/sdX
Replace /dev/sdX
with the name of the disk you want to manage (example: /dev/sda).
Once the command is executed, you will enter fdisk interactive mode. Here are some important commands available in this mode:
m
: Display helpp
: Display partition tablen
: Create new partitiond
: Delete partitiont
: Change partition typew
: Save changes and exitq
: Exit without saving changes
Practical Steps to Use Fdisk
1. Display Disk List
Before you start, display a list of available disks:
sudo fdisk -l
The output will display all disks and their partitions, including size information, file system type, and label.
2. Selecting a Disk to Partition
For example, if you want to partition /dev/sdb
, run:
sudo fdisk /dev/sdb
3. Creating a New Partition
Once in interactive mode, type n
to create a new partition. You will be prompted to choose:
- Partition type: Primary (p) or Extended (e)
- Partition number: Usually 1–4
- Start and end sectors: Or press Enter for default
4. Saving Changes
Once you are done creating the partition, type w
to write the changes to disk.
Important: The changes will take effect immediately and may result in data loss if done incorrectly. Be sure to backup first.
5. Formatting the Partition
Once the partition is created, you will need to format it with a file system such as ext4:
sudo mkfs.ext4 /dev/sdb1
6. Mounting the Partition
Finally, create a mount point folder and mount the partition:
sudo mkdir /mnt/data
sudo mount /dev/sdb1 /mnt/data
- Why is Monero Famous for its High Level of Security Compared to Other Cryptocurrencies?
- Complete Tutorial Using Dropbox for Beginners
- Powerful Way to Get WiFi Handshake with Aircrack-ng
- Cisa Warns of 5 Zero Day Vulnerabilities in Windows That Are Being Actively Exploited
- InvoiceNinja Module: The Complete Guide to Invoice and Finance Management
Safe Fdisk Tips and Tricks
- Always backup important data.
- Use the
fdisk -l
command to verify the target disk before making changes. - Avoid changing the primary system partition while it is active.
- After the changes, use
lsblk
ordf -h
to make sure the partition is recognized by the system.
Fdisk Advantages and Limitations
Advantages
- Lightweight and fast
- Suitable for MBR disks
- Easy to use on headless servers (without GUI)
Limitations
- Does not fully support GPT (GUID Partition Table)
- Not suitable for users who are new to the command-line
For disks with GPT schemes, it is better to use tools such as gdisk
or parted
.
Fdisk Alternatives
In addition to fdisk, there are several other utilities that have similar functions:
parted
: Supports GPT and a more friendly interface- gparted: GUI version of parted
cfdisk
: Text-based interface with menusgdisk
: Specially for GPT disks
Official Citations and References
“Fdisk remains one of the most trusted tools in Linux for managing MBR disk partitions, despite the rise of newer partitioning schemes and tools.” — GNU Project Documentation
“Before creating or deleting partitions, users must understand the impact on the file system and boot loader.” — Linux From Scratch Project
Conclusion
Fdisk is a very powerful tool for partition management on Linux systems. By understanding how it works, its functions, and the steps to use it, you can manage your disk structure more efficiently and safely. Although it seems simple, a small mistake in its use can have big consequences, therefore caution and thorough understanding are very necessary.
Use fdisk when you need full control over your system storage, but do not hesitate to switch to another tool if you feel it is more suitable for certain needs.
With this article, it is hoped that you can use fdisk with confidence and responsibility.