Adding a Share to fstab

Since fstab is readable by all users, we don't want to put our Samba password in this file. In this case we can use a credentials file that is only readable by you. This is a simple text file that contains:

username=<username>
password=<password>

The user option of the fstab line allows the owner of the <mount_point> to mount and unmount the share. The noauto option disables mounting at boot.

If you are adding a Samba share to fstab, you should also add the netfs daemon to rc.conf, somewhere after the network daemon. The netfs daemon will mount network partitions at boot and, more importantly, unmount network partitions at shutdown. Even if you are using the noauto option in fstab you should add the netfs daemon. Without it any network share that is mounted when you shutdown will cause the network daemon to wait for the connection to time out, consideribly extending your shutdown time.

Share files for your LAN without user and password

Edit default /etc/samba/smb.conf on the following lines:

security = user

to

security = share

If you want to restrict the shares data to a specific interface replace

; interfaces = 192.168.12.2/24 192.168.13.2/24

to (replace eth0 to local network you want share to)

interfaces = lo eth0
bind interfaces only = true

if you want to edit the account that access the shares, edit the following line:

; guest account = nobody

The last step is to create share directory (for write access make writable = yes):