Mounting Shares with mount

A fast and easy way to test whether your server is providing the services you were expecting it to is to use the mount command. All you need to do is specify the smbfs file system type and the options that are required to authenticate against the Samba share. You can use the following command, for example, to test the access to a local share with the name share by connecting it to the mnt directory temporarily:

mount -t smbfs -o username=someone //localhost/share /mnt

Note that the only option that's really required is the option username. This option is necessary to tell the Samba server what user you want to authenticate. You can enter a password, but it is not a good idea to provide that at the command line since it will be stored in your local history file, which contains a history of all commands you have entered. As an alternative to the mount command followed by the -t smbfs option, you can use the smbmount command. Basically, this command offers the same options; check its man page for more details.

Like with remote NFS file systems, you can mount Samba file systems automatically as well from /etc/fstab. You should be aware of one issue: to mount the Samba share automatically, you need to enter a password. Possibly you don't want this password to be stored in the /etc/fstab file, but it is world readable. The alternative is to put the password in the smbfstab file; this file is readable by root only and therefore offers better security. Note that the syntax of the lines you need to add to this file is a little bit different from the fstab syntax:

//lax/data /media/samba/lax smbfs username=sander,password=secret

In this example, the first line refers to the service that must be activated. In this case, it is a share with the name data offered by server lax. Next, the line refers to the local mount point. Then the file system type smbfs indicates that this mount should use smbfs. Finally, all required options are mentioned, in this case just the username and password. Since this line uses a server name instead of an IP address, make sure that Samba name resolving is configured as well. Do this by adding the nmb start-up script to your default runlevel with the command insserv nmb.

Was this article helpful?

0 0

Post a comment