How do you use fdisk to delete a partition?

Updated

We will assume you are modifying the first drive on your system. (To get a listing of your current partition scheme use fdisk -l.

Use the print command (p) to list your partition table:

# fdisk /dev/hda
Command (m for help): p

Disk /dev/hda: 40.0 GB, 40016019456 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot    Start       End    Blocks   Id  System
/dev/hda1   *         1        26    208813+  83  Linux
/dev/hda2            27      4865  38869267+  83  Linux

Use the the delete command (d) to delete a partition, it will prompt you for the partition number. For this example we are going to remove /dev/hda2.

Command (m for help): d
Partition number (1-4): 2

Use the print command (p) to list your partition table again:

Command (m for help): p

Disk /dev/hda: 40.0 GB, 40016019456 bytes

255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot    Start       End    Blocks   Id  System
/dev/hda1   *         1        26    208813+  83  Linux

Finally save and exit fdisk with the write/quit command (w). Changes will be permanent after this command is executed.

Command (m for help): w
Article Type