Super User is a question and answer site for computer enthusiasts and power users. 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

For testing purposes, I need to fidget with the MBR on a Windows7 test host: I'd like to remove the Master Boot Code but leave the Partition Table within.

Does the following Linux command do this, or does it wipe out the entire MBR, including the Partition Table?

dd if=/dev/zero of=/dev/hda bs=512 count=1

Thank you.

share|improve this question
+1, good question. – quack quixote Jan 20 '10 at 14:56
up vote 6 down vote accepted

That command will remove the partition table. If you want to remove the MBR and keep the partition table:

dd if=/dev/zero of=/dev/hda bs=446 count=1

See Wikipedia's MBR page for the MBR layout. The primary partition table starts at byte 446 (counting from zero).

share|improve this answer
Thanks guys for the help. – OverTheRainbow Jan 20 '10 at 14:53
to be on the safe side i'd use bs=440, tho i'm not sure if windows uses that 4-byte optional disk signature area as signature or the tail end of its boot code. – quack quixote Jan 20 '10 at 14:54
Booting with a Debian 2.6.32-based live USB Linux, I "sudo -s" to root, and ran the command... but it says "0 bytes copied", although I checked that the /sda partition is not mounted. Has someone seen this? – OverTheRainbow Jan 20 '10 at 17:45
Found it: "if=/dev/zero" worked, while "if=/dev/null" does nothing. Thanks. – OverTheRainbow Jan 20 '10 at 18:19
right. pulling data from /dev/null probably gets an immediate EOF. – quack quixote Jan 20 '10 at 18:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .