20.7. 使用 systemd.automount ,通过 /etc/fstab 按需挂载文件系统
当挂载点已在 /etc/fstab 中定义时,使用自动挂载 systemd 单元来按需挂载文件系统。您必须为每个挂载添加自动挂载单元并启用它。
流程
添加所需的 fstab 条目,如 永久挂载文件系统 中所述。例如:
/dev/disk/by-id/da875760-edb9-4b82-99dc-5f4b1ff2e5f4 /mount/point xfs defaults 0 0-
将
x-systemd.automount添加到上一步中创建的条目的 options 字段中。 加载新创建的单元,以便您的系统注册新配置:
# systemctl daemon-reload启动自动挂载单元:
# systemctl start mount-point.automount
验证
检查
mount-point.automount是否正在运行:# systemctl status mount-point.automount检查自动挂载的目录是否有所需的内容:
# ls /mount/point
如需更多信息,请参阅 管理 systemd