Hacker News new | ask | show | jobs
by ioman 1645 days ago
I remember the sense of deep satisfaction and virtue when I defragged my hard drive. Then I learned FreeBSD. I kept trying to figure out how to defrag the partitions. When I learned that the filesystem took care of it continuously my mind was blown.
8 comments

That would have been a strong reason for me not to use FreeBSD. It's like taking someone who says, "I have a stressful job. The only time I can really relax and feel worry-free is when I'm cooking."

And then hiring a personal chef for that person. Sure, the food will taste better, but at what cost? At what cost?

(Actually watching defrag stopped being satisfying around the time that I got my first 50GB HDD. It took too damn long to watch, like a 2 year old playing Tetris in slow motion)

> That would have been a strong reason for me not to use FreeBSD.

Well, with this new website, you can now enjoy defraging without having to suffer the consequences of a bad file system.

Yeah, but it's like a gambling addiction. If there are no stakes, no risk of loss? ... ... It takes the heart out of it. It's just not the same.

Maybe I should just defrag my SSD's these days. Sure they don't need it's but it's fast and bad for the drive, which gives it that same thrill of gambling with the integrity of my data. Of course I'd need to disable cloud backups to backblaze and local backups to a raid array, but if I try then I think I can still chase the thrill of the 'frag.

SSDs don't need to get defragged, but it needs occasional trimming, and that can be done either continuously, or batched. Sadly, there's no fancy graphical application to show you what was trimmed in the batched version.

If you use a filesystem with checksums, you can also scrub it. The stakes are there: is my data bit rotted? Will the errors resist recovery? It also takes about the same time as the defrag, but again I don't know of any graphical tools.

Make a 'defrag monkey' script. Take a random file, read it into the RAM, delete the source file, write it back.
I think that I'm happy with:

    xfs_fsr -v
With Linux and BSD I stopped gaming on AAA titles and I went full indie long ago.

Even "worse", now I an translating some English text adventures into Spanish.

And by playing them OFC.

Today I have more fun doing actual projects (programming, writting, playing with teleco stuff) than badly simulating then in video games.

With DOS/Windows you simulated a life on games. With Linux, you made it real. Seriously. Slackware it's still a "game changer. You don't play Cyberpunk 2077 if you want, you can make it real life. I do that with the PocketCHIP, Gopher and text gaming/roguelikes/MUDs up into a mountain at night. Incredible experience.

Or better, listening to the ISS with a WebSDR and decoding SSTV images with QSSTV. That's the ultimate cyberpunk experience.

On freebsd you can build/update ports instead of defragmenting your disk.
And then spend hours fixing the system, which I guess is like if the defragmenter corrupted your files
Never had that problem....not since years at least.
gtk3-webkit got updated again? There goes my day.
No ccache?
haha...true, time to fire up all the distcc machines ;)
I've noticed that myself, that capacity increased much faster than throughput. It would be interesting to see this graphed over time.
The number of tracks per platter increased, but the RPM didn't. Assuming the heads can only read one track at a time per platter, it will take (number of tracks per platter / rpm) minutes to read the whole disk. Therefore it will take longer to read the whole disk. QED
Drives don't read from multiple platters in parallel, so it's actually num_tracks * num_platters * 2 / rpm to read in the best case. Real world is more than that since it takes time for the drive firmware to shift between different platters and tracks.

*edit: not entirely true: the Seagate MACH.2 drive series that has 2 separate head assemblies per drive. They're pretty expensive and hard to get ahold of.

> defrag stopped being satisfying around the time that I got my first 50GB HDD

In the rare circumstances when I was in need of actual defrag of a heavily polluted drive > 40Gb I opted to take a filesystem aware image with Norton/Symantec Ghost and just re-image it back. Worked fine and by the time of 100-200Gb drives there were a USB HDDs so I wouldn't even need to unscrew the PC case.

You could always make a ramdisk and defrag that.
boy. i remember moving to xp and a visible disappointment after finding out it didn't have defrag like 98se did.
My mid 90s is FreeBSD. Two floppies and a 14.4k on the install. 486 66dx2 with 20 megs of ram and the thing cooked. I used that server up until 2002 as a proxy server (this is before the age of updating software for security). I finally didn’t need it, it simply never broke.
For me it was late 90s. A friend of the family bought for me Walnut Creek's FreeBSD CD set, with all the stickers and other goodies. They sent it all the way to my godforsaken small town in Mexico. As a 12 year old it was soooo cool. I remember spending hours installing (incluing configuring and compiling the kernel in an ncurses based interface). I printed the whole FreeBSD manual and my mom bound it for me.

Great times!

The printed FreeBSD Handbook with the 2.5 CD-ROM was amazing at the time. An open source OS with a book that was better than some of the commercial OS offerings. We setup the colleges first mail server with that combo.
Would you have been able to get FreeBSD otherwise? Like, mid 90s I remember downloading Slackware from a BBS. Floppy after floppy. Was that available in your area at the time?
I dont think so. BBSs were not really a thing in Mexico... particularly in a city as small as mine. Maybe in Mexico city. But long distance calls were super expensive (mom used to talk to my grandma living in another city only once a week for 30 mins).

I think I might have been able to get something in the local public university computer centre. It was the beginning of the internet (14.4 modems min to connect to the university, which was the only internet provider)

Great fun times!

Remember those times.

Some PCs just last. A 2.4 GHz Core2 Quad I had, I think from 2008, is still going strong and can run most modern software just fine.

It's amazing how little progress there has been in last 13 years. In the nineties you had to upgrade every two years or so just to be able to run current software.

I think 2021 computer has a good chance of being still completely usable in 2040.

That is probably the Q6600, I had it as well. Very good CPU at the time and I think I had it for 6-7 years as my main computer. The next time I got an (quite expensive) 6-core CPU. And the difference was mindblowing. Not because of the extra cores but the responsiveness and single-core performance was out of this world.

I'm currently building my next computer, and the difference again is just staggering. And that is not even factoring in that the next one has got 12-cores.

It is not that the progress hasn't been slow (I guess it has if you compare it to the pace of the past), but I think it has more to do with computers back then still being very capable.

You can still fire up some CAD software and do proper work on the Q6600. I mean, right until you want to listen to music or do some very light web browsing. Then it will suddenly become quite painful. The amount of waste in today is incomprehensible. No seriously, properly incomprehensible.

> You can still fire up some CAD software and do proper work on the Q6600. I mean, right until you want to listen to music or do some very light web browsing. Then it will suddenly become quite painful. The amount of waste in today is incomprehensible. No seriously, properly incomprehensible.

I recently set-up my old Q6600 as a station for CNC machinery, that thing flies with LinuxCNC on a small SSD. There's no issue running firefox and a music player at the same time (though I tend to not have other things running when milling something but more by cargo-cult than actual tests of the impact on the real-time behaviour needed for the CNC machine control). Some operations on Inkscape are of course slower than on more recent hardware but otherwise it's still very useable.

Obviously was some hyperbole, but still, running spotify on a 12core cpu with 64 GB ram and a top of the line SSD and an internet connection that is faster both in access time and bandwidth than a harddrive from 14 years ago is still slower than winamp on a machine from 2008.

And of course you can surf the web. But even with 5GHz turbo it is still slower than a fast connection was in the late 90s (on 90s hardware and browser). And it has nothing to do with that progress hasn't advanced in that time (we are talking orders of magnitude).

Spotify’s web app is horrible for performance. Even when idle, it keeps several cores fully occupied. They do not care to fix it either, as it has been this way for as long as I have used them. I even reported the issue multiple times and got nothing but a canned response. They just do not care.

Absolute garbage, and entirely representative of all other consumer class software.

Yeah, also using a recent 8-core Ryzen and the difference is definitely obvious for more demanding tasks. Been considering Threadripper, but I this is plenty fast.

I do think I could still manage on Q6600 with 16 GB RAM and an SSD. Might need to downscale VMs and browser tabs, but manageable in a pinch. Heck, in the early nineties I was happy to have an Amiga with 1 MB of RAM and that thing flew in comparison to C64. :-)

I'm still using an overclocked i5-2500K circa 2011 in my desktop. It does everything fast enough for me (even modern games). I haven't felt the need to upgrade.
I was planning on upgrading my 3570K five years ago. I'm still running it.
Intel Q6600 I presume? Great CPU. PC I a built in 2008 has the same. I recently retrieved it from my parents’ attic and updated it to Windows 10 - still works like a charm.
Got a Core2 Duo and 8 gigs of RAM since 2009. Added an SSD years ago and a better GPU and the thing remains just as fast as any other laptops (I run Linux so I guess it's lighter on resource than Windows but not sure). I use that computer 10 hours a day for all my stuff (no gaming though). I just hope the PSU won't fry everything when it'll die.
Jokes on you. I'm currently using a Q9400 as my daily driver :-) What you say is totally right, and the only thing that feels slow is 1080p 60 fps video decoding in web browsers, because it has to do it in software AFAIK.
My Main-PC is now 11-12 years old, it's a HP Z600 upgraded to the max, buy'd a second CPU for 15$ additional 24GB ram (now 48GB) for like 100$ and a new GPU for 350$ some time ago, and it still runs like a champ.
Also got one HP Z-something (can't remember) PC, a bit later with a Xeon CPU (or two?) with 24 GB RAM. Otherwise great, but it's very power hungry, heats up a room in a hurry.
I always liked to game and even with running everything on Medium or Low I needed to upgrade my PC every 3-5 years. But now, my CPU is from 2012 and my video card is from 2017, and I'm fine.
I had a FreeBSD doitall-machine from 1998 to 2006 on some Pentium-ish thing with an AT motherboard. Moved a few thousand miles and it didn't get unboxed, until 2020 when I needed an AT PSU for something unrelated. Prior to cannibalizing it I powered it up long enough to check that it would still send email and run brief X session to hit YTMND in 15 year old Firefox.
And my disappointment in btrfs when it reminded me of how long it took to defrag a hard drive was limitless. 100 out of 500 GB used, free disk space 0, had to spend an afternoon running rebalance with various parameters to get to a point where it could run a full rebalance without running out of memory. Of course our IT seems to love it since it comes with all possible bells and whistles so I already dread the next time it happens.
Is this anecdotal of some years ago or recent? Are they running a really old kernel? btrfs had this sorts of problems, but some major fixes in this regard have been committed like two years ago.
The issue was earlier this year, but the systems I saw it on were probably both LTS with an older kernel.Good to know that it was fixed.
No probably no a old kernel....but i know like everyone btrfs...that never happened to me.
This looks like Norton Utilities' Speed Disk. My 8-year-old self really thought that rearranging blocks to be sequential really made the disk faster.

In reality though, the increase in performance was barely noticeable.

Aren’t you selling it short? Spinny disks, especially in the days before NCQ/TCQ have a vast imbalance between reading sectors sequentially and positioning the head to a new track. NCQ/TCQ later helped a bit by optimizing the path the head takes (With Physics!) when multiple operations are in the queue, but a completely fragmented disk drive seems like it will underperform noticeable against one where everything is laid out neatly in a linear fashion, at least in some access patterns (reading large files in one go).

But I’d be interested in any real data anyway.

I can't conduct the experiment anymore obviously, but to qualify my perceptions -- if you try to do a linear read from a 90% fragmented filesystem, performance would definitely suck and defragging would obviously provide perceptible benefit.

Most of the time however, my disk was probably only about 30% fragmented (if I recall correctly from Speed Disk). I was running DOS on a FAT file system where there was no swap file or anything that would cause massive fragmentation except deleting and installing programs, and maybe some temp files created by certain programs. The performance delta for me was barely noticeable on a 40MB Seagate IDE drive.

> I can't conduct the experiment anymore obviously

Why not?

  $ virt-make-fs --type=msdos /usr/share/doc /var/tmp/disk.img
  $ export file=/var/tmp/disk.img
  $ nbdkit eval \
       after_fork=' echo 0 > $tmpdir/read ' \
       get_size=' stat -Lc %s $file ' \
       pread='
           diff=$(($4 - `cat $tmpdir/read`))
           echo $4 > $tmpdir/read
           if [ $diff -lt -10000 ] || [ $diff -gt 10000 ]; then
               # simulate a seek
               sleep 0.1
           fi
           dd if=$file skip=$4 count=$3 iflag=count_bytes,skip_bytes
       '
  $ sudo nbd-client localhost /dev/nbd0
  $ sudo mount /dev/nbd0 /tmp/mnt
The tricky thing is probably making a deliberately fragmented disk image for testing using modern tools.
In Vista defragging was one of my goto's for getting the thing to act nicely.

I would use process monitor from sysinternals to measure which files are loaded as the system boots. Then use jkdefrag/mydefrag to take said list and rebuild drive into different zones. Try to put small files that are used together in the same area of the disk. Put huge things like 'isos/vhds/acrivezips' etc near the end of the drive. Put small frequently used files near the front in used order if possible. Smash out any gaps if possible. This helps NTFS from creating more fragments. Defrag any files that 7zip unarchives immediately as it has a bad habit of creating highly fragmented files (contig from sysinternals). Try to put file index in its own 'area' as one reason it runs so badly is the drive fragmentation it causes to itself. It got so bad I would put the index on its own partition sometimes. Try to put files that fragment frequently in their own 'zone' as NTFS will tend to pick the next available gap to where the file is (not always).

That made a real noticeable difference in perceived speed.

These days with nvme and ssd I might just defrag the files themselves once a year if I feel like it. There is a difference but the perceived is pretty much not there anymore. The difference is there is a chain of sectors in the MFT that windows will have to traverse if you ask for something in the middle of a file. That is about the only thing you save with newer drives. ext4 has a similar issue. But it seems to be better about picking spots where it will not fragment. It will however fragment badly in low space conditions. Most filesystems will.

With FAT, you are constantly jumping between the table at the beginning of the disk to get the next cluster number and the data, unless disk caching pulled it in RAM.
I remember that being a reason why the MFT in NTFS is positioned in the middle of the drive so that on average the head has to travel less. And NTFS also supports putting small file contents directly into the MFT entry, which also cuts down on head movement. Nowadays all that probably is moot and a relic from ancient times (although I still have enough hard drives running at home).
Not really.

First thing the middle of the volume/partition is not the middle of the disk in any multi-partitioned disk, then NTFS $MFT is not (and never has been) in the middle of the partition, its location varies depending on the size of the volume/partiton but above a certain size, around 5/6 GB it is at a fixed offset, usually on LCN #786432 which - on a normal 8 KB/cluster NTFS volume - amounts to offset 6,291,456 sectors or 6,442,450,944 bytes, rarely the middle of the volume, unless its size is around 13 GB.

Have you found the difference between formatting NTFS in older Windows versions compared to the recent releases?

Seems to me the MFT was in the middle of volumes commonly in older versions, and lately much closer to the beginning of the volume.

Could have something to do with the feature of shrinking a volume which became more common, and you can now more often shrink an NTFS volume by more than half, which was often impossible in earlier years.

But a defrag FAT jumps much much less, because the cluster slots allocated to the same file will be close to each other, often in the same sector. I would be surprised if DOS doesn't optimize for this case.
Defrag absolutely helped in the winxp days if your HDD was always >90% full. Every chunk of data written to a full HDD would get spread across the platter, cutting your read and write IOPS to a fraction of what you expect. It was especially noticeable on laptops since their platters spin slower.
For most file systems performance suffers at latest at the 90% full mark, if not before.
Faster disk access was one selling point. But as I recall the primary reason to defrag was to prevent problems caused by long FAT chains. And when something did go wrong, contiguous files were easier to recover from the damaged filesystem.
It made a massive difference on spinny disks because of the elevator algorithm and the time it took to relocate physical heads and spin the disks around.
I suppose it solves the support staff's problem of convincing a customer that they fixed an issue.
A fragmented hard drive was so much faster than a defragmented floppy disk that I was happy either way.
Also quieter. I remember the satisfaction I felt after defragging the drive and no longer hearing the driving thrashing around on the smallest read operation.
UFS is fragmentation resistant by virtue of its allocation algorithms. It still get fragmented under certain patterns or if free space gets low. I'm not sure if FreeBSD did any online defragmentation back then, maybe it does now with softupdates? I know Linux never did only deframentation with ext2/3 (despite being inspired by UFS), although it did have an offline e2defrag tool.

But yes these designs generally seemed to be much better than FAT under DOS or Windows at avoiding excessive fragmentation.

The first bad sector I encountered in the 90s left me shaken for days. We stared eye to eye. The bad sector won. I had broken something my father worked a month for. But it didn't break. The bad sector was marked bad. The computer continued working. I rejoiced.
I remember the first time Norton Disk Doctor "repaired" a bad disk. Looked like magic to me.
SO did OS/2. People wanted the defrag of Windows 95 or Norton Utilities but OS/2 defragged in the background.

SSD drives don't need to be defragged.

NVME drives still like some TLC optimisation, i.e running TRIM on a regular basis.
I’m perpetually kind of bothered that I can’t defragment my ZFS HDD. I’m aware it’s not actually a problem in most cases and it’s not like I’m having performance issues, but it feels like a potential ticking time bomb, albeit one the rational part of me knows will never go off.