Setting up FreeBSD SMBFS with AutoFS

This short FreeBSD HowTo helps you set up smbfs with autofs.

Are you interested in setting up FreeBSD as Nfsv4 client with Kerberos and AutoFs ?

With autofs (man autofs) you can easily integrate devices or network shares when needed. In contrast to static integration, unmounting is done automatically without access. Automount reads in the /etc/auto_master the mountpoints and its map-file. The map-file contains the mount command. A disadvantage is, that for SMB the mount commands for BSD and Linux are completely not identical. In our scenario we want to mount the smbfs share (SHARE) on our file server (HOST) under the mountpoint “/mnt/smbfsmount/” with autofs.

Requirements:

  • vfs.usermount is set in sysctl.conf
  • mount_smbfs is installed and working
  • autofs _enable = “YES” in rc.conf
  • Windows or Samba that supports SMB Version 1
  • The user’s GID and UID are the same as those of the Samba server

Create or copy a /etc/nsmb.conf. You will find an example in /usr/share/examples/smbfs. Automount ignores ~/.nsmbrc !

Add your SMB file server and user and password.

[HOST:USR] # UPPERCASE !
password=YOURPASSWORD

$ mkdir /mnt/smbfsmount
$ nano /etc/auto_master

#mountpoint       map-file
/mnt/smbfsmount   /etc/smbfs.auto

$ nano /etc/smbfs.auto

Here man mount_smbfs or man auto_master really does not help much, because without the additional parameters the user rights are missing.

#share       mount-command  (upper case only for better readability !)
/HOST/SHARE -fstype=smbfs,-N,-u=USR,-g=GRP,-f=0660,-d=0770,-E=utf8:utf8 ://USR@HOST/SHARE

That’s it ! Restart services, then access to the share should be possible.

$ service automount (re)start

$ service automountd (re)start

$ service autounmountd (re)start

If automount fails, you can use $ automount -v and $ tail /var/log/messages to track down the error.

 

Testing environment: FreeBSD 11,12,12.1 and Samba 3.7,4.2 on Ascii (10/20)

 

Feel free to contact us if you have any comments or improvements.

feinwerk@wassermann.hamburg
www.wassermann.hamburg
www.facebook.com/Feinwerk.Hamburg

 

Feinwerk Hamburg Meeresgott

Feine Mechanik, nachhaltig gefertigt.

Wir beherrschen das.

Feinwerk Hamburg Wortmarke

 

 

Feinwerk Hamburg ist ein Angebot der Wassermann Dental-Maschinen GmbH.
Rudorffweg 15–17, 21031 Hamburg, Germany