Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: fstrim.timer

  1. #1

    Default fstrim.timer

    I've installed the OS on my new SSD, and I was wondering if anyone knows when fstrim (via fstrim.timer) runs?

    I cat fstrim.timer and get:

    Code:
    [Unit]
    Description=Discard unused blocks once a week
    Documentation=man:fstrim
    
    [Timer]
    OnCalendar=weekly
    AccuracySec=1h
    Persistent=true
    
    [Install]
    WantedBy=timers.target
    And I see fstrim runs weekly, but no time is indicated. The man page doesn't say when, either. I've set DAILY_TIME to 0100 (so udb will run when I not using the system). I know fstrim discards unused blocks, so if it were to run at 0100, it shouldn't cause udb any heartburn, right?

    TIA
    OpenSuse 15.0, Plasma 5.15
    Gigabyte GA-Z87X-UD4H Mobo; 16G Ram
    Intel Core i5-4570 Processor (6M Cache, up to 3.60 GHz)

  2. #2
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    25,451
    Blog Entries
    15

    Default Re: fstrim.timer

    Quote Originally Posted by susesteve View Post
    I've installed the OS on my new SSD, and I was wondering if anyone knows when fstrim (via fstrim.timer) runs?

    I cat fstrim.timer and get:

    Code:
    [Unit]
    Description=Discard unused blocks once a week
    Documentation=man:fstrim
    
    [Timer]
    OnCalendar=weekly
    AccuracySec=1h
    Persistent=true
    
    [Install]
    WantedBy=timers.target
    And I see fstrim runs weekly, but no time is indicated. The man page doesn't say when, either. I've set DAILY_TIME to 0100 (so udb will run when I not using the system). I know fstrim discards unused blocks, so if it were to run at 0100, it shouldn't cause udb any heartburn, right?

    TIA
    Hi
    You can check the timer status

    Code:
    systemctl status fstrim.timer
    ● fstrim.timer - Discard unused blocks once a week
       Loaded: loaded (/usr/lib/systemd/system/fstrim.timer; enabled; vendor preset: enabled)
       Active: active (waiting) since Sat 2018-12-29 10:11:47 CST; 5 days ago
      Trigger: Mon 2019-01-07 00:00:00 CST; 3 days left
         Docs: man:fstrim
    
    Dec 29 10:11:47 bert systemd[1]: Started Discard unused blocks once a week.
    Think of timers as the new cron, as cron gets deprecated, those jobs will move to systemd timers. One advantage of timers is that you can run jobs with less than 1 minute..
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  3. #3

    Default Re: fstrim.timer

    Thanks, Malcolm.

    Steve
    OpenSuse 15.0, Plasma 5.15
    Gigabyte GA-Z87X-UD4H Mobo; 16G Ram
    Intel Core i5-4570 Processor (6M Cache, up to 3.60 GHz)

  4. #4
    Join Date
    Sep 2012
    Posts
    4,778

    Default Re: fstrim.timer

    Quote Originally Posted by susesteve View Post
    And I see fstrim runs weekly, but no time is indicated. The man page doesn't say when, either.
    man systemd.time. No time defaults to midnight (00:00:00).

  5. #5
    Join Date
    Jan 2014
    Location
    Erlangen
    Posts
    581

    Default Re: fstrim.timer

    Quote Originally Posted by susesteve View Post
    I've installed the OS on my new SSD, and I was wondering if anyone knows when fstrim (via fstrim.timer) runs?

    I cat fstrim.timer and get:

    Code:
    [Unit]
    Description=Discard unused blocks once a week
    Documentation=man:fstrim
    
    [Timer]
    OnCalendar=weekly
    AccuracySec=1h
    Persistent=true
    
    [Install]
    WantedBy=timers.target
    And I see fstrim runs weekly, but no time is indicated. The man page doesn't say when, either. I've set DAILY_TIME to 0100 (so udb will run when I not using the system). I know fstrim discards unused blocks, so if it were to run at 0100, it shouldn't cause udb any heartburn, right?

    TIA
    From journal:
    Code:
    erlangen:~ # journalctl -b -1 -u fstrim.service 
    -- Logs begin at Sun 2018-08-26 08:48:18 CEST, end at Fri 2019-01-04 08:14:18 CET. --
    Jan 03 17:09:20 erlangen systemd[1]: Starting Discard unused blocks on filesystems from /etc/fstab...
    Jan 03 17:12:49 erlangen fstrim[1880]: /boot/efi: 88.2 MiB (92491776 bytes) trimmed on /dev/nvme0n1p4
    Jan 03 17:12:49 erlangen fstrim[1880]: /home-SSD: 184 GiB (197619363840 bytes) trimmed on /dev/sdb4
    Jan 03 17:12:49 erlangen fstrim[1880]: /Tumbleweed-SSD: 13.4 GiB (14422794240 bytes) trimmed on /dev/sdb3
    Jan 03 17:12:49 erlangen fstrim[1880]: /home: 206.8 GiB (222031929344 bytes) trimmed on /dev/nvme0n1p3
    Jan 03 17:12:49 erlangen fstrim[1880]: /: 14.7 GiB (15737827328 bytes) trimmed on /dev/nvme0n1p2
    Jan 03 17:12:49 erlangen systemd[1]: Started Discard unused blocks on filesystems from /etc/fstab.
    erlangen:~ #
    AMD Athlon 4850e (2009), openSUSE 13.1, KDE 4, Intel i3-4130 (2014), i7-6700K (2016), i5-8250U (2018), openSUSE Tumbleweed, KDE Plasma 5

  6. #6
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    2,083

    Talking Re: fstrim.timer

    Quote Originally Posted by susesteve View Post
    I've installed the OS on my new SSD, and I was wondering if anyone knows when fstrim (via fstrim.timer) runs?
    The “when” is resolved from the systemd Timer variables “OnCalendar” and “AccuracySec”:
    • “OnCalendar” set to ‘weekly’ is shorthand for “Mon *-*-* 00:00:00”.
    • “AccuracySec” set to ‘1h’ means that, the timer is scheduled to elapse within a time window starting with the time specified in OnCalendar=, …

    Therefore, with the default setting, “fstrim” will be run weekly on Monday within the hour following Sunday midnight or, the next boot following that timer expiry …
    • systemd stores the timer information in the directory “/var/lib/systemd/timers/”.
    • The time of the empty file “/var/lib/systemd/timers/stamp-fstrim.timer” is the time when the systemd fstrim service was last executed.


    Further information may be gleaned from the “systemd.timer” (5) and “systemd.time” (7) man pages …

  7. #7
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    9,885
    Blog Entries
    1

    Default Re: fstrim.timer

    Consider whether what you're now doing best meets your needs.

    https://wiki.archlinux.org/index.php...ate_drive#TRIM

    Periodic Trim
    Pros
    Ensures TRIM is done
    Can be done during dedicated periods of time that doesn't conflict with LOB apps
    Cons
    No assurance TRIM job is complete and sufficient
    Might conflict with something else running at the scheduled time

    Continuous TRIM
    Pros
    Runs as a low priority process, always
    Typically best ensures SSD is ready for writes
    Cons
    In the very, very unlikely case the machine never stops writing to disk, TRIM may never run
    Although usually unnoticeable, it's possible that heavy TRIM tasks may cause latencies

    Bottom line,
    For most Users doing common things like email and web surfing, it's far better to implement continuous TRIM by implementing the discard option in the fstab.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  8. #8
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    25,451
    Blog Entries
    15

    Default Re: fstrim.timer

    Quote Originally Posted by tsu2 View Post
    Consider whether what you're now doing best meets your needs.

    https://wiki.archlinux.org/index.php...ate_drive#TRIM

    Periodic Trim
    Pros
    Ensures TRIM is done
    Can be done during dedicated periods of time that doesn't conflict with LOB apps
    Cons
    No assurance TRIM job is complete and sufficient
    Might conflict with something else running at the scheduled time

    Continuous TRIM
    Pros
    Runs as a low priority process, always
    Typically best ensures SSD is ready for writes
    Cons
    In the very, very unlikely case the machine never stops writing to disk, TRIM may never run
    Although usually unnoticeable, it's possible that heavy TRIM tasks may cause latencies

    Bottom line,
    For most Users doing common things like email and web surfing, it's far better to implement continuous TRIM by implementing the discard option in the fstab.

    TSU
    Hi
    You need to be careful and review the use case when using other distributions wikis and advise, I would hazard a guess that the openSUSE/SUSE kernel developers are up to speed with things like btrfs and the default mount options for the filesystems selected. Also the discard option does not guarantee that small blocks are trimmed, hence the fstrim batch jobs ensures trim takes place. Perhaps a visit/post to the openSUSE Kernel mailing list with the question may glean additional information more relevant to the openSUSE distribution.
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  9. #9
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    9,885
    Blog Entries
    1

    Default Re: fstrim.timer

    Quote Originally Posted by malcolmlewis View Post
    Hi
    You need to be careful and review the use case when using other distributions wikis and advise, I would hazard a guess that the openSUSE/SUSE kernel developers are up to speed with things like btrfs and the default mount options for the filesystems selected. Also the discard option does not guarantee that small blocks are trimmed, hence the fstrim batch jobs ensures trim takes place. Perhaps a visit/post to the openSUSE Kernel mailing list with the question may glean additional information more relevant to the openSUSE distribution.
    Are there any default mount options for TRIM/discard?
    AFAIK, today there are still no default configurations that detect an SSD and apply a TRIM configuration, every person has to do this on their own.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  10. #10
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    25,451
    Blog Entries
    15

    Default Re: fstrim.timer

    Quote Originally Posted by tsu2 View Post
    Are there any default mount options for TRIM/discard?
    AFAIK, today there are still no default configurations that detect an SSD and apply a TRIM configuration, every person has to do this on their own.

    TSU
    Hi
    Btrfs detects and adjusts the mount options for a ssd;
    Code:
    (rw,relatime,ssd,space_cache,subvolid=nnn,subvol=/@/mountpoint)
    For btrfs the fstrim timer takes care of it all, albeit weekly.... which the man page indicates that discard may ignore small blocks to discard, hence leave it to fstrim...

    For xfs (which is the /home default) it is recommended not to use discard as the impact is severe and to use the fstrim job...

    Ref: man 5 btrfs and man 5 xfs (/discard)
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •