You are not logged in.

#1 2021-05-21 11:19:10

bpeary
Member
Registered: 2012-08-25
Posts: 45

fstrim runs at each boot, though set to run weekly [solved]

On cloning and optimizing a new SSD (Samsung 870 EVO), I discovered that fstrim runs at each boot (I typically boot Arch 4 times a week in this triple-boot system).

Background: my previous SSD was installed in 2011, while Arch was still using SysV-init.  Is it possible some remnant of Sys-V is causing this?

This shows that fstrim ran at boot today:

systemctl status fstrim.service
○ fstrim.service - Discard unused blocks on filesystems from /etc/fstab
     Loaded: loaded (/usr/lib/systemd/system/fstrim.service; enabled; vendor preset: disabled)
     Active: inactive (dead) since Fri 2021-05-21 06:23:26 EDT; 25min ago
TriggeredBy: ● fstrim.timer
       Docs: man:fstrim(8)
    Process: 331 ExecStart=/usr/bin/fstrim --fstab --verbose --quiet (code=exited, status=0/SUCCESS)
   Main PID: 331 (code=exited, status=0/SUCCESS)
        CPU: 1.480s

May 21 06:23:11 arch systemd[1]: Starting Discard unused blocks on filesystems from /etc/fstab...
May 21 06:23:26 arch fstrim[331]: /: 28.8 GiB (30890737664 bytes) trimmed on /dev/sda3
May 21 06:23:26 arch systemd[1]: fstrim.service: Deactivated successfully.
May 21 06:23:26 arch systemd[1]: Finished Discard unused blocks on filesystems from /etc/fstab.
May 21 06:23:26 arch systemd[1]: fstrim.service: Consumed 1.480s CPU time.

Here's the timer config, showing it's set to trim weekly:

systemctl cat fstrim.timer
# /usr/lib/systemd/system/fstrim.timer
[Unit]
Description=Discard unused blocks once a week
Documentation=man:fstrim
ConditionVirtualization=!container

[Timer]
OnCalendar=weekly
AccuracySec=1h
Persistent=true
RandomizedDelaySec=6000

[Install]
WantedBy=timers.target

Output of all system timers, showing fstrim should not trim for another two days:

systemctl list-timers
NEXT                        LEFT                LAST                        PASSED             UNIT                         ACTI>
Fri 2021-05-21 10:16:10 EDT 3h 15min left       Sun 2021-05-16 14:41:23 EDT 4 days ago         updatedb.timer               upda>
Sat 2021-05-22 00:00:00 EDT 16h left            Fri 2021-05-21 06:23:11 EDT 37min ago          logrotate.timer              logr>
Sat 2021-05-22 00:00:00 EDT 16h left            Fri 2021-05-21 06:23:11 EDT 37min ago          man-db.timer                 man->
Sat 2021-05-22 00:00:00 EDT 16h left            Fri 2021-05-21 06:23:11 EDT 37min ago          shadow.timer                 shad>
Sat 2021-05-22 06:38:13 EDT 23h left            Fri 2021-05-21 06:38:13 EDT 22min ago          systemd-tmpfiles-clean.timer syst>
Mon 2021-05-24 01:34:25 EDT 2 days left         Thu 2021-05-20 08:35:30 EDT 22h ago            fstrim.timer                 fstr>
Sat 2021-06-05 15:00:00 EDT 2 weeks 1 days left Sun 2021-05-02 19:12:27 EDT 2 weeks 4 days ago pamac-cleancache.timer       pama>

7 timers listed.
Pass --all to see loaded but inactive timers, too.

Timer status, also showing it's not supposed to trim for another two days:

systemctl status fstrim.timer
● fstrim.timer - Discard unused blocks once a week
     Loaded: loaded (/usr/lib/systemd/system/fstrim.timer; enabled; vendor preset: disabled)
     Active: active (waiting) since Fri 2021-05-21 06:23:11 EDT; 39min ago
    Trigger: Mon 2021-05-24 01:34:25 EDT; 2 days left
   Triggers: ● fstrim.service
       Docs: man:fstrim

May 21 06:23:11 arch systemd[1]: Started Discard unused blocks once a week.

And here's my /etc/fstab:

# lines to move temp files to RAM
tmpfs /tmp tmpfs defaults 0 0
tmpfs /var/tmp tmpfs defaults 0 0


#/dev/sda3 /  Root Partition
#UUID=2511c5d0-f2fc-4494-9788-85dc5e98fba7 / ext4 defaults,noatime 0 1
#/dev/sda3 / ext4 defaults,noatime 0 1
LABEL=ARCH / ext4 defaults,noatime 0 1


#/dev/sdb1  common data partition      
#UUID=5a9bf427-1389-45cf-a166-fb1bc3da9212 /data ext4 rw,user,auto,noatime 0 2 
#/dev/sdb1 /data ext4 rw,user,auto,noatime 0 2 
LABEL=DATA /data ext4 rw,user,auto,noatime 0 2 


# /dev/sdb3 swap
#UUID=c3a85cb9-6306-4bf3-a191-712c8f2317f5 none swap sw
#/dev/sdb3 none swap sw
LABEL=SWAP none swap sw

Last edited by bpeary (2021-05-24 11:34:14)

Offline

#2 2021-05-21 11:31:06

codicodi
Member
Registered: 2021-05-21
Posts: 3

Re: fstrim runs at each boot, though set to run weekly [solved]

I think there is something wrong with your fstrim.service. It's supposed to be static, but you enabled it somehow.
Can you show "systemctl cat fstrim.service"?

Last edited by codicodi (2021-05-21 11:31:36)

Offline

#3 2021-05-21 12:17:49

sabroad
Member
Registered: 2015-05-24
Posts: 242

Re: fstrim runs at each boot, though set to run weekly [solved]

bpeary wrote:

This shows that fstrim ran at boot today:

systemctl status fstrim.service
○ fstrim.service - Discard unused blocks on filesystems from /etc/fstab
     Loaded: loaded (/usr/lib/systemd/system/fstrim.service; enabled; vendor preset: disabled)

That suggests fstrim.service has been enabled (at boot) as opposed to vendor (arch) defaults. If only the timer is wanted, then enable the timer and don't enable the service:

systemctl enable fstrim.timer
systemctl disable fstrim.service

--
saint_abroad

Offline

#4 2021-05-21 13:28:21

bpeary
Member
Registered: 2012-08-25
Posts: 45

Re: fstrim runs at each boot, though set to run weekly [solved]

# /usr/lib/systemd/system/fstrim.service
[Unit]
Description=Discard unused blocks on filesystems from /etc/fstab
Documentation=man:fstrim(8)
ConditionVirtualization=!container

[Service]
Type=oneshot
ExecStart=/usr/bin/fstrim --fstab --verbose --quiet
PrivateDevices=no
PrivateNetwork=yes
PrivateUsers=no
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
MemoryDenyWriteExecute=yes
SystemCallFilter=@default @file-system @basic-io @system-service

Offline

#5 2021-05-21 14:17:57

bpeary
Member
Registered: 2012-08-25
Posts: 45

Re: fstrim runs at each boot, though set to run weekly [solved]

I deactivated fstrim.service

sudo systemctl deactivate fstrim.service

On reboot no trim indicated:

systemctl status fstrim.service
○ fstrim.service - Discard unused blocks on filesystems from /etc/fstab
     Loaded: loaded (/usr/lib/systemd/system/fstrim.service; static)
     Active: inactive (dead)
TriggeredBy: ● fstrim.timer
       Docs: man:fstrim(8)

Offline

#6 2021-05-22 00:59:24

bpeary
Member
Registered: 2012-08-25
Posts: 45

Re: fstrim runs at each boot, though set to run weekly [solved]

Thank you both.  Just waiting on Monday's scheduled trim to mark it solved.

Offline

Board footer

Powered by FluxBB