Systemd, how to mount a device at boot, but disable automount after boot

Latest response

Hi,

I do not seem to find a simple solution to the following problem:

I have a device listed in fstab, this should get mounted at boot. But if I manually unmount/remove the device after boot and if I present the device later on, systemd sees the device and automatically mounts it.

So how to prevent the latter (like pre-systemd behaviour). I can not use noauto in /etc/fstab since that will disable mounting at boot, which I still want to have.

Thanks

Responses

Hi Sven,

I wonder if this could help you: http://askubuntu.com/questions/25071/how-to-run-a-script-when-a-specific-flash-drive-is-mounted#679600.

Here, the device still gets mounted when it's hot-plugged, but your trigger script can unmount it immediately, or do anything else while at it.

Regards, Radek

As variant you can try: write the init.d script which will be mount and umount your file system at start/stop and remove your file system from fstab.

Thanks for the replies.

There are some ways to workaround systemd for this problem. But I would like to see it fixed with using systemd

After some digging it seems that the fstab systemd generator is creating device units and mnt units. The generator seems to add implicit values to this generated device unit, one of them is a "Wants" to the mount unit. Causing a dependency between the mount and the device. How can I influence or override the systemd generators so that it does not create this "Wants" dependency between the device and the mount?

show dev-mapper-test.device |grep -i wants
Wants=mnt-test.mount

But now the tricky part, even if you could override that "wants" then also starting at boot will be disabled...

Thanks

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.