migration from ext3 -> ext4 : use of online defrag tool ?

Hi :wink:

i migrated my data storage from ext3 -> ext4 but the site Ext4 - Linux Kernel Newbies mentions an online defrag tool , see 2.10 & 3.2 parts.

This tool is still being developped but in what is it useful/important ?

well… hmmm, lets see… it defrags files… so what is that useful for :wink: ?.. lets see… files tend to fragment over time even though a file system may have features to minimize this. There are two types of fragmentation; internal and external. Internal fragmentation refers to the fact that a file system uses specific sizes for a block (default on most file systems is 4 KB per block) so if you have a file which is only 1 KB big, it will be stored in one 4 KB block, occupying only 1 KB of it and wasting the other free 3 KB of the block. This can’t really be avoided, unless you set a specific block size during file system creation, say only 1 KB, and then always use files which are 1 KB big only

External fragmentation is when the files are not layed out continuously (ie, spread over different blocks which can be far apart from each others) thus it takes the disk head more time to “grab” all pieces together and reconstruct the file

For the e4defrag tool specifically, it not only can be useful for defragging but it can also be useful when you convert an ext3 file system to ext4. If you have gone from ext3 -> ext4 and turned on extents, your “new” ext4 will use only extents on newly created files but those files which were previously created on ext3 will still use block mappings so to convert them to use extents instead, you have to defrag them

Can we know when will this tool be available ?

Ask the devs… you don’t really need it though as Ext4 tends to fragment much less due to extents and other features like allocate on flush which reduce fragmentation a lot… you don’t even need it to convert existing files created on Ext3 before you converted to Ext4. To make them all use extents, simple copy them all to another location and then put them back in their original location and this process will make them use extents

That said, e4defrag can be useful on a file system which has seen heavy usage over a longer period of time and for when the partition fills up which linearly increases fragmentation the fuller the partition gets, most notable when it’s filled for 90-95% or so

@microchip: I’ve been using ext4 for a while now on some partitions on my main machine, on the laptop entirely. Is converting all ext3 partitions a good idea, the thing to do? From what I’ve read so far, there’s no real danger in it. I have backups of all I want to keep for the future.

I’d go for it… unless you really need ext3 for something

When I looked a few months ago, e4defrag.c was really hard to find and didn’t work on my ext4 partition on an expendable machine. That probably says that it’s still in development (by kernel developers, not Novell developers). Maybe things have changed since. But I would not use it until it’s been released for general use and then only after some field use.

I wouldn’t worry about using an online defragger unless you tend to fill up your ext4 partitions with large files. Consider the risk of an experimental program vs the slight (possible) inefficiency of the filesystem.