I vaguely remember someone telling me ages ago that Linux distros don’t come with a Disk Defragmentation utility (like Windows does) because files on Linux don’t get fragmented.
For some reason, I didn’t really challenge that very much at the time, and it’s remained at the back of my mind as a bit of an assumption. One of the things I’ve learned on my Linux course this week is that this isn’t true.
We’ve been playing with filesystems this afternoon, and one of the options to mke2fs
that I’ve not used before is -m
.
When you’re creating a new filesystem, the -m
option lets you specify the percentage of blocks that are reserved for the superuser. These reserved blocks are used by the filesystem to avoid fragmentation. So if you set this too low (or worse, set it to 0), then fragmentation can result.
And because this is defined when you create the filesystem, the only way to remove fragmentation is to recreate the filesystem (restoring data from a backup).
filefrag
(again, something I’ve never come across before!) seems to let you see if a file is fragmented:
[root@station17 ~]# filefrag install.log
install.log: 2 extents found, perfection would be 1 extent
That said, whether fragmentation actually matters seems to be debatable…
this page sums loads of things up nicely
my wintel laptop takes an age to boot, thrashing wildly until it finally starts doing productive work, and I foolishly hoped a defrag would help
with two cores starting tonnes of things at the same time, it made no difference for me :o(