e4defrag
- the only defragmentation tool I know for Linux - outputs a lot of information not covered by its manual. I assume that if a command outputs something, it is important thus I would like to understand the output.
Here is exemplary outputs (without superuser privileges and verbosity):
$ e4defrag defrag/
e4defrag 1.45.5 (07-Jan-2020)
ext4 defragmentation for directory(defrag/)
[2/3]/*/defrag/986M.file: 100% [ OK ]
[3/3]/*/defrag/986M.file2: 100% [ OK ]
Success: [ 2/3 ]
Failure: [ 1/3 ]
100% I guess means that e4defrag
defragmented the whole file, OK means the file is defragmented, Success 2/3 is number of _OK_s, but what the Failure is? Should I be worried about it or not?
When I ask for more verbosity I get:
e4defrag -v defrag/
e4defrag 1.45.5 (07-Jan-2020)
ext4 defragmentation for directory(defrag/)
[1/3] "/*/defrag"
File is not regular file [ NG ]
[2/3]/*/defrag/986M.file: 100% extents: 1 -> 1 [ OK ]
[3/3]/*/defrag/986M.file2: 100% extents: 3 -> 3 [ OK ]
Success: [ 2/3 ]
Failure: [ 1/3 ]
Total extents: 4->4
Fragmented percentage: 50%->50%
I can see that the defrag directory, as not a regular file, failed to be defragmented, but why is it Not Good (NG: e4defrag - what does output mean?)?
Both regular files are identical, but one is written as 1 extent, while the other as 3. Why does it count as success when e4defrag
clearly failed to defragment it?
What is the Fragmented percentage? Percentage of fragmented files? Percentage of excessive extents?
But it starts to be really confusing when I run the command as root in -c
mode:
# e4defrag -c defrag/
e4defrag 1.45.5 (07-Jan-2020)
<Fragmented files> now/best size/ext
1. /*/defrag/986M.file2
3/1 336408 KB
2. /*/defrag/986M.file
1/1 1009224 KB
Total/best extents 4/2
Average size per extent 504612 KB
Fragmentation score 0
[0-30 no problem: 31-55 a little bit fragmented: 56- needs defrag]
This directory (defrag/) does not need defragmentation.
Done.
Now both files are listed as fragmented... My guesses are wrong. So, how should I interpret the output?
[EDIT]
I have just found that e4defrag
counts files with more than one extent as fragmented, while it knows that the extents are contiguous:
$ sudo filefrag file.file
file.file: 1 extent found
$ sudo e4defrag -vc file.file
e4defrag 1.45.5 (07-Jan-2020)
<File>
[ext 1]: start 22388736: logical 0: len 32768
[ext 2]: start 22421504: logical 32768: len 32768
[ext 3]: start 22454272: logical 65536: len 32768
[ext 4]: start 22487040: logical 98304: len 27962
Total/best extents 4/1
Average size per extent 126266 KB
Fragmentation score 0
[0-30 no problem: 31-55 a little bit fragmented: 56- needs defrag]
This file (file.file) does not need defragmentation.
Done.