http://polishlinux.org/apps/cli/ext4-defragmentation-with-e4defrag/Ext4 defragmentation with e4defrag[ Saturday, 31 May 2008, optimizationkit ]Lately I have described ok_defrag
— a simple tool for defragmenting Linux file systems. Today, I want
to describe a specialized program designed to defrag the new Ext4 file
system. (For all who would like to say that Linux file systems don’t require defragmenting: Please redirect your great ideas to the Ext4 developers. They are the authors of this program — I do not have anything in common with it. As it will turn out, Ext4 is indeed quite different than other Linux file systems. Thanks in advance for your understanding) To begin playing with e4defrag we must start compile of new kernel with patches needed to carry out the defragmentation. Below you will find a short description of that process, and if you would not like to use all those experimental patches for Ext4, then you should be interested in these seven only:
In first step we start from creation of directory, grabbing the kernel source, and downloading and unpacking needed patches.
Then we apply the patches on the sources.
Then we start a process of configuring/building our new system kernel.
(on my PC it look like this:)
VER=`ketchup -m` make sudo make modules_install sudo cp arch/x86/boot/bzImage /boot/vmlinuz-$VER sudo cp System.map /boot/System.map-$VER sudo /sbin/new-kernel-pkg --mkinitrd --depmod --install $VER ) make oldconfig ./build.sh Meanwhile, when our new kernel compiles, we may open file: linux-2.6-ext4/patches/ext4-online-defrag-command.patch in our text editor of choice and we delete all lines from 1 to 18, and then from 1932 to 1935. Then, we copy our source code to other location.
And compile…
It is worth to grab some tools to handle the Ext4 file systems (the very latest version from the code repository).
After running our system with brand new kernel for the first time, we can finally start to test e4defrag. First we create and mount a test file system.
Now we must allow the use of experimental code on that partition.
Now our new file system is ready to be mounted
How to cause fragmentation at Ext4? - I have not yet tested any good way for fast fragmenting Ext4. This file system contrary to other Linux file systems is exceptionally resistant to fragmentation.
It seems that Ext4 is a tough row to hoe, but its developers still deliver a defragmentation tool for it. Take a peep! With use e4defrag we can defrag single files, for example:
or all directories:
also, there is a way to defrag a partition:
|