How to mount Windows share on Red Hat Enterprise Linux system using CIFS?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 5
  • Red Hat Enterprise Linux 6

Issue

  • How can Windows shares be mounted on Red Hat Enterprise Linux?

Resolution

  • Windows share can be mounted on RHEL system using cifs option of mount command as :
[root@host ~]# mount -t cifs -o username=<share user>,password=<share password> //WIN_PC_IP/<share name> /mnt
  • In case your user is in windows domain then you can define the domain as follows:
[root@host ~]# mount -t cifs -o username=<share user>,password=<share password>,domain=example.com //WIN_PC_IP/<share name> /mnt
  • By default windows share mounted with the full permission (777) in Linux. To change the default permission use the dir_mode and file_mode options to set directory and file permission.
[root@host ~]# mount -t cifs -o username=<share user>,password=<share password>,dir_mode=0755,file_mode=0755 //WIN_PC_IP/<share name> /mnt
  • To make the mount persistant across reboots, make the below entry to the /etc/fstab
 //WIN_PC_IP/<share name>    /<mntpoint>   cifs  _netdev,username=<share user>,password=<share password>,dir_mode=0755,file_mode=0755,uid=500,gid=500 0 0
  • If you receive the following error when try to mount the share folder from windows machines
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

Please verify the permission on the folder on you windows machine and try again mount the share folder.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

8 Comments

You'll need the "cifs-utils" package (not part of the @base) installed to get the mount.cifs command.

Worth noting that, if you're in an Active Directory environment and packet-signing is enforced for CIFS shares (or your CIFS server is a Windows 2008R2 server), you will need to add an appropriate sec= flag to your mount options. In our environment, we got vague permission denied errors (permission denied (errno 13)) until we set our client mount options to one of "sec=ntlmv2i" or "sec=ntlmsspi".

Another peculiarity of using a Windows 2008R2 server (or higher) is that mounting via CNAME may be not possible when using the "sec=ntlmsspi" mount option. It used to be, you could overcome this by setting DisableStrictNameChecking (per Microsoft KB 926642). However that fix no longer seems to reliably work.

As of Sept 2, 2015 connecting to a Windows share with CIFS is not possible if you enable FIPS on your RHEL 6x or 7x system. https://bugzilla.redhat.com/show_bug.cgi?id=1259497

Since /etc/fstab is world-readable, I think it's better to put the credentials in a file (e.g. /root/cifs_creds.txt), then use the "credentials=/root/cifs_creds.txt" mount option.

The credentials file should contain at least two lines "username=user" and "password=secretpass"

I tried "mount -t cifs //example.com/Linux_Support /mnt -o credentials=/root/cifsauth,noserverino,vers=3.0", on RHEL 6 , but it shows error "mount error(112): Host is down". This same command work on rhel7. What could be a possible cause?

On system reboot, networking doesn't start until after file systems are mounted. There is a _netdev option supposedly to add to the fstab entry to fix this.

What does the "0 0" designate at the end of the 4th example?

Those are the standard options for network drives, and mean respectively: don't back up, and don't scan for errors on boot. Wikipedia fstab