[systemd-devel] Suppressing automounting
Lennart Poettering
lennart at poettering.net
Tue Aug 19 13:43:27 PDT 2014
On Tue, 19.08.14 15:56, Dale R. Worley (worley at alum.mit.edu) wrote:
> (This is more proper for a systemd-users mailing list, but I can't
> find one.)
>
> I'd like to customize my systemd. (I'm running Fedora Linux 19, with
> systemd-204-20.fc19.x86_64.)
>
> I have a line in /etc/fstab like this, which refers to a logical
> volume on a USB storage device:
>
> /dev/Freeze02/Store2 /Store2 ext4 nofail,defaults 0 0
>
> Of course, if the logical folume Store2 is present at boot time, it
> gets mounted.
This is not really what "nofail" means in a systemd context. It just
means that we won't delay the boot process for this device to show
up. This means that the device will be mounted as it shows up but we
won't wait for it at boot.
To turn off automatic mounting of the device, you need to use "noauto"
instead.
Note that a concept of "mount at boot if it is there, otherwise don't"
cannot work. The problem here is that most modern storage devices can
take any time they want to initialize and we simply have no idea how
long to wait for them. Because of that we just wait for the file systems
listed in /etc/fstab and immediately continue.
Especially on USB there's no point in time known where all devices have
to have reported back to the OS, they can take any time they want. (For
the most extreme case, think of Android devices, which when plugged into
a PC actually require confirmation on the device before the device shows
up!)
> In the past, once the system is running, if I plug in the storage
> device, the volume does not get mounted unless I manuall issue "mount
> /Store2".
>
> More recently, if I plug in the storage device, the volume gets
> mounted automatically. Messages in /var/log/messages suggest that
> systemd is doing the mounting.
Correct.
> I would like to suppress the latter automatic mounting. (This is for
> all filesystems, which means I don't want to have to modify every
> fstab line.)
Well, this is not possible with the current logic. You have three choices:
a) not mount it at all by default (noauto)
b) wait for it at boot and mount it (default)
c) don't wait for it, but mount it as it shows up (nofail)
As mentioned an option d) of "mount it if it is around at boot, but not
later" is not available, since the idea is not compatible with modern
storage.
> The documentation of systemd is voluminous and hard to understand, but
> I believe that in order to do this, I need to provide systemd with a
> value that applies to all *.automount units that suppresses the action
> of the unit. Because I do not want to put "noauto" in the fstab line,
> I expect that the initial mounting will still be done if the logical
> volume is present at boot time. I'm guessing that putting something
> in a "automount at .service" file will suffice.
The ".automount" units actually are about something slightly different:
they are a way how you can establish mount points without actually
backing them immediately with a file system, but simply delaying that
until the first access. They implement what autofs4 or amd do, too. It
is not directly related to what you are trying to do.
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list