Scientific software development, stage lighting, and stuff

Connecting to a Windows file server from a Linux box

January 23rd, 2008 Posted in Linux

I was surprised how hard it was to find out how to mount a Windows file server as a drive on a Linux box. Fortunately, once I found out how, it was really pretty easy. First of all, you DO NOT need Samba. Most of the information I found on the web involved installing Samba and using your Linux box as a file server for Windows machines. If you want the Linux machine to be a client to a Windows server, Samba is not required. You need to enable support for the cifs filesystem in your kernel–in fact, it’s probably already compiled in (cifs is just a “rebranding” of smb). Then install the mount-cifs utility and you’re ready to go. Here is a command line you can use to mount a shared partition on a Windows server:
mount -t cifs //xx.xx.xx.xx/sharename /mnt/server -v -o user=myusername,prefixpath="myhomedirectory",noperm

It will prompt you for your password.  You might need to tweak the options–for example, the noperm option prevents Linux from trying to map Windows permissions to Linux permissions. This is necessary on my network to enable Linux to copy nested directories to the Windows share. Once you get it working, it can be added to fstab like any other file system.
//xx.xx.xx.xx/sharename /mnt/server cifs user,credentials=/etc/cifs_credentials,noperm 0 0

The cifs_credentials file can have any file name, in any location you choose, with the format described in the man page for mount.cifs.   Since this file will contain your network login and password, make sure it can be read only by root or the user who owns those credentials.

For reference: mount-cifs thread on the Ubuntu forums

You must be logged in to post a comment.