Linux Networking: Exploring Samba - page 3
The Samba Essentials
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
/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
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/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:
/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 //22.214.171.124/s /mnt/wong1/s smbfs 0 0
/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 //126.96.36.199/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, 188.8.131.52, 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.
- 1Linux Top 3: Alpine Linux 3.4, deepin 15.2 and Linux Lite 3.0
- 2Linux 4.7 Set to Boost Live Patching, Security and Power Management
- 3Linux 4.6 Charred Weasel adds USB 3.1 Support
- 4Linux Top 3: OpenIndiana 2016.04, Ubuntu 16.04 and Debian's New Leader
- 5Linux Top 3: KaOS 2016.04, TurnKey 14.1 and pfSense 2.3