SDB:修复 btrfsmaintenance-refresh
症状
- 启动时,由于 btrfsmaintenance-refresh.service 错误地创建新的计时器,systemd 会被重新加载。
- 已挂载的分区会无缘无故地再次卸载。
修改 btrfsmaintenance-refresh.service
供应商版本错误地包含了一个安装部分。禁用并创建一个修订后的系统版本
erlangen:~ # systemctl disable btrfsmaintenance-refresh.service erlangen:~ # systemctl edit --full btrfsmaintenance-refresh.service
删除“Install”部分并保存编辑会话。
检查您的修改
erlangen:~ # systemctl cat btrfsmaintenance-refresh.service # /etc/systemd/system/btrfsmaintenance-refresh.service [Unit] Description=Update cron periods from /etc/sysconfig/btrfsmaintenance [Service] ExecStart=/usr/share/btrfsmaintenance/btrfsmaintenance-refresh-cron.sh systemd-timer Type=oneshot erlangen:~ #
检查单元文件状态
注意:btrfsmaintenance-refresh.service 已加载,但处于非活动状态,而 btrfsmaintenance-refresh.path 既已加载又处于活动状态
erlangen:~ # systemctl list-units --all btrfsmaintenance-refresh.* UNIT LOAD ACTIVE SUB DESCRIPTION btrfsmaintenance-refresh.path loaded active waiting Watch /etc/default/btrfsmaintenance btrfsmaintenance-refresh.service loaded inactive dead Update cron periods from /etc/sysconfig/btrfsmaintenance LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type. 2 loaded units listed. To show all installed unit files use 'systemctl list-unit-files'. erlangen:~ #
启用 btrfsmaintenance-refresh.path。检查状态
erlangen:~ # systemctl enable btrfsmaintenance-refresh.path erlangen:~ # systemctl list-unit-files btrfsmaintenance-refresh.* UNIT FILE STATE VENDOR PRESET btrfsmaintenance-refresh.path enabled disabled btrfsmaintenance-refresh.service static enabled 2 unit files listed. erlangen:~ #
验证启动时的正确操作
重新启动机器并查看日志
erlangen:~ # journalctl -b -u btrfs* -o short-monotonic -- Logs begin at Sun 2020-03-29 16:41:11 CEST, end at Tue 2020-04-14 21:16:15 CEST. -- [ 4.207500] erlangen systemd[1]: Started Watch /etc/sysconfig/btrfsmaintenance. [ 17.512069] erlangen systemd[1]: Started Balance block groups on a btrfs filesystem. [ 17.512182] erlangen systemd[1]: Started Defragment file data and/or directory metadata. [ 17.512293] erlangen systemd[1]: Started Scrub btrfs filesystem, verify block checksums. erlangen:~ #
注意:btrfsmaintenance-refresh.service 在启动期间未运行!