Despite the advanced networking capabilities of Linux, the only network filesystem which is available seems to be NFS. There are others but they are either still in development, not free or not featured enough to act as a replacement for NFS... unitl now.
Enter SMBFS. SMBFS allows Linux to mount a remote SMB share but until now it did not act like a UNIX file system, even if the remote host was Samba running on a UNIX or Linux machine. This page is the home of the CIFS for UNIX implementation for SMBFS. Along with the server side Samba implementation, directories can now be mounted across the network using SMB.
To make SMB useful for home directories, a few tools are required to manage passwords and the mount procedure. These are also available on this page.
CIFS Extensions for UNIX is a small set of additions to the SMB protocol which allows the transfer of UNIX style metadata. The specification can be found here.
Samba 3, Linux 2.4.25 and Linux 2.6 now support these extensions without any extra patches.
Most new distributions have updated smaba and kernel code so the UNIX extensions will work out of the box. You can still use some of my software from this page to get auto mounting of home directories working.
CIFS VFS is a new implementation of SMBFS which aims to solve many of the problems which SMBFS has. It uses a different mount program but works in a simalar way. Many kernels come with CIFS included, but at this stage they all seem to be hopelessly broken.
I have build working modules for the following CentOS-4 kernels
If you want to build your own see the instructions further down this page.
The upside of this is that many changes which needed to be made to samba have been accepted so you no longer need to patch samba.
My Latest patch is against 2.4.20. This patch fixes a problem with newly created symlinks and cleans up some memory management. Using this patch I can start X with my home directory mounted off another machine (Under RedHat 7.2).
Older patches:. These are a bit out of date but should be usable for most purposes:
I have a patch for older RedHat 7.2 kernels at the bottom of this page.
The patch for smaba has gone into CVS so all you need is the CVS source from after 20 May 2002. There is another patch to disable ensure_link_is_safe which has not yet been accepted but this patch is optional.
You can still use older source such as 2.2.3a or 2.2.4 and my patch.
Any distro which comes with Samba 3 should be ready to use without any patching.
The problem with using automount is that Samba requires a username and password to mount a share. The username is not a problem but the password can be problematic. The solution I devised is a small daemon which collects passwords on login. A new PAM module takes the supplied password which has been verified by another PAM module and tells the smbpw daemon.
When an attempt is made to mount a home directory, automount first executes a small program called smbautomount which looks up the user details and builds an automount map string. Based on this string, automount then invokes mount which in turn invokes mount.smb. It connects to the smbpw daemon and asks for the users password. In this way, the automount can occur without any user interference.
This is all completed and working. Read INSTALL for installation instructions. You also need a patch for smbmount. smbmount.diff (included in the above file). You will have to play with your Makefile to compile it. In the latest .rpms 0.6-1, the directory can be mounted anywhere, not just as a home directory. This allows you to have a local home directory and still connect to a remote home directory. I have also renamed smbfs to cifs so it does not conflict with the samba-client package
smbpwman & smbmount 0.6
smbpwman version 0.6
smbmount version 0.6
Step by Step instructions for RedHat 7.2/7.3 & CentOS-2
These instructions are suitable for the following systems:RedHat 7.2 and RedHat 7.3 running on ix86 hardware running one of the the i686 up kernels listed in the table below
If you are running a kernel which is not listed in the table below then you will have to build the smbfs module your self. Instructions for building the module are at the bottom of this page. This is the recommended way because there is no guarantee of these binary modules working on your kernel.
Download the binary module for which matched your kernel and replace your existing smbfs with this one. You can check your current kernel version with the uname command
$ uname -a
# cd /lib/modules/<kernel
Install this rpm.
# rpm -ivh http://uranus.it.swin.edu.au/~jn/linux/smbfs/smbpwman-0.6-1.i386.rpm
Install this rpm.
# rpm -ivh http://uranus.it.swin.edu.au/~jn/linux/smbfs/smbmount-0.6-1.i386.rpm
Run authconfig and set up SMB authentication to work with your Samba server. This will make sure that you have the pam_smb module installed and will configure it.
Download this file or this file and save it as /etc/pam.d/system-auth. Your pam config obviously needs to be setup to meet your sites needs. My original pam config would use a local unix password if there was one but then it would not store it in the password daemon. The newer (second) file will authenticate with either and still store the password). If you use ldap or NIS or anything else then you will have to work out this step on your own.
# cd /etc/pam.d
At this point you should make sure you can log in as a user. The user must have a local account but it is probably best if they are authenticated against the same samba server which will be sharing the home directories.
Assuming home directories are stored under /home, edit /etc/auto.master and add the following line "/home /usr/sbin/smbautomount --timeout 60"
# echo "/home /usr/sbin/smbautomount --timeout 60" >> /etc/auto.master
Add the following line to /etc/smbautomount.conf "/home:myservername"
# echo "/home:myservername:case," >> /etc/smbautomount.conf
Start or restart automount
# /etc/rc.d/init.d/autofs stop
Log in as a user and see if it works.
These instructions will help you build samba and install it into /opt/cifsunix. This method does not interfere with any currently running samba installation so you can test it without breaking any existing samba set up. Unless you are already running Samba 2.2.8a I think this is the best way to test it.
Get Samba. Download samba-2.2.8a.tar.bz2 from your nearest mirror
$ cd /tmp
$ tar -jxf samba-2.2.8a.tar.bz2
$ wget http://uranus.it.swin.edu.au/~jn/linux/smbfs/samba.diff6
Build & Install Samba
$ cd samba-2.2.8a/source
If configure runs successfully then make samba
If the make is successful then you can install it. You need to be root to write to /opt
Configure Samba. Edit /opt/cifsunix/lib/smb.conf. You need to have the following samba settings:
unix extensions = yes
This is my complete smb.conf:
server string = Samba Server
You will need to adjust security options to suit your current configuration.
Start Samba. I use port 1139 so I can run alongside the existing samba installation. If you do this then remember to configure the client to connect to port 1139 (/etc/smbautomount.conf). The command to start the daemon is
# /opt/cifsunix/sbin/smbd -p 1139 -D
There is no need to run nmbd.
This is best done as a user and not as root. Start by making a copy of the RedHat linux source (you must have the appropriate kernel-source RPM installed)
$ cd /tmp
Edit the main Makefile and change the version to match exactly your target kernel. (Remove 'custom' from the extraversion). The version might already match, I think this is only a new change RedHat have started making. The run make mrproper to make sure the source is ready for use.
$ make mrproper
Then select the appropriate configuration file. The information about what kernel you are running can be found in /boot/kernel.h. Copy the appropriate file into the kernel source tree root as a file called .config and for peace of mind, run make oldconfig.
$ cp configs/kernel-2.4.18-i686.config .config
Do a test build.
$ make dep bzImage modules
If this works then you can start making your changes to the kernel. In this case we want to apply the smbfs patch. RedHat 7.3 users should use my 2.4.19-pre7 patch. RedHat 7.2 users should use my special RH72 patch. RedHat Enterprise Linux 2.1 use this patch.
$ cd /tmp
The patch should apply without any errors. Once applied you can build the new module
$ make modules
Depending on the patch you might need to do a more complete rebuild but this might break compatibility with your currently running kernel.
If you have problems loading the kernel module then you might need to use the -f parameter to make insmod load it. I am note sure what combination of circumstances is required to trigger this but I think mainly it is modutils-2.4.18-3.7x. Older versions seemed happy with the modules where as the new one complains. You can edit your /etc/modules.conf to do a forced load on demand (is that an oxymoron?). Add the following line
install smbfs /sbin/insmod -f smbfs
This should be done as a normal user and not as root. You will need the src.rpm for your kernel. This will be something like kernel-2.6.9-22.0.2.EL.src.rpm or kernel-2.6.9-34.EL.src.rpm. You can download it first or you can just install it off the web.
Edit SPECS/kernel-2.6.spec and change the following lines at the start of the spec file so it only builds the type of kernel that you use (UP, SMP etc). I want UP so I have this:
%define buildup 1
Now build the kernel like this (change the target as required):
$ rpmbuild --define _topdir$build_path -bb --target=i686 SPECS/kernel-2.6.spec
This will take some time... If it completes successfuly it will result in
Download the driver from http://pserver.samba.org/samba/ftp/cifs-cvs/. Which version??? I think I used cifs-1.34a-RHEL4.tar.gz. Version 1.40 is broken in the RH kernel, but this one seems to work cifs-1.40a-forFC3orRHEL4orSuSEWrk9.tar.gz. You might have to adjust the directories because every version of CIFS has a different arrangement.
$ cd $build_path/BUILD/kernel-2.6.9/
If you have no errors, you will end up with a file called fs/cifs/cifs.ko and that is the module. Check that you don't have cifs loaded already and then try loading your new module
# rmmod cifs
If it loads then you are ready to go. It is not best practice but if you want you can just copy the file on top of the system version.
There is a lot of information about the things you can do with samba and related tools and protocols. Some handy web sites are: