Unable to mount share (SMB + autofs)

Hi,

Im trying to mount my smb shares using autofs but its not working.
Im able to mount the share from my windows machine using the same creds.

osmc@osmc:~$ sudo automount -f -v -d
Starting automounter version 5.1.7, master map /etc/auto.master
using kernel protocol version 5.05
lookup_nss_read_master: reading master file /etc/auto.master
do_init: parse(sun): init gathered global options: (null)
lookup_read_master: lookup(file): read entry +dir:/etc/auto.master.d
lookup_nss_read_master: reading master dir /etc/auto.master.d
lookup_read_master: lookup(dir): scandir: /etc/auto.master.d
lookup_read_master: lookup(file): read entry +auto.master
lookup_nss_read_master: reading master files auto.master
do_init: parse(sun): init gathered global options: (null)
lookup_read_master: lookup(file): read entry /-
master_do_mount: mounting /-
automount_path_to_fifo: fifo name /var/run/autofs.fifo--
lookup_nss_read_map: reading map file /etc/auto.smb.shares
do_init: parse(sun): init gathered global options: (null)
mounted direct on /mnt/nas2/Serier with timeout 45, freq 12 seconds
do_mount_autofs_direct: mounted trigger /mnt/nas2/Serier
mounted direct on /mnt/nas2/Filmer with timeout 45, freq 12 seconds
do_mount_autofs_direct: mounted trigger /mnt/nas2/Filmer
st_ready: st_ready(): state = 0 path /-
handle_packet: type = 5
handle_packet_missing_direct: token 7, name /mnt/nas2/Filmer, request pid 17319
attempting to mount entry /mnt/nas2/Filmer
lookup_mount: lookup(file): looking up /mnt/nas2/Filmer
lookup_mount: lookup(file): /mnt/nas2/Filmer -> -fstype=cifs,rw,credentials=/home/osmc/.smbcredentials,iocharset=utf8,uid=osmc,gid=osmc,vers=3.0 ://192.168.1.54/Filmer
parse_mount: parse(sun): expanded entry: -fstype=cifs,rw,credentials=/home/osmc/.smbcredentials,iocharset=utf8,uid=osmc,gid=osmc,vers=3.0 ://192.168.1.54/Filmer
parse_mount: parse(sun): gathered options: fstype=cifs,rw,credentials=/home/osmc/.smbcredentials,iocharset=utf8,uid=osmc,gid=osmc,vers=3.0
parse_mount: parse(sun): dequote("://192.168.1.54/Filmer") -> ://192.168.1.54/Filmer
parse_mount: parse(sun): core of entry: options=fstype=cifs,rw,credentials=/home/osmc/.smbcredentials,iocharset=utf8,uid=osmc,gid=osmc,vers=3.0, loc=://192.168.1.54/Filmer
sun_mount: parse(sun): mounting root /mnt/nas2/Filmer, mountpoint /mnt/nas2/Filmer, what //192.168.1.54/Filmer, fstype cifs, options rw,credentials=/home/osmc/.smbcredentials,iocharset=utf8,uid=osmc,gid=osmc,vers=3.0
do_mount: //192.168.1.54/Filmer /mnt/nas2/Filmer type cifs options rw,credentials=/home/osmc/.smbcredentials,iocharset=utf8,uid=osmc,gid=osmc,vers=3.0 using module generic
mount_mount: mount(generic): calling mkdir_path /mnt/nas2/Filmer
mount(generic): calling mount -t cifs -o rw,credentials=/home/osmc/.smbcredentials,iocharset=utf8,uid=osmc,gid=osmc,vers=3.0 //192.168.1.54/Filmer /mnt/nas2/Filmer
>> mount error(13): Permission denied
>> Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)
mount(generic): failed to mount //192.168.1.54/Filmer (type cifs) on /mnt/nas2/Filmer
dev_ioctl_send_fail: token = 7
failed to mount /mnt/nas2/Filmer

osmc@osmc:~$ ls -lah /mnt/nas2/Filmer/
ls: cannot access '/mnt/nas2/Filmer/': No such file or directory

# Sample auto.master file
# This is a 'master' automounter map and it has the following format:
# mount-point [map-type[,format]:]map [options]
# For details of the format look at auto.master(5).
#
#/misc  /etc/auto.misc
#
# NOTE: mounts done from a hosts map will be mounted with the
#       "nosuid" and "nodev" options unless the "suid" and "dev"
#       options are explicitly given.
#
#/net   -hosts
#
# Include /etc/auto.master.d/*.autofs
# To add an extra map using this mechanism you will need to add
# two configuration items - one /etc/auto.master.d/extra.autofs file
# (using the same line format as the auto.master file)
# and a separate mount map (e.g. /etc/auto.extra or an auto.extra NIS map)
# that is referred to by the extra.autofs file.
#
+dir:/etc/auto.master.d
#
# If you have fedfs set up and the related binaries, either
# built as part of autofs or installed from another package,
# uncomment this line to use the fedfs program map to access
# your fedfs mounts.
#/nfs4  /usr/sbin/fedfs-map-nfs4 nobind
#
# Include central master map if it can be found using
# nsswitch sources.
#
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
#
+auto.master
/- /etc/auto.smb.shares --timeout 45 browse

/mnt/nas2/Filmer -fstype=cifs,rw,credentials=/home/osmc/.smbcredentials,iocharset=utf8,uid=osmc,gid=osmc,vers=3.0 :>
/mnt/nas2/Serier -fstype=cifs,rw,credentials=/home/osmc/.smbcredentials,iocharset=utf8,uid=osmc,gid=osmc,vers=3.0 :>


So, the content of this file is from interest, then. Are there any special characters used like blanks, etc.?

Are you sure the .smbcredentials file is a UNIX(LF) UTF-8 text file and not a Windows (CR LF) UTF-8 text file ? i.e. create it using the nano editor.

Spaces in the username of the .smbcredentials file don’t work. They cannot even be forced by preceeding the space with the escape ‘\’ character (however this is possible when using them in the mount specification to autofs. )

Are you sure this is correct? I haven’t tried one with autofs but I have one I use with fstab and my username most definitely has a space in it and I’ve been using it for a long time without issue. Although you use an escape character when entering directly in fstab, in a credentials file that you point to from fstab you just put in the space with no accommodation. My file just looks like this…

username=First Last
password=password

This certainly was the case back in Aug 2021 as I posted here - Mounting network shares with autofs (alternative to fstab) - #91 by thechrisgregory

This could have changed by now. See the rest of this FAQ - Mounting network shares with autofs (alternative to fstab)

Chris

I’m not sure what to tell you. I’ve been using a credentials file with a space in the username since December of 2020 (Windows 10 share). I just setup autofs and it is working there as well. The following machine had no system mounts prior to what I just configured…

osmc@Cave:~$ ls -lah /mnt/Video
total 1.3M
drwxr-xr-x 2 osmc osmc 256K Apr  8 15:36  .
drwxr-xr-x 3 root root 4.0K Apr 15 15:38  ..
drwxr-xr-x 2 osmc osmc    0 Apr 10 18:49  Misc
drwxr-xr-x 2 osmc osmc    0 Apr  1 13:52  Movie
drwxr-xr-x 2 osmc osmc    0 Apr 15 12:58 'Movie 2'
drwxr-xr-x 2 osmc osmc    0 Mar 28 19:58 'Movie 4k'
drwxr-xr-x 2 osmc osmc    0 Apr  7 21:41  MoviesetArtwork
drwxr-xr-x 2 osmc osmc    0 Jan 14  2022 'Music Video'
drwxr-xr-x 2 osmc osmc    0 Apr 15 13:28 'TV 2'
drwxr-xr-x 2 osmc osmc    0 Jan  7 12:21 'TV 4k'
drwxr-xr-x 2 osmc osmc    0 Apr  7 21:26 'TV show'
osmc@Cave:~$ cat /etc/auto.smb.shares
/mnt/Video -fstype=cifs,rw,credentials=/home/osmc/.credentials,iocharset=utf8,uid=osmc,gid=osmc,vers=3.0 ://192.168.254.201/Video
osmc@Cave:~$ cat .credentials
username=First Last
password=notmyrealone
osmc@Cave:~$ ls -la .credentials
-rwxr--r-- 1 osmc osmc 40 Dec 31  2020 .credentials
osmc@Cave:~$

Thats how I remember it, after doing some tests, I can’t be sure though, as to whether the SMB version has changed sice then.

Sure enough though, I just did another test with the following .smbcredentials, and this worked OK.

user=Chris Gregory
password=notmypassword

Where ‘Chris Gregory’ is a windows username, which equates to my Microsoft account with the name/email address - ‘gregory.chris@hotmail.com’.

Previously I resorted to using ‘gregory.chris@hotmail.com’ rather than ‘Chris Gregory’ as the username for SMB/windows authentication. Now of course either will work.

1 Like

Thanks for testing, will update the HowTo that it might be not needed anymore.

2 Likes

Hi guys @fzinken @thechrisgregory @darwindesign @JimKnopf thank you for your repons!
When I did the setup I followed this guide Mounting network shares with autofs (alternative to fstab)
I suspect that it was a linebreak at the end of the .smbcredentials file that was causing this.

PS. And I have to use smb1 even if my NAS supports 2 and 3.

I am using SMB V3 with a Windows 10 PC.
SMB V3 is preferable from a security perspective.