If I use this command :

mount -t xfs -o noatime,nodiratime,logbufs=8 -L d1 /srv/node/d1

all works correctly. But if I try to mount through the systemd mount it fails.

I've created a file /etc/systemd/system/mnt-d1.mount with the following content:

Description = Disk 1

What = LABEL=d1
Where = /srv/node/d1
Type = xfs
Options = noatime,nodiratime,logbufs=8

WantedBy = multi-user.target

After that I run these commands:

systemctl daemon-reload
systemctl start mnt-d1.mount

The last one showed me:

Failed to start mnt-d1.mount: Unit mnt-d1.mount failed to load: Invalid argument.  
See system logs and 'systemctl status mnt-d1.mount' for details.

systemctl status mnt-d1.mount showed me:

May 16 18:13:52 object1 systemd[1]: Cannot add dependency job for unit mnt-d1.mount, ignoring: Unit mnt-d1.mount failed to ...ectory.
May 16 18:24:05 object1 systemd[1]: mnt-d1.mount's Where= setting doesn't match unit name. Refusing.

Please help me to mount a disk via a systemd mount unit.

  • Still doesn't work.. The same error – Alexandr May 16 '16 at 12:51
  • This question should be reopened - I've had the same problem and the solution presented in the comment helped me. The comment should be made an answer so I can upvote it. – Guss Feb 16 '17 at 14:43

The error message explains the cause:

Where= setting doesn't match unit name. Refusing.

though understanding that message requires reading several man pages.
Per systemd.mount man page (emphasize mine):


Takes an absolute path of a directory of the mount point. If the mount point does not exist at the time of mounting, it is created. This string must be reflected in the unit filename. (See above.) This option is mandatory.

The "see above" part is:

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. For details about the escaping logic used to convert a file system path to a unit name, see systemd.unit(5).

OK, systemd.unit man page states that:

Properly escaped paths can be generated using the systemd-escape(1) command.

pointing to systemd-escape man page which explains how to do it:

To generate the mount unit for a path:

$ systemd-escape -p --suffix=mount "/tmp//waldi/foobar/"

So, in your case, /srv/node/d1 translates to srv-node-d1.mount

  • 3
    It's important to note that the "path escaping" system can get a bit complex even dealing with non-A-Z names. Even some dashes in the path will need to be converted to the C-style \x2d escape, which when used to create the unit file may (depending on your shell/editor) need to again escape the slash character - so the unit file fit mounting /some-path may require running edit some\\x2dpath.mount – Guss Feb 16 '17 at 19:22

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.