WipeMBR - a DOS util to wipe your MBR

By: Frank Rysanek of FCC Prumyslove systemy s.r.o., Czech Republic
e-mail: rysanek AT fccps DOT cz


Actually it can do a bit more: it allows you to backup/restore the whole MBR or just the executable MBR code to/from a file. Or to delete the executable code from the MBR, while keeping the partition table intact (= the original purpose and motivation).

It also works for floppies. Which can be useful for turning modern-day "dangerously dedicated" USB Flash drives (no partition table) from this "floppy mode" into proper hard drive format. If you ever wondered, why DOS doesn't allow you to "fdisk" a USB flash drive (not visible as a hard drive), it might be, that the drive is "formatted as a floppy" = no partition table, FAT boot sector directly in LBA sector 0. The drive would then be presented by the BIOS as a floppy (device 0,1,etc) rather than a HDD (device 0x80,0x81,etc) and DOS would try to present such a floppy as drive letter A or B (and can ultimately fail to access the volume, if your DOS is 6.22 and the filesystem on the USB drive is FAT32). Wipembr allows you to check what HDDs and floppies are reported by your BIOS, and to wipe the sector 0 even on a "floppy" (your USB drive "mis"detected by your BIOS as a floppy). After another reboot, your BIOS should autodetect the USB drive as an HDD, just based on the empty sector zero. Note that drive letter C: won't appear just yet - you have yet to fdisk the drive :-)
If you need a confirmation that the wipe succeeded, try starting wipembr (just to have a look at what it detects) or fdisk (does it offer the "select physical drive" option?) or if you have FreeDOS, it should now report the drive and its partitions (initially none) when the FreeDOS kernel boots.
Caveat: some BIOSes disable int13h extensions, if there's no hard drive (or "hard drive") in the system. Thus, if you boot from a floppy, or from a floppy image via ISO or PXE, and you need to "unfloppy" a preformatted USB stick, that may be bad luck - wipembr in its current version won't work without int13 extensions. In those cases, there's a possible workaround: you need to boot DOS from some hdd-like media (e.g. USB or PXE image including a partition table) or even just have some scrap hard drive attached in the system...

History and original motivation of wipembr:

On one occasion, I found myself in a situation where I needed to prevent a silly BIOS from trying to boot from a particular hard drive in my system. The drive in question is a data-only drive and it tends to take precedence over the dedicated system drive in the BIOS boot sequence, as I shuffle the various pluggable drives in my system. (The BIOS shuffles the boot sequence automagically on every boot, based on the set of devices it finds attached - ah well.)

What I found out was that, if I remove the 1st-stage NT bootloader (executable code) from the drive's MBR, the BIOS won't try to boot from that drive - and the drive remains perfectly functional in its role of a data-only disk (as long as the partition table in the MBR remains intact). Just removing the "active" flag from the NTFS partition doesn't make a difference.

The problem is precisely that the BIOS omits all the other bootable hard drives, even though the NT 1st-stage apparantly tells it (via INT 19h?) that there's nothing to boot on that data drive. The BIOS is willing to boot from PXE, but not from the other hard drives :-/

I first verified the hack in Linux (all you need is dd). Next, I tried a dd port for Windows (the one from Chrysocome.net), but XP SP3 refused to let me touch the MBR. So to make the "wipe" operation easier, I ended up writing a single-purpose dedicated util for plain DOS.

Boot FreeDOS from a USB key, run the proggie, and a few questions later, "hey presto". 1st-stage gone. I call the program "wipembr", inspired by the Windows recovery console's "fixmbr" :-)

Apart from wiping the executable code or the whole MBR (useful to make the drive appear "clean"), the proggie can also save the MBR to a file, or restore it from file, or save/restore just the executable code alone (leaving the partition table data intact). This might be handy to add/restore the Windows 1st stage without booting into the recovery console. Or, e.g. to edit some details of the MBR, e.g. in the Volkov Commander's built-in hex editor :o)

As the tool runs in DOS, using Int 13h BIOS extended disk services, it doesn't need hardware-specific drivers for the particular disk controller (as long as the controller comes with a BIOS option ROM of its own).