Saturday, 30 November 2019

How to Mount Windows Share on CentOS 7 using CIFS



CIFS (Common Internet File System) is an implementation of SMB and network file sharing protocol. It is used to provide shared access to files, folders and printers etc. between windows to windows and windows to Linux machines over the network.
This article describes How to Mount Windows Share on CentOS7 using CIFS.

Step 1. Package installation: Run the following command to install cifs-utils package:

[root@linuxcnf ~]# yum install cifs-utils -y
Loaded plugins: fastestmirror
…………………………..
Installed:
  cifs-utils.x86_64 0:6.2-10.el7

Dependency Installed:
  avahi-libs.x86_64 0:0.6.31-19.el7           cups-libs.x86_64 1:1.6.3-40.el7
…………………………..
  samba-common.noarch 0:4.9.1-6.el7      samba-common-libs.x86_64 0:4.9.1-6.el7

Complete!
[root@linuxcnf ~]#

Step 2. Create Credential File: Create a file with the following entries and change file permission:

[root@linuxcnf ~]# vi /root/.smb-credentials
username = <user-name>
password = <password>
domain = <domain-name>
[root@linuxcnf ~]#

[root@linuxcnf ~]# chmod 600 /root/.smb-credentials
[root@linuxcnf ~]#

Step 3. Mount a Windows Share: Run the following commands to create a directory to mount Windows Share and mount Windows Share:

[root@linuxcnf ~]# mkdir -p /mnt/cifs-share
[root@linuxcnf ~]#
[root@linuxcnf ~]# ls -ld /mnt/cifs-share/
drwxr-xr-x. 2 root root 6 Nov 30 22:17 /mnt/cifs-share/
[root@linuxcnf ~]#

[root@linuxcnf ~]# mount -t cifs -o credentials=/root/.smb-credentials //192.168.43.20/share /mnt/cifs-share/
[root@linuxcnf ~]#

Step 4. Configure for Auto Mount (Optional): Edit /etc/fstab and put the below entries at the end of the file to mount the Windows Share across reboot the machine:

[root@linuxcnf ~]# vi /etc/fstab
……………………………
//192.168.43.20/share    /mnt/cifs-share/       cifs    credentials=/root/.smb-credentials      0 0
[root@linuxcnf ~]#

[root@linuxcnf ~]# mount -a
[root@linuxcnf ~]#

Step 5. Verify the Mounting Status: Run the following command to verify mounting of the Windows Share:

[root@linuxcnf ~]# df -hT
Filesystem                             Type      Size  Used Avail Use% Mounted on
…………………………….
//192.168.43.20/share                          cifs     8.0G  3.9G  4.2G  49% /mnt/cifs-share
[root@linuxcnf ~]#

Done!!! Windows Share is mounted successfully on CentOS 7 client.

No comments:

Post a comment