[How to] Create Periodic TRIM Job for LibreELEC (Intel)

  • I'm a former openELEC user who has been using LibreELEC for the past year and I'm very impressed at LibreELEC's features, stability and pace of new version releases. I would like to know if anyone out there knows how to set up a Periodic TRIM Cron Job for an Intel-based build of LibreELEC.


    Thanking you all in advance.


    MINIX NGC-1 (Intel-based)

  • I don't have an X86 machine running LE but this *should* work.


    Create in /storage/.config/system.d

    fstrim.service

    Code
    1. [Unit]
    2. Description=Run fstrim on all applicable drives
    3. [Service]
    4. User=root
    5. Type=oneshot
    6. ExecStart=/usr/sbin/fstrim -av

    fstrim.timer

    Code
    1. [Unit]
    2. Description=Run fstrim on boot and weekly afterwards
    3. [Timer]
    4. OnBootSec=15min
    5. OnUnitActiveSec=1w
    6. [Install]
    7. WantedBy=timers.target

    Check that is works:

    systemctl start fstrim.service

    If happy: Enable it

    systemctl enable fstrim.timer

  • When I went to check that it works, I received the following error: "LibreELEC:~/.config/system.d # systemctl start fstrim.service
    Failed to start fstrim.service: Unit fstrim.service has a bad unit file setting.
    See system logs and 'systemctl status fstrim.service' for details."

  • OK - I was able to edit and commit the files and test it, however, when I went to enable fstrim.timer, I received the following error:

    "LibreELEC:~/.config/system.d # systemctl enable fstrim.timer
    Failed to enable unit: File fstrim.timer: Bad message"

  • Failed to enable unit: File fstrim.timer: Bad message"

    There were error Unit and Description were on same line. Must be on separate lines

    Code
    1. [Unit]
    2. Description=Run fstrim on boot and weekly afterwards
    3. .................

    Blu-ray Disc Java menus support - forum thread, Github

    my lamp addon (unofficial/community) (limited no support)
    my touchscreen support and instructions by Grruhn (now touchscreen addon exists in repository)

  • There were error Unit and Description were on same line. Must be on separate lines

    Code
    1. [Unit]
    2. Description=Run fstrim on boot and weekly afterwards
    3. .................

    Unit and Description were not on the same line. Still doesn't work.

  • I had to delete both the previously created fstrim.service and fstrim.timer files and recreate using nano - only then was I able to enable fstrim.timer. One of the two were corrupted.


    [SOLVED]