Difference between revisions of "Automounting Samba shares using autofs"

From froelix.com - Wiki
Jump to: navigation, search
(added page)
 
(added forcing cifs version)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
Install autofs
+
'''Instructions:'''
 +
 
 +
1. Install autofs
 
  $ sudo apt-get install autofs
 
  $ sudo apt-get install autofs
  
Create map file with one mountpoint per line
+
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
 
  # echo "desiredmountpoint -fstype=cifs,rw,username=mysmbuser,password=mysmbpwd,uid=myuser,gid=mygroup ://hostname/directory" >> /etc/auto.somename
 +
To force a specific CIFS/SMB version use the following syntax
 +
# echo "desiredmountpoint -fstype=cifs,rw,username=mysmbuser,password=mysmbpwd,uid=myuser,gid=mygroup,vers=2.0 ://hostname/directory" >> /etc/auto.somename
 +
 +
3. Add mapp file to master map (default timeout is 15min/900sec)
 +
# echo "/mnt/anyexistingdir    /etc/auto.somename    --timeout 3600" >> /etc/auto.master
 +
 +
4. Restart the autofs daemon and check if it is working
 +
$ sudo /etc/init.d/autofs restart
 +
 +
'''Notes:'''
  
Add mapp file to master map
+
* There might be some troubles resolving the hostname of the Samba server. Using the IP address instead of the hostname helped in my case.
# echo "/mnt/anyexistingdir    /etc/auto.somename" >> /etc/auto.master
+
* For more details regarding autofs, see [https://help.ubuntu.com/community/Autofs here].

Latest revision as of 01:28, 19 February 2018

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

To force a specific CIFS/SMB version use the following syntax

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

3. Add mapp file to master map (default timeout is 15min/900sec)

# echo "/mnt/anyexistingdir    /etc/auto.somename    --timeout 3600" >> /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.