3

I'm trying to automount CephFS after boot via systemd

I've got the next unit:

[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

As I know Where= setting must match unit name. I do next:

[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

But something went wrong:

[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.

How to name unit properly? Obviously the problem with a dash in mount point /mnt/cephfs-dev but I need exactly this mount point.

chicks
  • 3,793
  • 10
  • 27
  • 36
chs_voks
  • 33
  • 1
  • 5

2 Answers2

2

To put some closure to this:

The problem was that mnt-ceph\x2ddev.mount was a typo. It should have been mnt-cephfs\x2ddev.mount instead.

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
0

Mount units must be named after the mount point directories they control. Example: the mount point /home/lennart must be configured in a unit file home-lennart.mount.

Mount] What=/dev/vdc Where=/a/b/c Type=xfs Unit file name must be "a-b-c.mount", /usr/lib/systemd/system/a-b-c.mount