自去年二月以来,我一直在运行Ubuntu20.04桌面。
今天我发布了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.然后,我检查了服务是否已经启用,所以我发布了journalctl -fu fstrim,得到了“日志开始于Sun 2022-07-1007:55:26 PDT”,然后是8月8日和8月15日的事件列表。
最后,我发布了systemctl status fstrim.service并得到了以下消息:
fstrim.service - Discard unused blocks on filesystems from /etc/fstab
Loaded: loaded (/lib/systemd/system/fstrim.service; static; vendor preset:>
Active: inactive (dead)
TriggeredBy: fstrim.timer
Docs: man:fstrim(8)所以看起来fstrim已经在运行了,并且在2月份我安装Ubuntu时默认启用了它。我的问题是:
(1)上述来自 systemctl启用fstrim.service的消息的意义是什么?
(2)它似乎每周运行一次,星期一。这个频率够高还是太频繁了?如果我需要的话,怎样才能改变修剪频率呢?
(3)由于已开箱即用,是否有其他建议选项可供选择?
发布于 2022-08-21 18:05:31
是。当安装程序看到SSD时,fstrim将自动安装。
sudo systemctl enable fstrim.service显示的这些消息的意义是什么?除了已经显示的原因之外,在服务已经运行时也会显示这一点。当/etc/systemd/system/multi-user.target.wants/中已有一个符号链接时,就会触发它。
是。不是的。从手册上看:
频繁地运行fstrim,甚至使用
mount -o discard,可能会对劣质SSD设备的寿命产生负面影响。对于大多数桌面和服务器系统,足够的修剪频率是每周一次。
并查看fstrim.timer服务。里面有“周报”:
$ more /usr/lib/systemd/system/fstrim.timer
[Unit]
Description=Discard unused blocks once a week
Documentation=man:fstrim
ConditionVirtualization=!container
ConditionPathExists=!/etc/initrd-release
[Timer]
OnCalendar=weekly
AccuracySec=1h
Persistent=true
RandomizedDelaySec=6000
[Install]
WantedBy=timers.target不是的。建议不要改变其中任何一个。
但是,除了fstrim.timer提供的功能之外,fstrim手册还有4个选项可以操作fstrim的功能:
默认情况下,fstrim将丢弃文件系统中所有未使用的块。选项可用于根据范围或大小修改此行为,如下所述。
它提到的备选方案如下:
-o,--文件系统中的偏移量字节偏移量,从中开始搜索要丢弃的空闲块。默认值为零,从文件系统的开头开始。-l,-长度是搜索要丢弃的空闲块的字节数(在起始点之后)。如果指定的值扩展到文件系统的末尾,fstrim将在文件系统大小边界处停止。默认值扩展到文件系统的末尾。-I,- list - in list指定了一个由冒号分隔的文件列表,这些文件以fstab或内核挂载信息格式显示.所有丢失的或空的文件都会被忽略。列表的计算在第一个非空文件之后停止。例如:-列出-in /etc/fstab:/proc/self/mountinfo。-m,-最小最小大小最小连续空闲范围,以字节为单位.(这个值在内部被舍入到文件系统块大小的倍数。)小于此范围的空闲范围将被忽略,fstrim将调整最小值(如果小于设备的最小值),并将该值(fstrim_range.minlen)报告回用户空间。通过增加这个值,fstrim操作将更快地完成对于具有严重碎片的空闲空间的文件系统,尽管并不是所有的块都会被丢弃。默认值为零,丢弃每个空闲块。
https://askubuntu.com/questions/1424869
复制相似问题