In this guide we will learn how to Mount Windows Shares on Linux using autofs. CentOS 6.3 machine and a windows 7 machine will be used to perform this task.
A share folder is available on windows 7 machine named win-share. We will mount this share folder using autofs on CentOS.

Let’s get started.


Windows PC Details :

IP Address
Shared Folder   win-share
Mount Point on Linux   /win-share/share


Open up terminal on Linux machine and enter the following command:

# yum install -y autofs cifs-utils

Command Output :

Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
* c6-media:
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package autofs.i686 1:5.0.5-54.el6 will be installed
—> Package cifs-utils.i686 0:4.8.1-10.el6 will be installed
–> Finished Dependency Resolution
Dependencies Resolved
Package Arch Version Repository Size
autofs i686 1:5.0.5-54.el6 c6-media 492 k
cifs-utils i686 4.8.1-10.el6 c6-media 46 k
Transaction Summary
Install 2 Package(s)
Total download size: 537 k
Installed size: 3.1 M
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 537 k
Total 55 MB/s | 537 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 1:autofs-5.0.5-54.el6.i686 1/2
Installing : cifs-utils-4.8.1-10.el6.i686 2/2
Verifying : cifs-utils-4.8.1-10.el6.i686 1/2
Verifying : 1:autofs-5.0.5-54.el6.i686 2/2
autofs.i686 1:5.0.5-54.el6 cifs-utils.i686 0:4.8.1-10.el6
[root@w1 ~]#


Now Edit /etc/auto.master file and add below entry after /misc /etc/auto.misc line

# vi /etc/auto.master

/win-mount /etc/

This means we are going to mount some share folder at /win-mount and for the details read following file /etc/

Save & Exit



Now create directory on Linux which we mentioned in auto.master file.

# mkdir /win-mount


Create file under /etc/ and add below line into this.

# vi /etc/

Add following line

share -fstype=cifs,credentials=/etc/user-pass.txt ://

This entry means, mount win-share as sub-folder of win-mount directory with the name of share. Which means “ls /win-mount/share” command will display the contents of //

Save & Exit



Now create credentials file and provide windows machine username and password to access windows shares from Linux

# vi /etc/user-pass.txt

Save & Exit



At last restart autofs service

# service autofs restart

Verify if windows shares are mounted on Linux.

# ls /win-mount/share
1 2 3 4 New Text Document.txt


Verify mounted share using disk free command.

# df -kh

Filesystem Size Used Avail Use{1c918b003a0fec779e46518dd4d8df22f3dc554de918030f5a1a0cfd93cb28be} Mounted on
1.5G 704M 739M 49{1c918b003a0fec779e46518dd4d8df22f3dc554de918030f5a1a0cfd93cb28be} /
tmpfs 250M 0 250M 0{1c918b003a0fec779e46518dd4d8df22f3dc554de918030f5a1a0cfd93cb28be} /dev/shm
/dev/sda1 485M 38M 422M 9{1c918b003a0fec779e46518dd4d8df22f3dc554de918030f5a1a0cfd93cb28be} /boot
/dev/sr0 3.5G 3.5G 0 100{1c918b003a0fec779e46518dd4d8df22f3dc554de918030f5a1a0cfd93cb28be} /dvd
// 8.0G 6.8G 1.2G 85{1c918b003a0fec779e46518dd4d8df22f3dc554de918030f5a1a0cfd93cb28be} /win-mount/share

Everything looks perfect, hope its all clear, if you need any further help please use comment section.

Similar Posts