chkdsk considered harmful

This list of sysadmin horror stories reminded me of a story of my own:

A long, long time ago, possibly as much as fifteen years ago, I wrote a boot loader of which I’m still quite proud, even though I’ve long since lost the code. I also wrote an installer for it, naturally. The binary was very small (a few kilobytes), even though it included a command-line interface, a partitioning tool, a screen saver and a game, so instead of installing it in a separate partition, I simply installed it in the space between the MBR and the first partition, which on a DOS system in those days was on the order of 30 kB for completely idiotic reasons.

At some point during the development, inevitably, either due to a bug in the installer or incorrect command-line parameters, I managed to install the loader on top of the FAT on one of my DOS partitions.

OK, DES, don’t panic. DOS keeps a second copy of the FAT immediately after the first, and since the FAT on that partition is much larger than the boot loader, it should be undamaged. Just run chkdsk to restore it and…

Primary and secondary FAT inconsistent.
Update secondary FAT? (y/n)

(not verbatim, my memory isn’t that good)

Yep, chkdsk‘s proposed solution was to overwrite the backup.

I ended up doing the math on a piece of paper and using debug.com to restore the primary FAT from the backup.

I still maintain that debug.com is the best piece of software Microsoft’s ever published. Or possibly second best, after edlin.com.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.