Mounting an unreachable CIFS results in slow login and other problems

I have a NAS that I mount via CIFS. My /etc/fstab:

//192.168.178.1/FRITZ.NAS/ /home/xxx/NAS cifs credentials=/home\
/xxx/.smbcredentials,vers=3.0,noserverino,uid=1000,\
gid=1000,x-systemd.automount,x-systemd.requires=network-online.target,x-systemd.device-timeout=10ms 0 0

I works well in my home network, of course, but as soon as I leave the house and 192... isn't available anymore, I experience very slow logins and other problems, i.e. when trying to browse my files with Nautilus or any other program that tries to access the file system.

dmesg then shows:

[ 1176.653340] CIFS: Attempting to mount //192.168.178.1/FRITZ.NAS/
[ 1186.984727] CIFS: VFS: Error connecting to socket. Aborting operation.
[ 1186.984739] CIFS: VFS: cifs_mount failed w/return code = -2
[ 1186.993225] CIFS: Attempting to mount //192.168.178.1/FRITZ.NAS/
[ 1197.224579] CIFS: VFS: Error connecting to socket. Aborting operation.
[ 1197.224590] CIFS: VFS: cifs_mount failed w/return code = -2
[ 1197.233060] CIFS: Attempting to mount //192.168.178.1/FRITZ.NAS/
[ 1207.464505] CIFS: VFS: Error connecting to socket. Aborting operation.
[ 1207.464516] CIFS: VFS: cifs_mount failed w/return code = -2
[ 1207.476803] CIFS: Attempting to mount //192.168.178.1/FRITZ.NAS/
[ 1217.705176] CIFS: VFS: Error connecting to socket. Aborting operation.
[ 1217.705187] CIFS: VFS: cifs_mount failed w/return code = -2
[ 1217.713857] CIFS: Attempting to mount //192.168.178.1/FRITZ.NAS/

So over the course of dozens of seconds, it tries to mount the NAS again and again, which seems to block the system entirely...

The timeout option I added doesn't seem to help, dmesg tells me it is ignored:

[ 1078.414184] systemd-fstab-generator[532]: x-systemd.device-timeout ignored for //192.168.178.1/FRITZ.NAS/

Also adding a nofail option doesn't help.

Isn't there an option to have a very short timeout so it doesn't bother me when I'm not in my home network?


This really depends on how you use this remote share but I think you have two options:

[1] Keep the systemd.automount but add another option and change your mount point.

You need to add noauto to your options and add it before x-systemd.automount.

You will also need to change your mount point to someplace other than in your home directory or under /media. Having it under these locations induces a udisks response that makes the automounter think it's being accessed.

Without these changes your system will always attempt to mount it automatically at boot.

[2] There is another way to do this that doesn't use the systemd automounter and you can keep your mount point:

Replace x-systemd.automount with noauto,user

A mount icon will appear on the side panel of your file manager that is actionable. Click on it and it will go to fstab to find out how and mount it with those instructions

Either method will mean the remote share will mount only when accessed and not automatically.