Etcd: disk mount with unit fails

Created on 4 Sep 2014  ยท  10Comments  ยท  Source: etcd-io/etcd

At my cloud-config I have the following unit to mount an already btrfs formatted /dev/sdb1 partition to my ipxe booted server

- name: disk.mount
  command: start
  content: |
    [Unit]
    Description=Mount extra disk
    DefaultDependencies=no
    Conflicts=umount.target
    [Mount]
    What=/dev/sdb1
    Where=/mnt
    Type=btrfs
    TimeoutSec=10

This always fail with the folllowing errors

systemctl status disk.mount
โ— disk.mount - Mount extra disk
Loaded: error (Reason: Invalid argument)
Active: inactive (dead)
Where: /mnt
What: /dev/sdb1

Sep 04 00:46:14 core01 systemd[1]: disk.mount's Where= setting doesn't match unit name. Refusing.
Sep 04 00:56:02 core01 systemd[1]: disk.mount's Where= setting doesn't match unit name. Refusing.

What I am doing wrong ? Thanks,
George Mpouras

Most helpful comment

This comment is for those who land here after google search, this is not a bug in either etcd or coreos, its a feature of systemd's mount units. The solution is to name the file derived from the 'Where=' setting, by replacing '/' with '-' (and dropping the first '/'), so in the above case, the first line should have had been :

- name: mnt.mount

Source - http://www.freedesktop.org/software/systemd/man/systemd.mount.html

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.

All 10 comments

@crawford take a galance at this one?

@George-Mpouras This is not an etcd issue. Please file this bug under https://github.com/coreos/bugs/issues.

This comment is for those who land here after google search, this is not a bug in either etcd or coreos, its a feature of systemd's mount units. The solution is to name the file derived from the 'Where=' setting, by replacing '/' with '-' (and dropping the first '/'), so in the above case, the first line should have had been :

- name: mnt.mount

Source - http://www.freedesktop.org/software/systemd/man/systemd.mount.html

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.

What do you do if you want to mount the root filesystem in this way? :)

Note that according to adarshaj, paths with '-' in the name will not map correctly. If you are trying to mount /mnt/my-dash-dir -> Where=mnt-my-dash-dir which systemd will then search for as /mnt/my/dash/dir.

@crawford Can you please let me know how should it be addressed?
the mount name in /etc/systemd/system is 'path-A\x2dB\x2dC.mount' and its content:

[Unit]
Description=Mount
[Mount]
What=example.com:/mount
Where=/path/A-B-C/
Type=nfs
[Install]
WantedBy=multi-user.target

However still the same problem "Where= setting doesn't match unit name. Refusing"

I am pretty confused how to use the systemd-escape in this case

@Milad-Irani It works fine for me. Make sure you are quoting the mount name in Bash, otherwise the forward slash will be interpreted.

Where=/path/A\x2dB\x2dC

This comment is for those who land here after google search, this is not a bug in either etcd or coreos, its a feature of systemd's mount units. The solution is to name the file derived from the 'Where=' setting, by replacing '/' with '-' (and dropping the first '/'), so in the above case, the first line should have had been :

- name: mnt.mount

Source - http://www.freedesktop.org/software/systemd/man/systemd.mount.html

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.

I had this problem, I just need to name the *.mount files correctly.

if
Where=/media/user/abc

so the file name must be
media-user-abc.mount

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cheyang picture cheyang  ยท  3Comments

r007m4n picture r007m4n  ยท  3Comments

suresh-chaudhari picture suresh-chaudhari  ยท  3Comments

el10savio picture el10savio  ยท  4Comments

invidian picture invidian  ยท  3Comments