This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

NFS like SAMBA setup for WinNT/cygwin mini-HOWTO

I come from a UNIX background and am used to having NFS
mounts all over the place. I recently setup our NT system
running cygwin so that it almost acts like our Unix system
in regard to accessing network mounted disks. I am posting
a description of how to do this, since it was not easy and
perhaps others would like this setup. I do not profess to be
an expert on any of this stuff. There may be much easier ways
to do this, but I do not know of them. Your mileage may vary.

1. Goals

I wanted to set things up so multiple user's could simultaneously
use the same machine using telnet and console logins. Each user
has a home directory which needed to be network mounted to
the NT machine. I wanted to make sure that the ownership/permissions
of the home directories was respected. I also had a number
of shared network mounts (/usr/local) that were needed. The network
disks are on Unix machines (IRIX and linux). I have Samba setup on
the Unix machines.

2. Samba setup

The first thing to do is make sure the samba setup is right on the
serving machines. I recommend getting the latest samba version because
there have been quite a few bug fixes lately. I happen to have
my "shared" mounts on one machine and the home directories on other
machines. I setup the shared mount machine with samba "security" set
to "share". I setup the home machines with "security" set to "user".
I understand there is a way to make one machine do both security modes,
but have not tried that. It is important that the home directories have
a "user" security setting or you will have ownership problems with files.
Presumbaly you could have the shared mounts use "user" security mode as
well if you wanted to.

Here is a brief description of the two modes (as best as I understand it):

user mode - on the NT machine, the user who mounts it (using "net use")
is the only one who can access the share. In fact it seems that only
the session that issued the "net use" command can access it (if you
have two telnet sessions, you need to have a "net use" in each to access it).
Files that get created on the share use the user's permissions and ownership.

share mode - on the NT machine, the user who mounts it (using "net use")
is used for all permission/ownership issues. However, any user can access
the share. This is very bad for home directories if more than one user
can be logged in.

3. NT machine setup

I have set things up so that when a user logs in, scripts are run
to mount all the necessary remote volumes. This works both for telnet
and console logins. You must make sure your cygwin environment is
in good shape before staring (you a mount entry for "/", you have
the right environment setting in your registry for PATH, CYGWIN,
and HOME, and /etc/passwd and telnet are setup).

First put the attached file "" into /etc. Then create the
files "/etc/profile" and "/etc/csh.login" and put this line in both
of them (or simply insert it if you already have those files):

/etc/ $USER; cd .

This causes login tcsh and bash (or sh) to run the script that mounts
drives. The script uses a fstab like setup to control what
is done by the mount script. Create a /etc/fstab for your config.
Here is an example /etc/fstab:

# format is:
#  sharepath mount-dir user
# user is either a user name or "-share"
# lines beginning with #<space> are comments
\\host1\derek   /home/derek     derek
\\host2\lenny  /home/lenny	lenny
\\shareserv\export\cygwin   /usr/local      -share
\\shareserv\export\share    /usr/local/share        -share

The first field is the network path that is used to connect
to the samba server. The script will issue the
command "net use \\xxx\yyy" where xxx is the hostname and yyy
is the first element after the hostname to mount the share.
It will then issue a cygwin "mount" command for the whole network
path onto the mount-dir. The third field controls whether it is
a shared mount or a private mount. If the username matches this field,
the volume is mounted. If it is "-share", it is mounted for all users.
Note that the private mounts require a password; the script prompts
for this password (in non-echo mode). 

You then need to setup a script file for console login. Put the following
script into "%SystemDrive%/winnt/system32/Repl/Import/Scripts/login.bat":

SET PATH=%SystemDrive%\root\bin;%SystemDrive%\root\cygnus\CYGWIN~1\H-I586~1\bin
%SystemDrive%\root\bin\bash.exe /etc/ %USERNAME% /home/%USERNAME% > 

Then, for each user, using the user manager program and the "profile" screen
of the user properties, set the login script to be "login.bat". Then, each
user needs to login and map as a network drive (it does not matter what
drive letter) their home directory (and make sure it has "reconnect on
login" set).

4. Testing

If by some miracle NT has worked well for you well doing all this,
things should now be working. When you login on the console, NT should
mount your network drive as a drive letter first and then the nt-mount
script will be run (you may see a MSDOS window popup briefly) and do
the other mounts.

When you telnet in, it should prompt you for a password to connect
to you home directory and mount everything. Note that if you then
start xterms from that telnet session you can avoid typing in your
password everytime (assuming you are telnetting from an X windows

Want to unsubscribe from this list?
Send a message to

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]