Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Mount an SMB/CIFS Share as an Automount on CentOS/Fedora/RHEL  (Read 1616 times)

0 Members and 1 Guest are viewing this topic.

jibinw

  • Guest
In This  tutorial  I will show  you  How  to automatically mount/unmount a SMB/CIFS Windows share on a CentOS/Fedora/RHEL server.

First you should open terminal and follow the instructions bellow:

1-Install the  Automounter

Code: [Select]
[b]#  yum install autofs[/b]
 2-Install samba (client)

Code: [Select]
[b]#yum install samba-client samba-common[/b]
3-Next you have to add an entry to the file /etc/auto.master, like so:

 
Code: [Select]
[b]# file: /etc/auto.master
# ...
# ...
/mnt/cifs_share    /etc/auto.cifs    --timeout=600 --ghost[/b]

4-Now we’ll need to create the mount point:

 
Code: [Select]
[b]% mkdir /mnt/cifs_share[/b]
5-now create the file /etc/auto.cifs:

 
Code: [Select]
[b]share_data    -fstype=cifs,rw,noperm,credentials=/etc/credentials.txt    ://192.168.1.x/windows_data[/b]
6-And finally, create the credentials.txt file.

Code: [Select]
[b]# /etc/credentials.txt
username=user_windows
password=pass_windows[/b]

7-The last step is to startup the automounter service (/etc/init.d/autofs).

Code: [Select]
[b]% /etc/init.d/autofs start[/b]
8-Once done you should now be able to cd to /mnt/cifs_share/windwos_data.
   
Code: [Select]
[b]% cd /mnt/cifs_share/windows_data
 
% pwd
/mnt/cifs_share/windows_data[/b]

9-You can confirm that the mount is being accessed correctly by checking the active mounts:
   
Code: [Select]
[b]% mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
//192.168.1.x/windows_data on /mnt/cifs_share/windows_data type cifs (rw,mand)[/b]