Please add EXT4 filesystem defrag tools

  • I noticed that LibreELEC is missing some important EXT4 tools, for instance: e4defrag, e2freefrag or filefrag. Basically they all come from the e2fsprogs package (in the case of the Debian distro). The tools are really great ones when you deal with the EXT4 filesystem fragmentation.


    Currently, I can send files from my laptop to LibreELEC via WiFi, but I have no control over the fragmentation process. From time to time I would like to set some online defragmentation (which is supported by the EXT4 filesystem), but I can't do it now with LibreELEC. I have to unplug the drive from RPI, and connect it to my laptop to initiate the defrag process, which makes my TV useless till the process is finished.

    • Official Post

    You typically don't need to defrag ext4 filesystems (I've never done it in my 10ish years of usage).


    If you absolutely need the tools you can compile them yourself and copy them to your system.

  • You typically don't need to defrag ext4 filesystems (I've never done it in my 10ish years of usage).

    I disagree. :) In contrast, I defrag my drives regularly.


    If you absolutely need the tools you can compile them yourself and copy them to your system.

    How can I do it in LibreELEC?

  • ref, An introduction to Linux's EXT4 filesystem | Opensource.com

    I'm aware of the ext4 filesystem features which aims to reduce fragmentation lvl, but it happens and it happens a lot, especially when big files come into play. That's why for instance bigalloc flag was invented, which BTW your article didn't mention. :)


    You need to setup the LibreELEC build system then add the packages needed to compile the tools. You can try copying binaries from a similar system but YMMV.

    I think it's a overkill for me. Anyway, is there some howto on this subject?


    But still I think the e2fsprogs package should be present in the default image as LibreELEC supports EXT4 filesystem. It's just 1,5M uncompressed (615K compressed).

    • Official Post

    But still I think the e2fsprogs package should be present in the default image as LibreELEC supports EXT4 filesystem. It's just 1,5M uncompressed (615K compressed).

    This is the first time I have any memory of someone demanding (let along actually needing) defrag tools in LE and I've been hanging around the project and its forerunner for nearly a decade. On that basis alone I'm confident defrag tools are not a must-have thing for our users. You also fundementally mistunderstand how the team thinks about adding unnecessary cruft into our images. Adding 200Kb of new files causes huge debate. Adding 1.5MB for something withiout large-scale user demand .. isn't going to happen. Even if it was needed the approach we'd follow would be to bundle up a collection of things into a "disk-tools" add-on that the minority who need them could install (see the current btrfs-tools add-on as an example).

  • But the e2fsprogs package contains other tools which are already present in LibreELEC, here's what's in the package (just binaries from my Debian system):


    So as you can see, the biggest binaries are: e2fsck(340K), debugfs(234K), mke2fs(139K), tune2fs(113K).


    In LibreELEC we have already the following bins:


    Code
    e2fsck/fsck.ext{2,3,4}   (340K)
    e2label/tune2fs          (111K)
    e2mmpstatus              (31K)
    e2scrub+e2scrub_all      (29K)
    e4crypt                  (27K)
    mke2fs/mkfs.ext{2,3,4}   (139K)
    resize2fs                (63K)
    chattr+lsattr            (30K)
    -------------------------------------------
                             770K               


    Also it looks like there's one broken link: e2mmpstatus -> dumpe2fs , because there's no dumpe2fs tool in the image. I'm not sure whether it's a bug or not.


    And see at the defrag tools and their sizes:


    Code
    e2freefrag 15K
    e4defrag   35K
    filefrag   19K
    --------------
               69K


    So even adding all the defrag tools, would be adding just 69K, or if you added just e4defrag (the other tools just give some info), it would be 35K. So it's not that much and you would support the defragmentation process which is a really useful thing.


    There's also the e4crypt binary in the LibreELEC image which takes 27K of space. Could you please tell me whether do "you have any memory of someone demanding (let along actually needing)" a native EXT4 encryption mechanism in LibreELEC? If no, you could just switch e4crypt witch e4defrag, and since they have similar sizes (and names), no one would ever notice the difference, and everybody would be happy. :)


    On that basis alone I'm confident defrag tools are not a must-have thing for our users.

    Awareness of file fragmentation among even native linux users is low. Maybe because they all repeat that EXT filesystems don't fragment files. :) So I'm not suprised you've never heared about such peope -- but now you have just one example of such person who did hear about file fragmentation and the need of defragmentation.