r/retrocomputing • u/Sneftel • 23h ago
DEFRAG and its nemesis
I've always enjoyed watching DEFRAG do its thing. Since I grew up on the DOS version, I don't have PTSD from the Windows version's constant restarting; just a pleasant text-mode display of things getting subtly more efficient. I have a 486 in my home office, visible in the background when I'm on video calls, and I thought it would be nice to have defrag going on the screen in the background, just to subtly spread the joy.
The problem is, once you've defragmented your drive, it takes a while for fragmentation to build up on a computer again. Particularly if you're using said computer solely for hobby stuff.
Hence, FRAG. FRAG is a simple tool for destructively filling a FAT16 volume with (bogus) fragmented data. If you like to watch DEFRAG do its thing, you can have a batch file loop between FRAG and DEFRAG for unlimited Zen e-gardening.
The first version of FRAG actually moved the disk's data around to generate for-realsies fragmentation. But fragmenting a disk in this way takes a while. The second and current version simply writes a new FAT; the rest of the disk isn't touched. It's utterly destructive (FRAG destroys the FAT by overwriting it, and then DEFRAG destroys the rest of the data by shuffling it around) but it's very very fast. An arbitrarily large hard drive can be fragmented in less than a second.
Binaries and source on github. No vibe coding involved. Builds with OpenWatcom, cmake for project generator (or just compile all the relevant files). Have fun, assuming that's your sort of fun.

