我现在有一台装有Ubuntu 18.04的笔记本电脑,我喜欢它。我已经通过/etc/fstab
行将/ tmp挂载为tmpfs,如下所示:
tmpfs /tmp tmpfs defaults,noatime,nosuid,nodev,noexec,mode=1777 0 0
现在,我想知道我该怎么做systemd
,我只需要激活一项新systemd
服务(tmp.mount
相关),或者我还需要一件东西?如何在实时模式下/etc/fstab
用systemd
笔记本电脑替换我的实际生产线?
请注意,使用/etc/fstab
仍然是systemd的首选方法!
请参见手册页中的systemd.mount,其中指出:
通常,通过/ etc / fstab配置安装点是首选方法。
systemd提供了systemd-fstab-generator,可将其转换为安装单元。
如果您真的想将该安装架转换为安装架,我的建议是使用以下命令检查其当前的确切配置:
$ systemctl cat tmp.mount
或者:
$ systemctl cat /tmp
它将向您显示由systemd-fstab-generator创建的动态单位,其外观应类似于:
# /run/systemd/generator/tmp.mount
# Automatically generated by systemd-fstab-generator
[Unit]
SourcePath=/etc/fstab
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
Before=local-fs.target
[Mount]
What=tmpfs
Where=/tmp
Type=tmpfs
Options=noatime,nosuid,nodev,noexec,mode=1777
您可以将这些内容保存到/etc/systemd/system/tmp.mount
并运行systemctl enable tmp.mount
以将其激活。(您需要添加一个[Install]
板块和一个板块WantedBy=local-fs.target
才能成功启用它。)
(另一种选择是使用来自systemd来源的tmp.mount。其他一些发行版(如Fedora)正在交付并启用该发行版。)
不要忘记从中删除一个/etc/fstab
,否则它们可能会发生冲突。(我相信fstab中的那个会占上风,因为我希望/run
优先于/etc
。)
但是,如前所述,通过管理/etc/fstab
仍然是首选的解决方案...因此,我可能建议您仍然坚持使用该解决方案。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句