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

Solution Verified – Updated

Environment

  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 5

Issue

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

Resolution

  • To run the following commands, you need to install cifs-utils package which provides mount.cifs helper program. Some commands for mounting CIFS volume require the helper program to pre-process options before issuing a mount() syscall.
  • Windows share can be mounted on RHEL system using cifs option of mount command as :

    # mount -t cifs -o username=<share user>,password= //WIN_PC_IP/ /mnt

    You can specify iocharset to convert local path names to/from UTF-8 if the server uses multi byte charset:

    # mount -t cifs -o iocharset=cp932,username=<share user>,password= //WIN_PC_IP/ /mnt

    In case your user is in windows domain then you can define the domain as follows:

    # mount -t cifs -o username=<share user>,password=,domain=example.com //WIN_PC_IP/ /mnt

    By default, Windows shares are mounted with the full permission (0755) in Linux. To change the default permission use the dir_mode and file_mode options to set directory and file permission.

    # mount -t cifs -o username=<share user>,password=,dir_mode=0755,file_mode=0755 //WIN_PC_IP/ /mnt

    To make the mount persistent across reboots, make the below entry to the /etc/fstab

    //WIN_PC_IP/<share name> / cifs _netdev,username=,password=,dir_mode=0755,file_mode=0755,uid=500,gid=500 0 0

    If a username/password/domain is needed, it is best not to leave it in fstab. In order to achieve this, the previous entry can be modified like so:

    //WIN_PC_IP/<share name> / cifs _netdev,credentials=/root/.credfile,dir_mode=0755,file_mode=0755,uid=500,gid=500 0 0

    and then create the file /root/.credfile, with the following content (domain might not be mandatory):

    username=<share user> password= domain=

    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.

    Root Cause

    • Fore more information, please refer to MOUNT.CIFS(8).

    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.

    15 Comments

    MM

    Community Member

    20 points

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

    thomas.jones2@dodiis.mil's picture

    Guru

    6435 points

    thomas.jones2@dodiis.mil

    Community Leader

    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

    Community Member

    78 points

    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”

    HA

    Community Member

    22 points

    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?

    Any one has solution or suggestions for this issue? I am too seeing this issue. I am trying to mount share from Windows 2012 R2 system on to RHL Linux 6.

    I have seen this issue. Try adding the option vers=2.1 to the mount options, possibly in addition to sec=ntlmsspi

    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

    And a silly question: on two similar (but not identical) hosts (one running 7.4, one 7.5), both using cifs-utils-6.2-10.el7.x86_64 I get different results in the output of mount for identical fstab entries (neither of them mentions domain in the mount options). On the one running 7.5 the domain name doesn’t feature in mount’s output, on the 7.4 one it does. The smb.conf is identical for both machines, as is sssd.conf (both are AD attached and authenticate the mounting user [same user on both] via AD). What other config file might play a part in this?

    GL

    Active Contributor

    115 points

    Unfortunately the answer does not include details of how to mount a CIFS share when that share must be mounted with no username and no password.

    ES

    Community Member

    23 points

    Very nice page explaining syntax of the mount command for cifs. Doesn’t mention dependencies though to make it work: mount: wrong fs type, bad option, bad superblock on //, missing codepage or helper program, or other error (for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount. helper program) for the command to work. The solution page might suggest a package that contains the helper program for CIFS. Now I get to look for it. 🙁

    Steven Blair's picture

    Community Member

    42 points

    “To make the mount persistant across reboots, make the below entry to the /etc/fstab”

    There is no “a” in “persistent”.

    doesnt work.

    Similar Posts

    • Mount NTFS on RHEL

      ElRepo repository has kmod-fuse package that does not need dkms system. Since kmod installation uses module aliases (something like symlinks on filesystems), it works on all installed and future kernels without the need to recompile/install even automatic one with dkms. Get started Import the public key:rpm –import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org Detailed info on the GPG key used by the…

    • ACPI Errors on Ubuntu bootup

      You can get rid of those ACPI Error messages by 1. Open ‘/etc/default/grub’ in an editor with root access. In your case I believe Ubuntu uses gedit as it’s text editor Code: 2. The line with ‘GRUB_CMDLINE_LINUX_DEFAULT’, add the loglevel=3 part. The original looks like GRUB_CMDLINE_LINUX_DEFAULT=’quiet splash’ Change it to this: Code: Then save the…

    • Transfer data between RHEL and Solaris

      Transfer Data between RHEL and Solaris On SUN: in /etc/dfs/dfstab file addshare -F nfs /export/homethen type:/etc/init.d/nfs.server start On RHEL: to mounttype mount host:/export/home /mnt/sundisk Or in /etc/fstab host:/export/home /home/sundisk nfs defaults 0 0 Then type mount /home/sundisk Or type mount -aTo make nfs start at boot type: chkconfig nfs on to sharein file /etc/exports add/home/vnmr1…