Linux Enhanced SMBFS
(CIFS for UNIX for smbfs)
written by John Newbigin

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 systems v2.0

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.

Note on patches

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

OS Release Kernel version Kernel type CIFS Version
CentOS-4 2.6.9-22.0.2.EL i686 0.34a
CentOS-4 2.6.9-34.EL i686 0.34a

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

  • tarball (includes smbpwman and smbmount patches)

smbpwman version 0.6

smbmount version 0.6

CentOS-4 / RHEL4

Step by Step instructions for RedHat 7.2/7.3 & CentOS-2

Client side set up

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

OS Release Kernel version Kernel type Patch Version
RedHat 7.2 2.4.9-31 i686 4
RedHat 7.2 2.4.18-10 i686 4
RedHat 7.2 2.4.18-27.7.x i686 4
RedHat 7.3 2.4.18-4 i686 4
RedHat 7.2 2.4.20-18.7 i686 4
RedHat 7.2 2.4.20-19.7 i686 4
RedHat 7.2 2.4.20-20.7 i686 8
RedHat 9 2.4.20-18.9 i686 5
RedHat 9 2.4.20-19.9 i686 8
RHEL 2.1 2.4.9-e.27 i686 9

# cd /lib/modules/<kernel version>/kernel/fs/smbfs
# mv smbfs.o smbfs.o.orig
# wget<version>.o

Install this rpm.

# rpm -ivh

Install this rpm.

# rpm -ivh

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
# mv system-auth system-auth.orig
# wget
# mv system-auth2 system-auth

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
# /etc/rc.d/init.d/autofs start

Log in as a user and see if it works.

Server side set up

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
$ wget
$ tar -jxf samba-2.2.8a.tar.bz2

Patch samba

$ wget
$ patch -p1 < ../samba.diff6

Build & Install Samba

$ cd samba-2.2.8a/source
$ ./configure \
--prefix=/opt/cifsunix \
--with-privatedir=/opt/cifsunix/private \
--with-lockdir=/opt/cifsunix/locks \

If configure runs successfully then make samba

$ make

If the make is successful then you can install it.  You need to be root to write to /opt

$ su
# make install

Configure Samba.  Edit /opt/cifsunix/lib/smb.conf. You need to have the following samba settings:

unix extensions = yes
map archive = No
delete readonly = Yes
create mask = 0755
case sensitive = yes
mangled names = no

This is my complete smb.conf:

workgroup = MYWORKGROUP
unix extensions = Yes
mangled names = no

server string = Samba Server
hosts allow =

log file = /opt/cifsunix/var/log.%m

max log size = 50
security = user

socket options = TCP_NODELAY

#=== Share Definitions ===
comment = Home Directories
browseable = no
writable = yes
map archive = No
delete readonly = Yes
case sensitive = yes
comment = Oracle Home
path = /home/oracle
browseable = no
writable = no
map archive = No
delete readonly = Yes
guest ok = true
guest account = nobody
case sensitive = yes

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.

Patching SMBFS in the RedHat kernel

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
$ cp -r /usr/src/linux-2.4.18-4/ .
$ cd linux-2.4.18-4

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
$ make oldconfig

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
$ wget
$ cd linux-2.4.18-4
$ patch -p1 < ../smbfs-cifs8.patch

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.

Note about insmod

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

Patching CIFS in the RedHat kernel

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.

$ build_path=/tmp/mykernel
$ mkdir -p $build_path
$ cd $build_path
$ rpm --define _topdir$build_path -i

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
%define buildsmp 0
%define buildsource 0
%define buildhugemem 0
%define buildlargesmp 0
%define builddoc 0
%define kabi 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

Wrote: /tmp/mykernel/RPMS/i686/kernel-2.6.9-34.EL.i686.rpm
+ exit 0

Download the driver from  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/
$ mv linux-2.6.9/fs/cifs linux-2.6.9/fs/cifs.orig
$ tar -zxvf cifs-1.34a-RHEL4.tar.gz
$ mv cifs-1.34a-RHEL4/fs/cifs fs/
$ make modules

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
# insmod fs/cifs/cifs.ko

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.

Other Resources

There is a lot of information about the things you can do with samba and related tools and protocols.  Some handy web sites are:


Last modified 20060324.
Maintained by John Newbigin