I have a somewhat old NAS hosting my music collection. It is not capable of running a DAAP media server so I have mounted the music folder on my Sheevaplug (a tiny headless server running Debian) which then runs the DAAP media server.
It works perfectly, but the problem is that the mounting of the samba share prevents the NAS from going into hibernation when there is no activity. If I unmount the share manually, the NAS will hibernate after some time.
Because of that I am looking after a way to automatically mount the network drive when needed (ie. accessed) and unmount it again after a period with inactivy.
I have tried
inotifywait to monitor read access in the mount point, but unfortunately that does not catch reading from files not found which is what happens when the DAAP server tries to stream a music file in the empty folder.
Then I have googled more and have found
autofs which seems to be able to do exactly what I need. But unfortunately, even after reading a guide like this, I still don't understand how to use it.
I was confused by the small differences between Debian and Gentoo. In Gentoo the config file is /etc/autofs/auto.misc whereas Debian uses /etc/auto.misc and so on.
Adjusting for those subtle differences, autofs works perfectly. It mounts the samba share when needed and unmouns it again after the timeout period given in auto.master