[ale] Ubuntu Linux Defrag EXT4
Michael B. Trausch
mike at trausch.us
Mon Sep 13 10:54:48 EDT 2010
On Mon, 2010-09-13 at 09:10 -0400, Richard Faulkner wrote:
> Paul: You're doing a defrag operation on a mounted drive? I've done
> this a billion times I swear on M$ but not Linux (don't feel a need
> to). Am I correct in thinking that to do an actual defrag on Linux
> you need to unmount the drive in question and do the operation from a
> bootable disc? Am I reading this correctly that your doing a disk
> fragmentation check on a mounted drive and it "no-likey" that because
> it is mounted?
One of the features of ext4 is that it supports _on-line_
defragmentation.
Keep in mind that *any* filesystem will develop fragmentation over time,
and *any* filesystem for which a defragmentation program exists can be
defragmented off-line.
However, on-line defragmentation requires cooperation of the operating
system, because defragmentation necessarily changes the state of the
disk "behind the back" of the operating system, which may cache parts of
the filesystem state in buffers.
As an example, it was possible to use any number of DOS programs to
defragment drive C:, for example, as long as no drive caching software
("drivers") were running (or alternatively if the defragmenter program
knew how to suspend and resume the functionality of whatever cache
software was on the system). Because DOS was a single-tasking operating
system, this worked. The defragmenter would take over the system,
perform the defragmentation operation, and then return to DOS, which
would immediately benefit from the optimized volume.
For late versions of the Windows operating environment (distinct from
operating system!) running on DOS, including 9x/Me, the defragmenter
needed the cooperation of the 32-bit disk I/O and filesystem drivers.
Additionally, whenever any application on the system wrote anything to
the disk, the defragmentation process would have to start over again,
which was a royal pain in the butt. Not wholly unexpected, though,
since the FAT family was _not_ designed for concurrency. I don't know
if later versions of Windows managed to work around that limitation for
FAT-formatted volumes or not; I don't believe that it is an issue for
NTFS volumes when Windows is defragmenting them.
Coming back to the subject at hand, this means that any filesystem can
become fragmented, and any filesystem may be defragmented, but only very
few filesystems can be defragmented on a live system.
There are some additional issues, too: How do you meaningfully
defragment a filesystem that is spanned across several drives? What
about LVM, where it can pepper parts of a logical volume all over the
place on different-size, different-speed media? I'm not sure that
either of those questions have been answered (in the general case) yet.
--- Mike
More information about the Ale
mailing list