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

    • Invalid or Missing Entitlement Certificates

      How to turn off the warning message, “Invalid or Missing Entitlement Certificates” last modified by Moritoshi Oshiro on 09/21/11 – 04:29Issue We manage entitlement/subscription in RHN Classic (not Customer Portal) The system is not connected to the Internet with RHN Classic (in disconnected mode), therefore the system is not registered in RHN Classic When the…

    • Installing Real VNC on RHEL

      Red Hat-compatible Linux The following instructions are valid for CentOS 5 running the GNOME desktop environment. Instructions may differ slightly fordifferent versions of CentOS, and versions of Fedora or Red Hat Enterprise, running different desktop environments, but theprinciple is the same. If in doubt, consult the operating system documentation. Downloading VNC Download a VNC for Linux…

    • Configure redhat remote printers

      On system connected to printer In system-config-settings under server settings check Share published printers connected to this system. On system connecting to remote printer Using makePrinter, create a printer using the same printer name as server. Also, hostname of server must be in /etc/hosts.  The UIR(port) should be ipp-1. Using system-config-printers, modify Device URI to read ipp//host-IP:631/printers/printer-name This allows for remote printing using the internet printer protocol.

    • RHEL 6 NFS

      Ensuring NFS Services are running on RHEL 6 The first task is to verify that the NFS services are installed and running on your RHEL 6 system. This can be achieved either from the command line, or using the graphical services tool. Begin by confirming that the NFS service is installed by running the following command from a…

    • How to Configure Networking in Ubuntu 20.04 with NetPlan

      Overview In this tutorial, you will learn how to configure networking in Ubuntu 20.04 with Netplan. You will learn how to set static IP addresses, DHCP addresses, as well as how to configure DNS and Wifi. Introduced back in 18.04, April 2018, networking was redone using a new system called Netplan โ€“ a YAML based…