User Tools

Site Tools


wiki:freebsd:mount_cifs_smb_share

Mount SMB or CIFS Share

This document provides help on mounting SMB/CIFS shares under FreeBSD Operating System.

Temporary or Testing Mount

The mount_smbfs command mounts a share from a remote server using SMB/CIFS protocol. You can easily mount MySharedFolder share using the following syntax:

mount_smbfs -I 192.168.1.1 //myUser@serverName/mySharedFolder /mnt/mySharedFolder

Where:

  • 192.168.1.1 is the IP address of the remote computer.
  • myUser is your user name.
  • serverName is NETBIOS Server Name.
  • mySharedFolder is CIFS share name.
  • /mnt/mySharedFolder is the local mount point directory.

You will be prompted for your password. Once this happens you can change to the directory and view the contents usingcd and ls command:

cd /mnt/mySharedFolder
ls -la

Save Credentials

To avoid password prompt, you have to create a .nsmbrc file in your home directory:

vi ~/.nsmbrc

Set username and password as follows:

[SERVERNAME:MYUSER]
password=myPassword

Note: Both the hostname and the username need to be in uppercase.

Now mount mySharedFolder as follows:

mount_smbfs -N -I 192.168.1.1 //myUser@serverName/mySharedFolder /mnt/mySharedFolder

The -N option forces to read a password from ~/.nsmbrc file. At run time, mount_smbfs reads the ~/.nsmbrc file for additional configuration parameters and a password. If no password is found, mount_smbfs prompts for it. You need to use the -N option while writing a shell script.


Mount on Boot

mount_smbfs does not make the mount permanent. If the FreeBSD system is rebooted, you will have to mount the share again. To make the mount occur each time you start the FreeBSD system, you can put an entry in your /etc/fstabfile. An example file would look like this:

//myUser@serverName/mySharedFolder /mnt/mySharedFolder smbfs rw,-N,-I192.168.1.1 0 0

Next, you have to add the username and password to /etc/nsmb.conf:

[SERVERNAME:MYUSER]
password=myPassword
wiki/freebsd/mount_cifs_smb_share.txt · Last modified: 2016/09/13 15:53 (external edit)