How to mount a sambashare with autofs and cifs
Solution 1
I was having a similar problem until I figured out reading a lot of pages. Try this:
Make a sub-directory for automount in
/media
like/media/auto
(I wanted to automount two different servers/files here and/media
is available for other stuffs)Edit
/etc/auto.master
with:/media/auto /etc/auto.cifs-shares --timeout=500
(You can give another name to file "auto.cifs-shares" and change timeout to another value if you want to)
Create a file for store your config (as I wrote above I've written in
/etc/auto.cifs-shares
)files --fstype=cifs,credentials=/home/your_user/.credentials,dir_mode=0755,file_mode=0755,uid=your_user,rw ://server/files
(if you don't give credentials it will automount as anonymous, it depends on permission)
You have to restart service for having changes taking effect:
service autofs restart
That's it! Next try:
ls /media/auto/files
(should give you what you want)
Solution 2
Try inserting a direct map line in "/etc/auto.master" - something like:
/- /etc/auto.data
Where "/etc/auto.data" contains the "direct" mount point and your cifs mount info that you previously had in "myserver.autofs" - i.e.:
/media/server/files -fstype=cifs,rw ://server/files
I am new to autofs and was not able to get an "indirect" mapping working for a cifs mount but the above "direct" mapping method works for me.
Related videos on Youtube
Comments
-
Redsandro over 1 year
I'm trying to automount a sambashare as CIFS, as documented here: https://help.ubuntu.com/community/Autofs#CIFS
This seems so simple, I'm running out of things to google. It's probably something very obvious. Let me speak in commands:
sudo apt-get install autofs
sudo nano /etc/auto.master.d/myserver.autofs
files -fstype=cifs,rw ://server/files
sudo automount -f -v
Starting automounter version 5.0.7, master map /etc/auto.master using kernel protocol version 5.02 syntax error in map near [ files -fstype=cifs,rw : ] no mounts in table
I didn't do a whole lot, but I still did something wrong. How do I get this working?
edit @Jos
updated
myserver.autofs
:/media/server/files -fstype=cifs,rw ://server/files
Output from
sudo automount -f -v
:Starting automounter version 5.0.7, master map /etc/auto.master using kernel protocol version 5.02 : / / / file map /etc/-fstype=cifs not found mounted indirect on /media/server/files with timeout 300, freq 75 seconds statemachine:1363: got unexpected signal 28!
Now we have a directory in
/media
! But it's empty.-
Panther over 8 yearspost your other configuration files
-
Jos over 8 yearsPerhaps the mount point needs to contain the full path? (i.e.
/path/to/files -fstype=cifs,rw ://server/files
) -
Redsandro over 8 years@bodhi.zazen such as?
auto.master
contains+dir:/etc/auto.master.d
which is empty. -
Redsandro over 8 years@Jos ok that seems to help, but I think the line is different from what was expected. It searches for the
-fstype
flag as if it's searching for a binary. I think the docs are outdated. -
Jos over 8 yearsHm. According to the most recent man page it should be correct as stated.
-
-
Sridhar Sarnobat about 7 yearsUntil reading your post I didn't notice that direct and indirect mappings were different! Now I've got something working.
-
Tom about 2 yearsShould that be
-fstype
instead of--fstype
?