[systemd-devel] unable to automount overlayfs with upperdir set to mount point

Dominik Fischer d.f.fischer at web.de
Fri Feb 19 00:45:30 UTC 2016


I recently tried to configure an automount point for an overlayfs with systemd
version 229 on Arch Linux. It failed with a mount error. As this is my first
time writing a unit for mounting, I am unsure whether I correctly expressed the
unit files. Thus, I would like to ask you to have a look into my setup and tell
me whether I did something wrong or whether this indeed qualifies as a bug.

Steps to reproduce follow. All commands are to be executed as root.

Overlayfs is a pseudo-filesystem to join multiple directory and file
hierarchies. So create two for testing and mount them together manually.

# mkdir /tmp/{upper,lower,work} touch /tmp/upper/a /tmp/lower/b mount overlay
# /tmp/upper -t overlay \
-o upperdir=/tmp/upper,lowerdir=/tmp/lower,workdir=/tmp/work

This works just fine. Files from both directories show up in "uppper",
everything created there stays there. Then I unmounted and tried to achieve the
same with a systemd mount unit. Therefore, I placed both attached files into
/usr/lib/systemd/system/. After that

# systemctl start tmp-upper.mount

has the exact same effect as the mount line above, as expected. However,
triggering the activated automount point via ls fails.

# systemctl stop tmp-upper.mount systemctl start tmp-upper.automount ls
# /tmp/uppper
ls: cannot open directory '/tmp/upper': No such device

journalctl shows a message from the kernel that says "overlayfs: filesystem on
'/tmp/upper' not supported". I suspect that this is because autofs is still
mounted at /tmp/upper when the overlayfs tries to establish it as its upperdir.
Testing a setup where the mount point is distinct from the upperdir indeed
works flawless. Unfortunately, this is exactly the case I need overlayfs for.

Is there any way around this to have an overlayfs automount despite its
upperdir is the same as its mount point?
-------------- next part --------------
[Unit]
Description=Overlayfs test mount point

[Mount]
What=overlay
Where=/tmp/upper
Type=overlay
Options=upperdir=/tmp/upperr,lowerdir=/tmp/lower,workdir=/tmp/work
-------------- next part --------------
[Unit]
Description=Overlayfs test automount point

[Automount]
Where=/tmp/upper

[Install]
WantedBy=local-fs.target


More information about the systemd-devel mailing list