Autofs mount when server goes to sleep

I have all of my video files on an autofs mount of an SMB share. A long-standing issue is that the server is set to go to sleep after ten minutes of inactivity to save power; this leaves Kodi with what looks like an empty local folder. (Kodi obviously has no way of knowing whether it’s a mounted folder or a genuinely local one as that distinction is only visible at OS level).

So, if I try to play something from the library when the server is asleep, Kodi reports that the file is no longer present, and asks if I should delete the library item. (Reasonable so far). However, if I say no, then wake up the server, then try to play the video again, it still doesn’t play; it’s as if, once autofs has checked for the presence of the remote share once, if it finds it isn’t there, it doesn’t bother to check again.

It’s possible to get the video to play if I restart autofs:

sudo systemctl restart autofs

After running that, if I try playing the video again, now it plays. But is there a way to configure autofs so that it actively checks for the presence of the remote share each time an application tries to access the mounted folder, instead of checking once and then giving up if it isn’t there the first time?

Here is my /etc/auto.master file:

#
# Sample auto.master file
# This is a 'master' automounter map and it has the following format:
# mount-point [map-type[,format]:]map [options]
# For details of the format look at auto.master(5).
#
#/misc  /etc/auto.misc
#
# NOTE: mounts done from a hosts map will be mounted with the
#       "nosuid" and "nodev" options unless the "suid" and "dev"
#       options are explicitly given.
#
#/net   -hosts
#
# Include /etc/auto.master.d/*.autofs
# The included files must conform to the format of this file.
#
+dir:/etc/auto.master.d
#
# Include central master map if it can be found using
# nsswitch sources.
#
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
#
+auto.master
/- /etc/auto.smb.shares --timeout 15 browse

And here is /etc/auto.smb.shares (usernames and passwords redacted):

/mnt/smb/nicolas-pc/VideoE -fstype=cifs,rw,username=XXXXX,password=XXXXX,iocharset=utf8,uid=osmc,gid=osmc,vers=3.0 ://192.168.1.13/VideoE/
/mnt/smb/nicolas-pc/VideoF -fstype=cifs,rw,username=XXXXX,password=XXXXX,iocharset=utf8,uid=osmc,gid=osmc,vers=3.0 ://192.168.1.13/VideoF/
/mnt/smb/nicolas-pc/Interim -fstype=cifs,rw,username=XXXXX,password=XXXXX,iocharset=utf8,uid=osmc,gid=osmc,vers=3.0 ://192.168.1.13/Interim/
/mnt/smb/nicolas-pc/QBTE -fstype=cifs,rw,username=XXXXX,password=XXXX,iocharset=utf8,uid=osmc,gid=osmc,vers=3.0 ://192.168.1.13/QBTE/
/mnt/smb/nicolas-pc/QBTF -fstype=cifs,rw,username=XXXXX,password=XXXXX,iocharset=utf8,uid=osmc,gid=osmc,vers=3.0 ://192.168.1.13/QBTF/

I think this is actually more of a Kodi thing as I’ve seen similar on my PC when I remove a file with Kodi running and then replace it with another file named the exact same, I get that message. I found that I can actually play another file, stop it, and then the first file will play as it should. It seems that once a file times out then Kodi will not try again until (something).

Do you have try to wake up and max wait time set in settings>system>power savings?

I do, yes. But that only works for sources that are defined as SMB or as NFS at the Kodi level. If a remote share is mounted using autofs then, as far as Kodi is concerned, it’s simply a folder in the local filing system - so Kodi doesn’t know it has to wake anything up, it’s just looking for a file in a local folder and not finding it.

If that were the case, wouldn’t Kodi still not bother looking for the file even after I’ve unmounted the folder and restarted autofs? Does Kodi even know I’ve done that?

The 10-minute shutdown of the server is rather aggressive for something that is supposed to be acting as a server. Consider a disk spindown first before going for a (further delayed) shutdown.

It also seems that the problem would stop if you first remembered to start the server before using Kodi.

You could try restarting mediacenter after autofs. If that works, you can always combine the two commands into a shell script.