You can delete a partition in Linux using the fdisk, parted or gdisk command-line utilities, depending on the partition table format (MBR or GPT) and your preference. Here are the steps for each utility:
Note:
Deleting a partition will result in data loss, so make sure you have a backup of any important data before proceeding.
Using fdisk (for MBR Partition Table):
1.Open a terminal window of the machine which you want to delete a partition and identify the partition which you want to delete. Before deleting, if it’s mounted into directory, make sure to unmount it.
2. List the partitions on your disk using the following command. Replace /dev/sdX with the appropriate device identifier (e.g., /dev/sda):
sudo fdisk -l /dev/sdX
Identify the partition you want to delete.
As you can see from the above previous figures, the partition /dev/sda7 is not mounted into any directory and going to delete that partition.
3. Run the fdisk command on the disk containing the partition you want to delete:
sudo fdisk /dev/sdX
4. Inside the fdisk utility, press “p” to list the partitions again and confirm the partition number you want to delete.
5. Press “d” to delete a partition, followed by the partition number (e.g., “1”`) you want to delete.
6. Press “w” to write the changes to disk and exit “fdisk”.
Using “parted” (for MBR or GPT Partition Tables):
1. Open a terminal window.
2. List the partitions on your disk using the following command. Replace “/dev/sdX” with the appropriate device identifier (e.g., “/dev/sda”):
sudo parted /dev/sdX print
Identify the partition you want to delete.
3. Run the parted command on the disk containing the partition you want to delete:
sudo parted /dev/sdX
4. Inside the parted utility, use the following commands to list and delete a partition:
(parted) print
(parted) rm PARTITION_NUMBER
Replace PARTITION_NUMBER with the number of the partition you want to delete.
5. Type quit to exit parted.
Using “gdisk” (for GPT Partition Table):
1. Open a terminal window.
2. List the partitions on your GPT disk using the following command. Replace “dev/sdX” with the appropriate device identifier (e.g., “/dev/sda”):
sudo gdisk /dev/sdX
3. Inside the gdisk utility, press “p” to list the partitions and identify the partition you want to delete.
4. Press “d” followed by the partition number (e.g., “1”) to delete the partition.
5. Type “w” to write the changes to disk and confirm the deletion.
6. Type “Y” to confirm the deletion.
After completing these steps, the selected partition will be deleted, and the space it occupied will become unallocated. You can then create a new partition or resize existing partitions as needed.
Click here!! to know how to create a logical partions in linux.
How do you feel about this post? Drop your comments below..