Linux Networking: Exploring Samba
Accessing Files Using Samba smbfs

William Wong
Monday, July 10, 2000 08:36:03 AM
The smbfs daemon is used to map remote disk shares on Samba- or
Windows-based servers to a local directory. This operates in the same fashion
as mapping a local device like a CD-ROM to a local directory. Typically, the
/mnt directory is where mapped directories are placed although
they can actually be setup anywhere in the Linux directory tree. A good
convention to follow for smbfs mapped directories is to create a directory in
the /mnt directory that matches the server name. Directories can
then be created that match the share names so a shared disk named
//wong1/public would map to /mnt/wong1/public.
Shares can be mounted, or mapped in Windows-speak, and unmounted at any
time. There are two files that keep track of these operations:
/etc/mtab and /etc/fstab. The mtab file contains a
list of mounted devices and it is maintained by Linux. The fstab indicates how
a device should be mounted. The following are examples of the files:
mtab
/dev/sda3 / ext2 rw 0 0
none /proc proc rw 0 0
none /dev/pts devpts rw,gid=5,mode=620 0 0
//wong1/u /mnt/wong1/u smbfs 0 0
//wong1/t /mnt/wong1/t smbfs 0 0
//123.123.123.8/s /mnt/wong1/s smbfs 0 0
fstab
/dev/sda3 / ext2 defaults 1 1
/dev/cdrom /mnt/cdrom iso9660 noauto,owner,ro 0 0
/dev/fd0 /mnt/floppy ext2 noauto,owner 0 0
none /proc proc defaults 0 0
none /dev/pts devpts gid=5,mode=620 0 0
/dev/sda2 swap swap defaults 0 0
//wong1/u /mnt/wong1/u smb username=admin,password=pass 0 0
//wong1/t /mnt/wong1/t smb username=admin,password=pass 0 0
//123.123.123.8/s /mnt/wong1/s smb username=admin,password=pass 0 0
Normally the fstab file will be configured by the user. Each line contains
six items. The first is the device description, the second is the directory
where the device will be mounted, the third is the file system type. The fourth
is the list of parameters given to the file system daemon. The last two are
normally 0 for all but the main disk partition.
Note, in the prior examples, the server's domain name, wong1, and the
server's IP address, 123.123.123.8, are used to refer to the same computer.
Typically only one of these will be used.
One drawback of using fstab is that user names and passwords must be
included. The alternative is to have users use the smbmount command or one of
the browser programs. There are many browser programs. Two graphical ones are
KWMount by Gazer Zoser for
KDE and gnomba by Chris Rogers for
Gnome.
The following is a sample of the smbmount program:
smbmount //wong1/u /mnt/wong1/u -o username=admin,password=pass
The arguments are very similar to the contents of the fstab file. The
password can be omitted from the command line, in which case the program prompts
for a password if needed. The smbmount program accepts a number of other
parameters that the online help describes.
Next: File Transfers Using smbclient »