Removing the MBR/partition information

Note: By running any of the following commands you may cause your system to become un-bootable. Best make backups of the MBR prior to trying anything within. Use at your own discretion.

URLs:

Ben Okopnik wrote a good article on the linux gazette site called “Clearing out the Master Boot Record”. I was wanting to clear the MBR/partition information so that I could reboot the system and re-intstall using DHCP/TFTP/bootp etc… The BIOS is set to boot of USB-CDROM->HDD->Net/None. So, unless the system failed to boot/find the MBR I couldn’t rebuild. (The system was remote and only reachable via the installed TCP/IP settings and respective OS’s).

It turns out it’s fairly simple to delete the MBR from within Linux:

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

The above dd command deletes both the MBR and disk partition information on device hda. Ideal for what I wanted. You could of course backed up your MBR with:

dd if=/dev/hda of=mbr.bin bs=512 count=1

So, after rebooting the linux system it started building off the build server.

Windows was a little bit harder to find information about deleting the MBR. On the Linux Gazette article it said:

DOS-based solution

Boot with a DOS floppy that has “debug” on it; run “debug”. At the ‘-‘ prompt, “block-fill” a 512-byte chunk of memory with zeroes:

f 9000:0 200 0

Start assembly mode with the ‘a’ command, and enter the following code:

mov dx,9000
mov es,dx
xor bx,bx
mov cx,0001
mov dx,0080
mov ax,0301
int 13
int 20

Press <Enter> to exit assembly mode, take a deep breath – and press “g” to execute, then “q” to quit “debug”. Your HD is now in a virgin state, and ready for partitioning and installation.

Although I could type in all the commands I kept hitting an exception when I pressed “g” to execute. Windows would send a popup box saying something along the lines of “NTVDM encountered a hard error”. After rebooting the system came up so the above doesn’t work unless you boot up using a boot disk.

After a bit more searching I found TestDisk which is:

TestDisk is a powerful free data recovery software! It was primarily designed to help recover lost partitions and/or make non-booting disks bootable again when these symptoms are caused by faulty software, certain types of viruses or human error (such as accidentally deleting a Partition Table). Partition table recovery using TestDisk is really easy.

Using this software on Windows it allowed the deletion of the MBR/partition table by simply downloading, extracting and running one command.

Rebooting the system now allowed me to get on with re-installing the machine over the net.

Leave a Reply

Your email address will not be published. Required fields are marked *