Connecting to a Windows file server from a Linux box

Updated 18 Jan 2013


There are two basic prerequisites for mounting a Windows share on a Gentoo Linux client. First, your kernel must be compiled with cifs support. Second, you must emerge the appropriate packages. The package used to be called mount-cifs, but this package is obsolete. You only need to install net-fs/samba, which will pull in net-fs/cifs-utils and a few other dependencies. The Samba page on the Gentoo Wiki is pretty good.
Since you probably need a user name and password to log in to the Windows share, you should create a credentials file. You don’t want to specify your password on the command line because it will be saved in your .bash_history file and unauthorized users may be able to see it. I created a file called /etc/credentials.txt and set permissions so that only root can see it. The format is:


Here is a command line you can use to mount a shared partition on a Windows server:

mount -t cifs //server_name/path_to_share /mnt/mount_point/ -o nosuid,uid=your_username,rw,noexec,credentials=/etc/credentials.txt

Once you get it working, add a line to /etc/fstab so you don’t have to remember that command:

//server_name/path_to_share    /mnt/mount_point    cifs    uid=your_usrname,rw,noexec,credentials=/etc/credentials.txt

By default, the mount.cifs program is not installed suid. Therefore, only root can mount the Windows share. The uid option specifies which user should “own” the files on the Windows share when the sharing server doesn’t provide ownership information. Don’t worry, this does not bypass the Windows permissions on the shared volume!

Red Hat Enterprise Linux 5

For RHEL 5, the only difference is the name of the package that needs to be installed. I installed samba-client and its dependencies. The command-line options and fstab configuration are the same as described above.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.