How to clear/delete all the partition table from a disk or partition in Linux

How to clear/delete all the partition table from a disk or partition in Linux

Below article is a must read to understand all about partition, partition scheme and partition table

Everything you need to know about a partition, types of partition, partition scheme

To clear a partition table, wipefs command can be used

How to clear/delete all the partition table from a disk or partition in Linux

Here I have a disk /dev/sdb which I have added to my Linux box for this article.
In this disk I have created two primary partitions

# fdisk -l /dev/sdb

Disk /dev/sdb: 17.2 GB, 17179869184 bytes, 33554432 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x1410600c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     4196351     2097152   83  Linux
/dev/sdb2         4196352    10487807     3145728   83  Linux

Now I would like to clear the partition table from this disk
To do so below commands can be used

Check the partition table

# wipefs /dev/sdb
offset               type
----------------------------------------------------------------
0x1fe                dos   [partition table]

Here I have a dos partition table

Clear the partition table

Using the below command you can wipe "dos" partition table

# wipefs -a -t dos -f /dev/sdb
/dev/sdb: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
/dev/sdb: calling ioclt to re-read partition table: Success

If I had a GPT partition table then to clear the same

# wipefs -a -t gpt -f /dev/sdb

To clear all the partition tables

# wipefs -a -f /dev/sdb

You can also delete a partition table using the offset value as shown above

# wipefs -o 0x1fe /dev/sdb

Once the above command returns success, check the partition table using fdisk

# fdisk -l /dev/sdb

Disk /dev/sdb: 17.2 GB, 17179869184 bytes, 33554432 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

As you both my partitions are cleared/deleted.

Also read:

I hope the article was useful.

1 thought on “How to clear/delete all the partition table from a disk or partition in Linux”

Leave a Comment