Bug 2262393 - fstrim.timer is disabled by default in F39, even though preset says enabled
Summary: fstrim.timer is disabled by default in F39, even though preset says enabled
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: util-linux
Version: 39
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Karel Zak
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-02-02 13:23 UTC by Kamil Páral
Modified: 2024-03-01 01:08 UTC (History)
13 users (show)

Fixed In Version: util-linux-2.39.3-6.fc39
Clone Of:
Environment:
Last Closed: 2024-03-01 01:08:54 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Fedora Package Sources util-linux pull-request 15 0 None None None 2024-02-12 13:49:12 UTC

Description Kamil Páral 2024-02-02 13:23:39 UTC
Description of problem:
After a clean installation of Fedora 39 Workstation, fstrim.timer is disabled:

$ sudo systemctl status fstrim.timer
○ fstrim.timer - Discard unused filesystem blocks once a week
     Loaded: loaded (/usr/lib/systemd/system/fstrim.timer; disabled; preset: enabled)
     Active: inactive (dead)
    Trigger: n/a
   Triggers: ● fstrim.service
       Docs: man:fstrim


You can see that there's "preset: enabled", that can be confirmed by grepping a preset file:

$ grep -ri trim /usr/lib/systemd/system-preset/
/usr/lib/systemd/system-preset/90-default.preset:# Run fstrim weekly on filesystems listed in fstab
/usr/lib/systemd/system-preset/90-default.preset:enable fstrim.timer

But the overall status is still "disabled", and shown above.

I've tested this both in VM and on bare metal (having a SSD), with btrfs and ext4. It's always the same.

The timer is supposed to be enabled by default since F32:
https://fedoraproject.org/wiki/Changes/EnableFSTrimTimer

Running "sudo systemctl preset fstrim.timer" enables the timer.

So why is the timer disabled by default after installation? Is it a systemd bug?


Version-Release number of selected component (if applicable):
systemd-254.8-2.fc39.x86_64
fedora-release-common-39-34.noarch
util-linux-2.39.3-4.fc39.x86_64


How reproducible:
always

Steps to Reproduce:
1. Install F39 Workstation
2. sudo systemctl status fstrim.timer
3. see that it's disabled, but preset is enabled

Comment 1 Chris Murphy 2024-02-02 15:53:00 UTC
The symlink doesn't exist
>/etc/systemd/system/timers.target.wants/fstrim.timer → /usr/lib/systemd/system/fstrim.timer
Question is what's supposed to create it, is it the job of a postun script in the util-linux RPM? Or are we supposed to "systemctl preset-all" at some point during the installation?

Comment 2 Chris Murphy 2024-02-02 16:03:50 UTC
This is what does it for upgrades when util-linux version is below a certain version.
https://src.fedoraproject.org/rpms/util-linux/blob/rawhide/f/util-linux.spec#_471

Doesn't that imply `preset-all` is invoked at some point to make sure all the presets are set correctly?

Comment 3 Chris Murphy 2024-02-02 16:27:50 UTC
https://src.fedoraproject.org/rpms/fedora-release/blob/rawhide/f/90-default.preset#_371

It should be enabled, still not sure why it isn't.

Comment 4 Chris Murphy 2024-02-02 17:14:06 UTC
This feature change https://fedoraproject.org/wiki/Changes/Preset_All_Systemd_Units_on_First_Boot suggests what we're seeing shouldn't happen because a preset-all should already be happening. And yet here we are.

Comment 5 Kamil Páral 2024-02-05 09:24:58 UTC
On a cleanly installed system (F39 Workstation installed from a netinst), this happens:

$ sudo systemctl preset-all --preset-mode=full
Removed "/etc/systemd/system/systemd-homed.service.wants/systemd-homed-activate.service".
Removed "/etc/systemd/system/vmtoolsd.service.requires/vgauthd.service".
Removed "/etc/systemd/system/default.target".
Created symlink /etc/systemd/system/timers.target.wants/fstrim.timer → /usr/lib/systemd/system/fstrim.timer.
Created symlink /etc/systemd/system/systemd-homed.service.wants/systemd-homed-activate.service → /usr/lib/systemd/system/systemd-homed-activate.service.
Created symlink /etc/systemd/system/multi-user.target.wants/machines.target → /usr/lib/systemd/system/machines.target.
Created symlink /etc/systemd/system/basic.target.wants/rpmdb-migrate.service → /usr/lib/systemd/system/rpmdb-migrate.service.
Created symlink /etc/systemd/system/basic.target.wants/rpmdb-rebuild.service → /usr/lib/systemd/system/rpmdb-rebuild.service.
Created symlink /etc/systemd/system/vmtoolsd.service.requires/vgauthd.service → /usr/lib/systemd/system/vgauthd.service.
Unit /usr/lib/systemd/system/qemu-guest-agent.service is added as a dependency to a non-existent unit dev-virtio\x2dports-org.qemu.guest_agent.0.device.

It sure looks like fstrim.timer is not the only systemd unit affected.

This looks to be some general problem in systemd? The first-boot preset isn't working well? Reassigning.

@zbyszek.pl @jonathan You worked on the preset-all first boot change (comment 4). Can you look into this? Thanks!

Comment 6 Kamil Páral 2024-02-05 10:05:06 UTC
D'oh, in the Change description, I just read "It does not apply to systems that were installed using Anaconda." So, sorry, that Change probably doesn't apply here (and my invocation of the preset-all was likely incorrect?).

In regards to fstrim.timer, it's correctly enabled after default installation of Fedora 37 and 38 Workstation from Live image. So this is a regression in Fedora 39 (Workstation). Running "systemctl preset-all" without any further argument resets it correctly to enabled.

Comment 7 Zbigniew Jędrzejewski-Szmek 2024-02-06 10:46:37 UTC
> Removed "/etc/systemd/system/systemd-homed.service.wants/systemd-homed-activate.service".
The implementation of preset-all seems to have some issues with units listed in Also=.
But this is not an actual problem, because we want the unit to be enabled.
(preset-all would disable it, but people generally don't run it on already-installed systems.)

> Removed "/etc/systemd/system/default.target".
Hmm. We probably shouldn't remove this in preset-all.

> Created symlink /etc/systemd/system/basic.target.wants/rpmdb-migrate.service → /usr/lib/systemd/system/rpmdb-migrate.service.
> Created symlink /etc/systemd/system/basic.target.wants/rpmdb-rebuild.service → /usr/lib/systemd/system/rpmdb-rebuild.service.
Possibly a bug in rpm scriplets?

> Created symlink /etc/systemd/system/timers.target.wants/fstrim.timer → /usr/lib/systemd/system/fstrim.timer.
https://src.fedoraproject.org/rpms/util-linux/pull-request/15

Since this bug was about fstrim.target, I'll reassign it to util-linux for tracking.

Comment 8 Zbigniew Jędrzejewski-Szmek 2024-02-06 11:08:12 UTC
https://src.fedoraproject.org/rpms/rpm/pull-request/55(In reply to Zbigniew Jędrzejewski-Szmek from comment #7)
> > Created symlink /etc/systemd/system/basic.target.wants/rpmdb-migrate.service → /usr/lib/systemd/system/rpmdb-migrate.service.
> > Created symlink /etc/systemd/system/basic.target.wants/rpmdb-rebuild.service → /usr/lib/systemd/system/rpmdb-rebuild.service.
> Possibly a bug in rpm scriplets?https://bugzilla.redhat.com/show_bug.cgi?id=2044061#c3https://src.fedoraproject.org/rpms/rpm/pull-request/55

Comment 9 Chris Murphy 2024-02-06 15:34:40 UTC
I'm not sure what util-linux package needs to do because its default is disabled fstrim.timer, whereas it's up to fedora-release package to enable it but that isn't happening during installation. The different result between netinstall and live is also suspicious.

Comment 10 Zbigniew Jędrzejewski-Szmek 2024-02-06 15:42:07 UTC
I submitted a pull request. The two relevant patches are:
https://src.fedoraproject.org/fork/zbyszek/rpms/util-linux/c/e5d9a1e3ef8c2d336a0d75686b6b2d82d4799db0
https://src.fedoraproject.org/fork/zbyszek/rpms/util-linux/c/dc6a971801c751b973a53f5a7372f529e5960fd1
Both have descriptions that explain the changes. If it's still not clear, it's probably better to
comment on the pull request.

Comment 11 Kamil Páral 2024-02-07 10:19:50 UTC
Thanks a lot for your patches, Zbigniew.

Comment 12 Kamil Páral 2024-02-07 10:42:28 UTC
I've built a F39 RPM from that PR and tested updating an existing F39 installation, and also installing a new F39 Workstation through netinst (with that patched RPM included in the package set). Both worked fine, fstrim.service is now enabled by default. The PR works great.

Comment 13 Kamil Páral 2024-02-12 13:49:13 UTC
Karel, can we get an F39 update, please?

Comment 14 Kamil Páral 2024-02-26 16:52:39 UTC
Ping again. Running without fstrim is probably quite bad for our F39 users with SSDs.

Comment 15 Karel Zak 2024-02-28 09:36:50 UTC
Sorry, I'm not sure why I missed this BZ. I'll backport it.

Comment 16 Fedora Update System 2024-02-28 10:07:43 UTC
FEDORA-2024-4afc15e835 (util-linux-2.39.3-6.fc39) has been submitted as an update to Fedora 39.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-4afc15e835

Comment 17 Fedora Update System 2024-02-29 01:20:14 UTC
FEDORA-2024-4afc15e835 has been pushed to the Fedora 39 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-4afc15e835`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-4afc15e835

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 18 Kamil Páral 2024-02-29 09:25:31 UTC
(In reply to Fedora Update System from comment #16)
> FEDORA-2024-4afc15e835 (util-linux-2.39.3-6.fc39) has been submitted as an
> update to Fedora 39.
> https://bodhi.fedoraproject.org/updates/FEDORA-2024-4afc15e835

fstrim.timer is now enabled, thanks

Comment 19 Fedora Update System 2024-03-01 01:08:54 UTC
FEDORA-2024-4afc15e835 (util-linux-2.39.3-6.fc39) has been pushed to the Fedora 39 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.