I wanted to use Autofs to auto-mount the shares on my Netgear ReadyNAS upon entering specific directories so…
Install pre-requisites:
sudo apt-get install cifs-utils autofs
sudo gedit /etc/auto.master
Add the line:
/mnt/nas /etc/auto.nas --timeout=6000 --ghost
sudo gedit /etc/auto.nas
And added the following lines:
pictures -fstype=cifs,rw,noperm ://nas/pictures
videos -fstype=cifs,rw,noperm ://nas/videos
music -fstype=cifs,rw,noperm ://nas/music
documents -fstype=cifs,rw,noperm ://nas/documents
backup -fstype=cifs,rw,noperm ://nas/backup
readydrop -fstype=cifs,rw,noperm ://nas/readydrop
Note that I have used ‘nas’ instead of the nas IP address and I also opted not to use a credentials file as my ReadyNAS shares are public.
restart autofs
Test it out with:
ls -al /mnt/nas/videos