Linux Commands Examples

A great documentation place for Linux commands

e4defrag

online defragmenter for ext4 filesystem


see also : mke2fs - mount

Synopsis

e4defrag [ -c ] [ -v ] target ...


add an example, a script, a trick and tips

: email address (won't be displayed)
: name

Step 2

Thanks for this example ! - It will be moderated and published shortly.

Feel free to post other examples
Oops ! There is a tiny cockup. A damn 404 cockup. Please contact the loosy team who maintains and develops this wonderful site by clicking in the mighty feedback button on the side of the page. Say what happened. Thanks!

examples

3
source
            
sudo e4defrag /
dd if=/dev/zero of=/tmp/zero.pylab bs=2048
sync
rm /tmp/zero.pylab
sync
SCRIPT
1
source
            
echo "Please install the e2fsprogs, for the e4defrag command."
exit 1
fi
age_filesystem()
{
local dirId=
local idx=
rm -rf mnt_point/*
tst_resm TFAIL "e4defrag returned failure"
umount mnt_point
return 1
fi
umount mnt_point
if [ $? -ne 0 ]; then

description

e4defrag reduces fragmentation of extent based file. The file targeted by e4defrag is created on ext4 filesystem made with "-O extent" option (see mke2fs(8)). The targeted file gets more contiguous blocks and improves the file access speed.

target is a regular file, a directory, or a device that is mounted as ext4 filesystem. If target is a directory, e4defrag reduces fragmentation of all files in it. If target is a device, e4defrag gets the mount point of it and reduces fragmentation of all files in this mount point.

options

-c

Get a current fragmentation count and an ideal fragmentation count, and calculate fragmentation score based on them. By seeing this score, we can determine whether we should execute e4defrag to target. When used with -v option, the current fragmentation count and the ideal fragmentation count are printed for each file.

Also this option outputs the average data size in one extent. If you see it, you’ll find the file has ideal extents or not. Note that the maximum extent size is 131072KB in ext4 filesystem (if block size is 4KB).

If this option is specified, target is never defragmented.

-v

Print error messages and the fragmentation count before and after defrag for each file.

notes

e4defrag does not support swap file, files in lost+found directory, and files allocated in indirect blocks. When target is a device or a mount point, e4defrag doesn’t defragment files in mount point of other device.

Non-privileged users can execute e4defrag to their own file, but the score is not printed if -c option is specified. Therefore, it is desirable to be executed by root user.


see also

mke2fs , mount .


author

Written by Akira Fujita <a-fujita[:at:]rs.jp.nec[:dot:]com> and Takashi Sato <t-sato[:at:]yk.jp.nec[:dot:]com>.

How can this site be more helpful to YOU ?


give  feedback