In Linux, the storage devices are divided into various sections called “Partitions”. Each partition behaves independently and can be created and deleted easily without affecting other partitions. Deleting and creating partitions is a regular job because it is important to manage and free up the storage device before its usage.
Considering its importance, this guide demonstrates the possible aspects of deleting a partition in Linux with the following outline:
- Method 1: Delete a partition Using Terminal
- Method 2: Delete a partition Using Ubuntu Software Center
Method 1: Delete a partition Using Terminal
In Linux, the “fdisk” and “cfdisk” are the interlinked utilities to manage the disks/partitions. Both have the same functionalities but with different interfaces.
Method 1.1: Through the “cfdisk” Command
The “cfdisk” is utilized to create, modify, and delete partitions on a disk device. It is a covenant and user-friendly partitioning tool because it displays the disk partition table in a text-based “graphical” interface.
Follow the step by step by step instructions to delete the specific partition from the disk.
Step 1: Choose the Partition of the Specific Disk
First, we need to choose the specific partition of any disk to be deleted. To do so, the “cfdisk” utility will list down all the disks and partitions of the system as follows:
$ sudo cfdisk
The above command pops up a text-based graphical interface from which the “/dev/sd4” is selected using the “down-arrow” key.
Step 2: Delete the Partition
As the above window also contains some options in the end that can be assessed through the “left/right” arrow keys. In this case, use the “left-arrow” key to move on to the “Delete” option and press the “Enter” key:
Step 3: Write the Changes
Navigate to the “write” option and press the “Enter” key. It will confirm the above operation and fully delete the “/dev/sda” from the disk “/dev/sda”:
Type the “yes” to continue the process:
Here, the highlighted message confirms that the “/dev/sda4” partition has been deleted completely, and the “partition” table has been altered.
Method 1.2: Through the “fdisk” Command
The “fdisk” stands for the “format disk” and has the same functionality as the “cfdisk”. The process is the same but emphasizes the command line interface.
Step 1: Choose the Disk Devices
We can list the disks devices and their partitions with the help of the following “fdisk” command:
$ sudo fdisk -l
The partition we want to delete belongs to the “/dev/sda” disk.
Step 2: Delete the Partition
Once the device is chosen, use the following command to start operating on that device:
$ sudo fdisk /dev/sda
Type the “d” at the pointer place to open the “partition menu”. It will indicate the partition number that the user wants to delete and press the “Enter” key:
In this scenario, partition number 33 is entered to delta the “/dev/sda33” partition:
The message highlighted in the output verifies that the “d” option has successfully deleted the “/dev/sda33” partition
Step 3: Write the Changes
To save the changes in the partition table, type the “w” into the console. It will reboot the system and save the new changes:
It is verified that the partition table has been altered after deleting the “/dev/sda33” partition from the device “dev/sda”.
Method 2: Delete a Partition Using GParted (GUI Method)
The “GParted” application is the software tool to reorganize the partitions in Linux. Some essential steps are explained in this section to install and use the “GParted” application on your Linux system.
Prerequisites: Install “GParted” Application on Linux
Firstly, open the “terminal” and execute the following commands according to your Linux distribution for the installation of the “GParted” tool:
$ sudo dnf install gparted # For Fedora $ sudo pacman -S gparted # For Arch $ yum install gparted # For CentOS/RHEL $ sudo apt install gparted # For Ubuntu/Debian-Based
The “GParted” application is installed successfully into “Ubuntu 22.04”.
Step 1: Open the GParted Application
Open the “GParted” application from the applications menu of the system.
Type the “root-user” password for authentication privileges. After that, it will open with an interface like this:
Step 2: Delete the Particular Partition
The above “GParted” window displays the “Partition Table”. Right-click on the particular partition (user’s choice) and choose the “Delete” option:
In the result, the foot bar displays that “1 operation is pending”. Click on the highlighted green “Tick” icon to fully delete the “/dev/sda5” partition from the disk:
Here, the green check mark pop-ups a confirmation box that confirms the deletion of a specified partition. Tap on the “Apply” option as shown below:
The new changes have been applied by clicking on the “Apply” button. It has completed the pending task and also deleted the “/dev/sda5” from the disk “/dev/sda”:
After that, press the “Close” button:
Hence, it is verified that there is no more “/dev/sd5” partition in the “Partition Table” of the “/dev/sda” disk as shown in the above image.
That’s all about the possible ways to delete a partition in Linux.
Linux provides the “fdisk” and the “cfdisk” utilities to delete a partition from the device. Both utilities have the same purpose and functionality but differ in the interface. Apart from these, the “GParted” GUI application can also delete a Linux partition. This post has listed all possible methods to delete a Linux partition.