smbfs
leŭksman
Note: The software or advice on this page is very old, and may apply only to outdated versions.
Contents |
mount.smbfs
mount.smbfs is a Perl script that translates mount(8) style option into options for smbmount(8) as in the smbfs package and then runs smbmount. In conjunction with a small patch to mount(8) this script can be used to mount SMB shares on Linux via the normal mounting methods.
Users of Linux kernels 2.1.70+ can use Michael Warfield's script to translate the smbfs-style smbmount options to the new samba-style smbmount options. See his page at http://www.wittsend.com/mhw/smbmount.html.
mount.smbfs is copyright (c) 1998 by Brion Vibber (brion@pobox.com). There is no warranty! Use it at your own risk! The license is GPL 2.0 - see http://www.fsf.org/copyleft/
Version history
Version 1.0 - 5 August 1998
Download & Installation
- You can download version 1.0 of mount.smbfs at http://pobox.com/~brion/linux/mountsmbfs-1.0.tar.gz. You'll also want mount 2.8a, which you can get at ftp://ftp.win.tue.nl/pub/linux/util/mount/mount-2.8a.tar.gz.
- Find a nice directory and extract the archives:
% cd /some/dir % tar zxvf /download/dir/mountsmbfs-1.0.tar.gz ... % tar zxvf /download/dir/mount-2.8a.tar.gz ... % cd mountsmbfs-1.0
- Edit mount.smbfs in your favorite text editor to make sure that the $smbmount variable points to the actual location of your smbmount program. If you're not sure where it is, run ``which smbmount.
- Copy mount.smbfs to /sbin:
% cp mount.smbfs /sbin
- Apply the patch to mount and compile it:
% cd ../mount-2.8a % patch -p1 < ../mountsmbfs-1.0/mount-2.8a-smbfixes.patch ... % make ...
- Back up your old mount program just in case and install the new one:
% mv `which mount` mount.old % make install ... % hash -r
- Try it out!
% mount //some_server/some_share /some/directory -o nopwd
Usage
You should be able to mount SMB shares in any of the following fashions:
- mount -t smbfs //server/share /mountpoint
- mount //server/share /mountpoint
- mount //server/share (if in /etc/fstab)
- mount /mountpoint (if in /etc/fstab)
Note that if you for some reason are unable to patch mount, you may still be able to use an older version if you rename mount.smbfs to mount.smb and specify the filesystem type as ``smb with the -t option or in /etc/fstab.
Options
The following options (-o option=value,option=value,...) are based on the DOS FAT filesystem options:
- uid=###: sets user ID of the owner of the files on the filesystem. Maps to smbmount's -u option.
- gid=###: sets group ID of the owner of the files on the filesystem. Maps to smbmount's -g option.
- umask=###: sets the file permissions for the files on the filesystem. Maps to smbmount's -f and -d options; I may have it screwed up though. Somebody please check!
These options I made up to give readable names to smbmount's unique
options.
- username=...: the user name to use to login. Maps to smbmount's -U option.
- domain=...: the domain name to use to login. Maps to smbmount's -D option.
- max=###: the maximum packet size that should be used to communicate with the server. Maps to smbmount's -m option.
- port=###: the TCP port to use; default is 139. Maps to smbmount's -p option.
- ip=###.###.###.###: the IP address of the server. Maps to smbmount's -I option.
- server=...: the netbios name of the server. Maps to smbmount's -s option.
- nopwd: don't prompt for a password. Maps to smbmount's -n option.
- lcasepwd: don't convert the password to all caps before sending to the server. Maps to smbmount's -C option.
How it works
mount can use helper programs called mount.filesystemtype to help it out with filesystems it doesn't know. By default it only does this for types ``smb (LAN Manager / Windows) and ``ncp (Netware). However, the rest of the world (the kernel and the SMB mounting utilities) know the SMB filesystem as ``smbfs, and mount doesn't recognize SMB service names of the form //server/service, so you need to specify the wrong name for the filesystem type in order to get mount to touch SMB.
That's where the patch to mount comes in. It adds ``smbfs to the list of helpers to check for, so we can use the right name for the filesystem type and it will find and run mount.smbfs. The patch also adds a check for the distinctive double slash and automatically sets the filesystem type to smbfs, so you don't need to explicitly set it on the command line. There is also an addition to the logic for assigning mounts to child processes when doing a forked mount all, but that doesn't seem to work right at the moment.
The mount.smbfs program is called by mount, and translates the options and calls smbmount which performs the actual mounting of the filesystem.
Successes so far!
mount.smbfs and the patch to mount have been tested on two different machines successfully:
- Red Hat Linux 5.1
kernel 2.1.113 - i686 SMP kernel on a UP machine
glibc 2.0.7
smbmount 1.9.18p7 (samba - using Michael Warfield's script)
- Slackware 3.4
kernel 2.0.34 - i586
libc 5.4.33
smbmount 2.0.2 (smbfs)
Problems
- Mounting all SMB filesystems at once with "mount -a -t smbfs" doesn't work, I'm not quite sure why. On my 2.1/glibc2 box it seems to ignore the filesystems that _aren't_ mounted and complains about the ones that are (if the -v option is set). It's not calling mount.smbfs so it seems to be a problem in mount itself. On my 2.0/libc5 box it mounts, but it doesn't add them to /etc/mtab, the device is set to <NULL> in /proc/mounts, and I get "device or resource busy" errors as it's working. This sounds more like bad interaction between smbmount and mount, whereas mount itself seems okay here. Very strange...
- Shares with passwords can be dicey, since smbmount will try to ask you for a password which doesn't always work. Try specifying the nopwd option (i.e., mount //foo/bar /mnt/foople -o nopwd) to suppress the asking for shares without passwords. I'm reluctant to have an option for specifying the password because command lines have a way of being visible (in ps for example) and so it's horribly insecure.
-
The Samba version of smbmount likes to capitalize the service name. You can use
any case to mount, but remember to use all caps when you unmount if you specify
by service name. Example:
% mount //frank/pub /mnt/foo % mount ... //FRANK/PUB on /mnt/foo type smbfs (0) % umount //frank/pub umount: //frank/pub is not mounted (according to mtab) % umount //FRANK/PUB %
- If you specify //foo as the device it will get detected as a SMB filesystem, but won't mount because you need to specify a service (//server/service) to mount.
- If Perl or smbmount are installed in a filesystem that is not available at the time mount is run, attempts to mount SMB shares will fail, however other filesystem types should not be affected.

