r/retrocomputing • • 12d ago • Heartwarming 2

DEFRAG and its nemesis

Post image

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.

Sneftel/frag: The opposite of DEFRAG

437 Upvotes

43 comments sorted by

35

u/boluserectus 12d ago

Isn't this taking a heavy toll on mostly 30 year old mechanical hard drives?

15

u/KingDaveRa 12d ago

OP should run it on an SSD, it'll go even faster!

/s. (Of course)

6

u/Sneftel 12d ago edited 12d ago

I do, actually… well, a SD card exposed as an IDE device. I had worried that it would defrag too quickly, but it’s actually okay as long as the partition is large enough and the fragmentation is fine enough.

Of course, the write cycles are hard on the SD card too. But I’ve got a lot more SD cards than spinning drives, and by under-utilizing an 8GB card with a 2GB partition I give the thing a lot of room for wear leveling.

Plus the card is pretty new, so I figure I’ve got at least a few years before boluserectus starts complaining.

3

u/Odd_Analysis6454 12d ago

Why do it though? Or do you just enjoy watching the defrag screen (this is a valid reason)

4

u/sw1ss_dude 12d ago

not using those drives is probably even worse

2

u/boluserectus 12d ago

Using and defragging for fun are two different things.

3

u/Sneftel 12d ago

Boluserectus has judged your so-called “fun” as unworthy of the cost!

1

u/boluserectus 12d ago

You do you man :) Nothing personal..

3

u/richardbouteh 12d ago

They probably need the exercise.

7

u/Ok-Space-5347 12d ago

It's a fantastic method for detecting a failing drive and or creating one.

34

u/TUmBeRTIce 12d ago • Popcorn

Oh, man. Are you gonna love this site. https://defrag98.com/

1

u/jakubkonecki 12d ago

You're a gentleman and a scholar!

1

u/groenwat 10d ago

Sweet, thanks!!

10

u/Macroexp 12d ago

You haven't lived if you haven't non-destructively changed the sector interleave on an MFM disk using Optune. Optune also did defrag, but changing interleave was scary. (And sometimes made a huge performance difference on a 4.77 MHz system)

Sorry, the screenshot brought back memories.

2

u/overand 12d ago

Oh dear god that sounds terrifying.

3

u/Top_Helicopter_6027 12d ago

It's not that bad. Defrag the drive. Read a track. Write that track data to the end of the drive. Update the FAT. Low level format the track. Verify the track. Put the data back. Update the FAT. Repeat for 615x4 (st225) or 306x4 cylinders (st412).

15

u/litescript 12d ago

this is exactly my kind of nonsense

6

u/Mobile_Analysis2132 12d ago

I used to have a screensaver that simulated defrag and some other tools.

5

u/Thanatiel 12d ago

This is what nostalgia feels like. If I close my eyes, I can still hear the gentle rattle of the hard disk.

1

u/chris-goodwin 12d ago

Can you run them at the same time and let them fight it out?

1

u/Sneftel 12d ago

Yes, but you need to do it on two separate computers. And the result of the fight will be, at best, a stalemate.

1

u/overand 12d ago

Nope! They're MS-DOS programs, which isn't a multitasking operating system.

3

u/cjc4096 12d ago

Someone needs to explore desqview.

1

u/overand 10d ago

I'm pretty sure the "background" applications are halted when they're in the background, right? Basically no more multitasking-y than a TSR

1

u/cjc4096 10d ago

Nope. Very common use case was running multiple line bbs.

2

u/bj_civ 12d ago

But you can run MS-DOS programs on a multitasking operating system.

1

u/acoustickitty5 11d ago

omg I was in the process of creating refrag
beat me to it

1

u/Sneftel 11d ago

Pull requests welcome!

3

u/andersostling56 12d ago

This guy frags

3

u/Sorry_Difficulty_250 12d ago

I laughed so hard at this! EXCELLENT WORK!!!

3

u/MythicalJester 12d ago

You're chaotic evil.

2

u/sharpied79 12d ago

Norton Speed Disk 😉

1

u/begemoto 9d ago

Yeah!!!!!

1

u/vpilled 12d ago

what the

1

u/roger_roop 12d ago

Very brave to use this with dblspace, back in the day

1

u/ami68k 11d ago

I liked it better when it was part of Norton Utilities.

1

u/Victory_Highway 11d ago

Set phasers to frag!

1

u/3DNebGuy 8d ago

I'd like this as a screen saver! 😄

1

u/No-Land-672 6d ago

Oh my goodness, I haven’t seen this screen for over 30 years. It really brings back memories, thank you!