我试图通过systemd启动后自动挂载CephFS
我有下一个单位:
[Unit] SourcePath=/etc/fstab DefaultDependencies=no After=remote-fs-pre.target After=network.target Wants=network.target After=network-online.target Wants=network-online.target Conflicts=umount.target Before=umount.target [Mount] What=ceph-node1:6789,ceph-node2:6789,ceph-node3:6789:/dev Where=/mnt/cephfs-dev Type=ceph Options=name=devuser,secretfile=/etc/ceph/cephuser.secret [Install] WantedBy=remote-fs.target
据我所知, Where=设置必须与单元名称匹配。 我接下来做:
[root@centos system]# systemd-escape -p --suffix=mount '/mnt/cephfs-dev' mnt-cephfs\x2ddev.mount [root@centos system]# vi /etc/systemd/system/mnt-cephfs\\x2ddev.mount
但是出了点问题:
[root@centos system]# systemctl status mnt-ceph\\x2ddev.mount ● mnt-ceph\x2ddev.mount - /mnt/cephfs-dev Loaded: error (Reason: Invalid argument) Active: inactive (dead) Where: /mnt/cephfs-dev What: ceph-node1:6789,ceph-node2:6789,ceph-node3:6789:/dev May 05 10:07:12 centos.imoldovan-lpt systemd[1]: mnt-ceph\x2ddev.mount's Where= setting doesn't match unit name. Refusing.
如何正确命名单位? 很明显,在挂载点/mnt/cephfs-dev短划线的问题,但我需要正是这个挂载点。
为了说明这一点:
问题是, mnt-ceph\x2ddev.mount是一个错字。 应该是mnt-cephfs\x2ddev.mount 。
安装单元必须以它们控制的安装点目录命名。 例如:必须在单元文件home-lennart.mount中configuration挂载点/ home / lennart。
Mount] What = / dev / vdc Where = / a / b / c Type = xfs单元文件名必须为“abc.mount”,/usr/lib/systemd/system/abc.mount