You are not logged in.

#1 2014-02-09 09:05:13

ball
Member
From: Germany
Registered: 2011-12-23
Posts: 164

[x-systemd.automount] timeout or failover

Hello there,

I use a laptop and backup my data to an external hdd via a script which is executed by cron. In order to boot successful when the drive is not attached I came up with the following fstab entry:

/dev/mapper/backup /mnt/backup ext4 rw,nosuid,nodev,noexec,nouser,noauto,x-systemd.automount 0 2

This works mostly as it should: booting is fine even when the drive is not attached; when the drive gets accessed by the backup script, it gets mounted automatically. However when accessing the mountpoint /mnt/backup when the drive is not attached the mounting "process" hangs forever: systemd wants to mount a drive which is not present and waits for it until it shows up. This is unfortunate as backup script is executed every hour.

I want to have the automounting fail when the drive is not attached. (Because the backup script checks for a certain folder structure in the mountpoint, which would cause the script to abort silently.) I tried adding x-systemd.device-timeout=5 to the mount options but that doesn't have any effect. (Is this a bug or a user misconception?)

How can I alter my setup to only mount the drive when it is attached?

EDIT: udiskie (or something similar) is no alternative to fstab as the drive is encrypted and should be mounted by the means of crypttab and a keyfile without having to type the passphrase.

Last edited by ball (2014-02-09 13:52:56)

Offline

#2 2014-02-09 13:41:14

ball
Member
From: Germany
Registered: 2011-12-23
Posts: 164

Re: [x-systemd.automount] timeout or failover

Well, of course I could always check in the backup script if the uuid of the harddisk is present in /dev/disk/by-uuid but this seems to me like dirty workaround as other commands like a simple ls on the mountpoint will hang forever...

If no "real" or better solution turns up I'll mark this as solved.

autofs doesn't seem like an alternative, as it doesn't provide a non-hacky way of mounting encrypted partitions, does it?

(Minor grr: I am somewhat surprised that automounting is always such an issue. Automounting is tackled by so many approaches, which often lack basic functionality. I consider not mounting a non-present device as very basic functionality. Am I unfair here?)

Last edited by ball (2014-02-09 13:59:19)

Offline

#3 2014-02-09 18:07:49

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [x-systemd.automount] timeout or failover

I think what you want is to have the script run when the device becomes present rather than just having it run at in interval which checks for the device's presence.  You can use udev to start a systemd unit when it detects the disk.

Our own Jason Ryan has recently written up a very nice blog post on the matter: http://jasonwryan.com/blog/2014/01/20/udev/  Enjoy!

Offline

#4 2014-02-09 18:28:53

ball
Member
From: Germany
Registered: 2011-12-23
Posts: 164

Re: [x-systemd.automount] timeout or failover

Thanks, I already discovered Jason's fine blog post, and in fact I use it for off site backups to another disk at my work place. However using udiskie requires typing the passphrase every time which is cumbersome. It would be *perfect* if udiskie made use of keyfiles or respected fstab/crypttab entries.

Last edited by ball (2014-02-09 21:29:51)

Offline

Board footer

Powered by FluxBB