How to Delete Partition in Linux

September 30, 2020

Introduction

Linux users create partitions to organize their data in an efficient manner. As easy as they are created, Linux partitions can be deleted to reformat a storage device and regain storage space.

In this step-by-step tutorial, you will learn how to delete a partition on a Linux system.

How to Delete Partition in Linux

Prerequisites

  • A system running Linux
  • A user account with sudo or root privileges
  • Access to a terminal window / command line (Activities > Search > Terminal)
  • The fdisk command-line utility

Delete a Partition in Linux

Deleting a partition in Linux requires selecting the disk containing the partition and using the fdisk command-line utility to delete it.

Follow the steps outlined in the sections below to delete partitions in Linux.


Note: The fdisk command-line utility is a text-based partition table manipulator. It is used for partitioning and repartitioning storage devices.


Step 1: List Partition Scheme

Before deleting a partition, run the following command to list the partition scheme.

fdisk -l

In our case, the terminal prints out information about two disks: /dev/sda and /dev/sdb. Disk /dev/sda contains the operating system, therefore its partitions should not be deleted.

Listing the partition scheme

On the /dev/sdb disk, there is a /dev/sdb1 partition which we are about to delete.


Note: The number 1 in /dev/sdb1 indicates the partition number. Make a note of the number of the partition you intend to delete.


Step 2: Select the Disk

Select the disk that contains the partition you intend to delete.

Common disk names on Linux include:

Type of diskDisk namesCommonly used disk names
IDE/dev/hd[a-h]/dev/hda, /dev/hdb
SCSI/dev/sd[a-p]/dev/sda, /dev/sdb
ESDI/dev/ed[a-d]/dev/eda
XT/dev/xd[ab]/dev/xda

To select a disk, run the following command:

sudo fdisk /dev/sdb
Selecting storage disk with fdisk command.

Step 3: Delete Partitions

Before deleting a partition, back up your data. All data is automatically deleted when a partition is deleted.

To delete partition, run the d command in the fdisk command-line utility.

The partition is automatically selected if there are no other partitions on the disk. If the disk contains multiple partitions, select a partition by typing its number.

The terminal prints out a message confirming that the partition is deleted.

Deleting partition.

Note: If you wish to delete multiple partitions, repeat this step as many times as necessary.


Step 4: Verify Partition Deletion

Reload the partition table to verify that the partition has been deleted. To do so, run the p command.

The terminal prints out the partition structure of the disk selected in Step 2.

Partition table reload.

Step 5: Save Changes and Quit

Run the w command to write and save changes made to the disk.

Quitting fdisk command-line utility and saving changes to the disk.

Conclusion

After following the instructions in this tutorial, you should have learned how to delete a partition in Linux.

If you want to learn more about partition manipulation, we recommend reading our tutorial on creating partitions in Linux or if you are running NTFS partitions, check out our article on how to mount NTFS partitions in Linux.

Was this article helpful?
YesNo
Dejan Tucakov
Dejan is the Head of Content at phoenixNAP with over 8 years of experience in Web publishing and technical writing. Prior to joining PNAP, he was Chief Editor of several websites striving to advocate for emerging technologies. He is dedicated to simplifying complex notions and providing meaningful insight into data center and cloud technology.
Next you should read
How to Create Partitions in Linux
September 23, 2020

In Linux systems, in order to use storage devices such as Hard Drives and USB drives, you need to understand...
Read more
How to Use the sudo Command in Linux
August 18, 2020

sudo stands for SuperUser DO, and it's used to temporarily elevate privileges in Linux. This guide will show...
Read more
19 Crucial Linux ls Commands to Know
July 30, 2020

The ls command (short for list) lists information about directories and any type of files in the working...
Read more
Linux Commands Cheat Sheet: With Examples
November 2, 2023

A list of all the important Linux commands in one place. Find the command you need, whenever you need it or...
Read more