Re: A possible way to reduce free space fragmentation?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 2/1/25 3:38 PM, Andreas Dilger wrote:
It should be possible to run "find $DIR -type f -size -1M | xargs e4defrag" to only defragment files below 1MB (or whatever you consider "small").

I have smaller files completely defragmented already.

The issue is a dozen of 50-250MB files that span multiple extents (up to
30).


However, I don't recall if e4defrag will move a file if the new file has the same number of fragments as the original (presumably both "1") or leave it in place. That would be possible add an option to change.

Alternately, just run the "find" above to find small files and then "cp $F $F.tmp && mv $F.tmp $F" to rewrite those files into new blocks, and hope mballoc will move them to a better location.

cp doesn't even support posix_fallocate(), rsync does but this process
will be a complete guesswork as I have no idea which files are worth
moving and which are not.

Considering there are holes that can include files in their entity, this
must be done by something that knows what it's doing.

Best regards,
Artem


Cheers, Andreas

On Jan 31, 2025, at 14:02, Artem S. Tashkinov <aros@xxxxxxx> wrote:

Hello,

ext4 has no free space defragmentation and at most you can use e4defrag
to defragment individual files. I now have a 24GB ext4 filesystem that
has only 7GB of space occupied however it has small files scattered all
over it and now bigger files occupy more than one extent and I cannot
reduce fragmentation to zero. One way to approach that would be to
shrink the volume and then defragment it but that will involve a ton of
disk writes and unnecessary tear and wear. Is it possible to modify the
e4degrag utility to move small defragmented files, so that they were
placed consecutively instead of being randomly spread all over the disk?

Regards,
Artem







[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux