Defragmenter

Given that I've only tested this on a couple of filesystems, I'm asking that people play things safe with this.

Please ,download and read` this page as well if you download the software.

cd mountpoint
mount -o remount,noatime mountpoint
touch /tmp/md5 /tmp/md5b
chattr -m gzip6 -b 32 /tmp/md5 /tmp/md5b
find -xdev -type f -print0|tr \\0\\n \\n\\0|sort|tr \\0\\n \\n\\0|
 xargs -0 md5sum > /tmp/md5
cd /
umount mountpoint
e2fsck -f /dev/xxx
e2defrag -r -n -v /dev/xxx
e2defrag -n -v /dev/xxx
e2fsck -f /dev/xxx
mount -o noatime mountpoint
cd mountpoint
find -xdev -type f -print0|tr \\0\\n \\n\\0|sort|tr \\0\\n \\n\\0|
 xargs -0 md5sum > /tmp/md5b
diff /tmp/md5 /tmp/md5b
mount -o atime,remount mountpoint

The diff shouldn't find any differences, of course.

If you run e2defrag without any arguments, it'll show you a brief usage message so you can see what those options do.

The reason for running e2defrag once beforehand readonly is that that can catch some problems, and it's better to find that there is a problem before it's munged your filesystem :-) .

The tr and sort probably isn't necessary, btw.

The reason for running e2fsck beforehand is a) e2defrag can stuff up if the filesystem isn't valid, and b) if the e2fsck afterwards shows any problems, then we can be sure that e2defrag introduced the problems.

For my 500MB partition, /tmp/md5 takes up:

$ e2ratio /tmp/md5
4905    1668     34.0%  /tmp/md5

Doing the md5sums does take up some time, but it's worth it for these reasons:

  1. If there is a bug in this e2defrag, then it is best to find out as soon as possible, so that as few filesystems as possible are affected.
  2. If damage is done to a file, then you probably want to know about it so that you can restore that file.

Naturally, don't use it with stuff that you can't afford to lose. As I say, I haven't read through the whole of the e2defrag sources, and maybe there are problems that an e2fsck and md5sum check won't catch.

If you do have any problems, please post a note to the e2compr mailing list, e2compr@lists.sourceforge.net. (By posting to the mailing list, other people will be aware of the problem sooner than if you'd just sent a note to me.)

Download

defrag-e2c-0.73.1-1.1.tar.gz: Source (including e2compr and Debian modifications).

Unfortunately I don't have a copy of standard defrag-0.73, so can't provide the usual files (e.g. e2compr diffs, Debian diffs separately).


Return to Main Entrance
e2compr maintainers
Last modified: Thu Jan 22 10:46:15 AEST 2004