Linux allows you to create disk partitions to organize data in an efficient manner. However, sometimes you may need to delete partition in Linux in order to free up disk space, or merge it with other partitions. Here are the steps to delete partition in Linux.
How to Delete Partition in Linux
Here are the steps to delete partition in Linux. We will use fdisk command to delete our partition. Before you proceed further, please make sure to backup all important data present on your partition.
1. List all disk partitions
Open terminal and run the fdisk command to list all disk partitions. If you get ‘permission denied’ error, add sudo keyword at the beginning of the command, as shown below.
$ sudo fdisk -l
2. Select the disk partition for deletion
Next, select the disk partition you want to delete. Here are the common disk partition names.
|Type of disk||Disk names||Commonly used disk names|
Let us say you want to delete /dev/sdb then run the following command to select it first.
$ sudo fdisk /dev/sdb
3. Delete Partition
When you run the above command, you will see a prompt as shown below, asking you to enter the command to be executed.
We will enter d to delete the partition.
If there is only 1 disk partition, fdisk will select it automatically. Otherwise, you need to enter the partition number. After deletion, you will see a conformation message. If you want to delete another partition, enter d again, else enter p to list all available partitions at the moment.
4. Save and Quit
If you want to quit, enter w key. It will save changes & quit.
In this article, we have learnt how to delete Linux disk partition.