![用于 SSD 优化的“systemctl start fstrim.timer”在 Debian 10 上不起作用](https://linux22.com/image/182020/%E7%94%A8%E4%BA%8E%20SSD%20%E4%BC%98%E5%8C%96%E7%9A%84%E2%80%9Csystemctl%20start%20fstrim.timer%E2%80%9D%E5%9C%A8%20Debian%2010%20%E4%B8%8A%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8.png)
我刚刚安装了一个 1TB 金士顿 SSD,我克隆了我的 HDD(使用 Debian 10),所以除了性能之外没有任何改变,我想为这个 SSD 设置 TRIM。
所以我做了这个:
$ sudo hdparm -I /dev/sda | grep -i TRIM
* Data Set Management TRIM supported (limit 8 blocks)
$ sudo systemctl cat fstrim.service
# /lib/systemd/system/fstrim.service
[Unit]
Description=Discard unused blocks on filesystems from /etc/fstab
Documentation=man:fstrim(8)
[Service]
Type=oneshot
ExecStart=/sbin/fstrim -Av
$ sudo systemctl status fstrim.timer
● fstrim.timer - Discard unused blocks once a week
Loaded: loaded (/lib/systemd/system/fstrim.timer; enabled; vendor preset: enabled)
Active: inactive (dead)
Trigger: n/a
Docs: man:fstrim
正如您在第三个命令 fstrim.timer 的输出中看到的那样,fstrim.timer 处于非活动状态,因此要激活它,我认为我应该这样做:
$ sudo systemctl enable fstrim.service
其输出:
The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
Alias= settings in the [Install] section, and DefaultInstance= for template
units). This means they are not meant to be enabled using systemctl.
Possible reasons for having this kind of units are:
• A unit may be statically enabled by being symlinked from another unit's
.wants/ or .requires/ directory.
• A unit's purpose may be to act as a helper for some other unit which has
a requirement dependency on it.
• A unit may be started when needed via activation (socket, path, timer,
D-Bus, udev, scripted systemctl call, ...).
• In case of template units, the unit is meant to be enabled with some
instance name specified.
和
$ sudo systemctl start fstrim.timer
其输出:
Failed to start fstrim.timer: Unit -.mount is masked.
所以我不知道那里发生了什么,我已经搜索过如何解决这个问题,但我找不到正确的答案,我希望有人可以在这里帮助我,提前谢谢你。
答案1
作为ajgringo619建议我这样做:sudo systemctl unmask fstrim.timer
然后启动 fstrim.timer 并检查状态,一切正常。