blog.up-link.ro
25Oct/110

FreeBSD: How to mount SMB/CIFS shares under FreeBSD

This document provides help on mounting SMB/CIFS shares under FreeBSD Operating System.
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 using cd and ls command:

cd /mnt/mySharedFolder
ls -la

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_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/fstab file. 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

Print This Post Print This Post
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


*

No trackbacks yet.