Linux: How to delete a partition with fdisk command

Linux: How to delete a partition with fdisk command

To delete a partition with the fdisk command on a Linux system, you will need to start the fdisk utility and use the d command to delete the partition.

Here's the basic syntax for the fdisk command:

fdisk device
Sou‮:ecr‬www.lautturi.com

device is the name of the block device that you want to partition, such as /dev/sda or /dev/hda.

Once you have started the fdisk utility, you can use the p command to view the current partition table, and the d command to delete a partition.

fdisk /dev/sda
p
d

The fdisk utility will prompt you to enter the number of the partition that you want to delete. You can use the p command to view the list of partitions and their numbers, and then enter the number of the partition that you want to delete when prompted.

Once you have deleted the partition, you will need to use the w command to write the changes to the partition table and exit the fdisk utility.

w

It's important to note that deleting a partition with the fdisk utility will erase all data on the partition. Make sure that you have backed up any important data before deleting a partition.

It's also a good idea to be cautious when using the fdisk utility, as it is easy to accidentally delete the wrong partition or make other changes to the partition table that could cause problems with your system. It is always a good idea to double-check your changes before writing them to the partition table.

Created Time:2017-10-30 10:17:45  Author:lautturi