Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I followed the guide on this page to get samba shares working via autofs:

http://www.howtoforge.com/accessing_windows_or_samba_shares_using_autofs

Servers and Configuration

My Samba server (remote) is on a server named "mattserver" (that's its Windows server name). It has four shares, called "backup", "matt", "print", and "web". The Samba client (local) is named "bird".

My setup is very similar to the examples in the aforementioned tutorial, except for some differences:

  • /cifs /etc/auto.cifs --ghost instead of /cifs /etc/auto.cifs --timeout=60 in /etc/auto.master
  • uid=1000,gid=1000 instead of uid=user,gid=users in /etc/auto.cifs

Here's my /etc/auto.master:

matt@bird:~ $ cat /etc/auto.master
/cifs /etc/auto.cifs --ghost

Here's my /etc/auto.cifs:

matt@bird:~ $ cat /etc/auto.cifs
#!/bin/bash
key="$1"
credfile="/etc/auto.smb.$key"
mountopts="-fstype=cifs,file_mode=0644,dir_mode=0755,uid=1000,gid=1000"
smbclientopts=""
for P in /bin /sbin /usr/bin /usr/sbin
do
    if [ -x $P/smbclient ]
        then
        SMBCLIENT=$P/smbclient
        break
    fi
done
[ -x $SMBCLIENT ] || exit 1
if [ -e "$credfile" ]
then
    mountopts=$mountopts",credentials=$credfile"
    smbclientopts="-A "$credfile
else
    smbclientopts="-N"
fi
$SMBCLIENT $smbclientopts -gL $key 2>/dev/null \
    | awk -v key="$key" -v opts="$mountopts" -F'|' -- '
        BEGIN   { ORS=""; first=1 }
        /Disk/  { if (first) { print opts; first=0 };
        gsub(/ /, "\\ ", $2);
        sub(/\$/, "\\$", $2);
        print " \\\n\t /" $2, "://" key "/" $2 }
        END     { if (!first) print "\n"; else exit 1 }
        '

So here's what I get when I call /etc/auto.cifs directly:

matt@bird:~ $ sudo bash /etc/auto.cifs mattserver
-fstype=cifs,file_mode=0644,dir_mode=0755,uid=1000,gid=1000,credentials=/etc/auto.smb.mattserver \
            /print\$ ://mattserver/print\$ \
            /matt ://mattserver/matt \
            /web ://mattserver/web \
            /backup ://mattserver/backup

So far, so good, I think.

Testing

When I try to access the /cifs directory, I should get one directory called mattserver, right? I did put the --ghost option in there. I don't get anything though:

matt@bird:~ $ ls -l /cifs
total 0

When I access the server directory, I get a list of shares but it's screwed up:

matt@bird:~ $ ls -l /cifs/mattserver
ls: cannot access /cifs/mattserver/web: No such file or directory
ls: cannot access /cifs/mattserver/print$: No such file or directory
ls: cannot access /cifs/mattserver/matt: No such file or directory
ls: cannot access /cifs/mattserver/backup: No such file or directory
total 0
d????????? ? ? ? ?                ? backup
d????????? ? ? ? ?                ? matt
d????????? ? ? ? ?                ? print$
d????????? ? ? ? ?                ? web

When I try to access an actual share, I get nothing:

matt@bird:~ $ ls -l /cifs/mattserver/web
ls: cannot access /cifs/mattserver/web: No such file or directory

As a test, I added a line to /etc/hosts for mattserver.

Still no ghosting:

matt@bird:~ $ ls -l /cifs
total 0

When I try accessing the server directory again, I no longer get a list of shares:

matt@bird:~ $ ls -l /cifs/mattserver
ls: cannot access /cifs/mattserver: No such file or directory

But when I access an actual share, I get full access:

matt@bird:~ $ ls -l /cifs/mattserver/web
[correct listing of files -- removed]

I should be able to rely on broadcasting and I shouldn't need to have anything in /etc/hosts (right?). Broadcasting is working:

matt@bird:~ $ nmblookup mattserver
querying mattserver on 192.168.0.255
192.168.0.2 mattserver<00>

Problems

  • When I try and access a list of servers by calling ls -l /cifs, I get nothing.
  • When I try and access a list of shares by calling ls -l /cifs/mattserver, I get a screwed up list (see above).
  • I can't get a share mounted without adding an entry for the servername to /etc/hosts. I don't want to rely on a kludgy entry in /etc/hosts.

What are my options here?

share|improve this question
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.