Automounting Samba shares using autofs

From froelix.com - Wiki
Revision as of 14:22, 4 December 2015 by Froelix (Talk | contribs) (added notes)

Jump to: navigation, search

Instructions:

1. Install autofs

$ sudo apt-get install autofs

2. Create map file with one mountpoint per line

# echo "desiredmountpoint -fstype=cifs,rw,username=mysmbuser,password=mysmbpwd,uid=myuser,gid=mygroup ://hostname/directory" >> /etc/auto.somename

3. Add mapp file to master map

# echo "/mnt/anyexistingdir    /etc/auto.somename" >> /etc/auto.master

4. Restart the autofs daemon and check if it is working

$ sudo /etc/init.d/autofs restart

Notes:

  • There might be some troubles resolving the hostname of the Samba server. Using the IP address instead of the hostname helped in my case.
  • For more details regarding autofs, see here.