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.

link|improve this question

60% accept rate
+1, good question. – quack quixote Jan 20 '10 at 14:56
feedback

1 Answer

up vote 4 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).

link|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
Do you have a SATA drive or IDE drive? – John T Jan 20 '10 at 18:09
2  
Found it: "if=/dev/zero" worked, while "if=/dev/null" does nothing. Thanks. – OverTheRainbow Jan 20 '10 at 18:19
show 3 more comments
feedback

Your Answer

 
or
required, but never shown

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