Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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
3  
Found it: "if=/dev/zero" worked, while "if=/dev/null" does nothing. Thanks. –  OverTheRainbow Jan 20 '10 at 18:19
1  
right. pulling data from /dev/null probably gets an immediate EOF. –  quack quixote Jan 20 '10 at 18:22

Your Answer

 
discard

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.