Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do you delete all partitions on a device from the command line on Linux (specifically Ubuntu)? I tried looking at fdisk, but it presents an interactive prompt. I'm looking for a single command, which I can give a device path (e.g. /dev/sda) and it'll delete the ext4, linux-swap, and whatever other partitions it finds. Essentially, this would be the same thing as if I were to open GParted, and manually select and delete all partitions. This seems fairly simple, but unfortunately, I haven't been able to find anything through Google.

share|improve this question
up vote 19 down vote accepted

Would this suffice?

dd if=/dev/zero of=/dev/sda bs=512 count=1 conv=notrunc
share|improve this answer
This will not delete the partitions. By deleting the partitions he meant to preserve the MBR and just empty the partition table. – Mircea Vutcovici Mar 23 '11 at 19:22
No, this appears to do exactly what I need. I don't really care if the data is still there. GParted shows that the partitions are gone after running this, and that's what I wanted. – Cerin Mar 24 '11 at 11:53
Mircea Vutcovici wasn't talking about your data, but about the bootstrap code in your MBR. That's now gone, because you've erased it along with the 4 primary entries from the MBR-style partition table. – JdeBP May 17 '11 at 11:22
Don't forget to unmount the driver, otherwise it won't work. – OrangeTux Dec 6 '13 at 14:47

Quick and Dirty: use gparted to delete the partitions, or if you’re in a hurry:

dd if=/dev/zero of=/dev/[disk device] bs=512 count=1

This will zap the MBR of the drive (Data is still intact).


dd if=/dev/zero of=/dev/[disk device]

to wipe the whole drive (write a single pass of zeros over everything. Not "secure" but usually good enough), or use a "disk shredder" tool for a secure wipe.

share|improve this answer

See man sfdisk, which is a non-interactive variant of fdisk. Other than that, you can delete the whole partition table with dd, as pk wrote.

share|improve this answer

You should be able to use parted for this aswell, although that may involve some scripting to loop through the partitions.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.