Mar 4, 2012

Mounting file systems via Samba (CIFS) or NFS through automount (autofs) (II)

This is the second part of the article Mounting file systems via Samba (CIFS) or NFS through automount (autofs). In the first one, we started to prepare autofs in order to automatically mount a couple of remote directories by NFS and Samba.

Now let's carry on by supposing that centos02 exports the directory /nfs via NFS and centos03 exports the directory /samba via Samba. I am not going to note down how to configure NFS or Samba, because next week I intend to write an article related to this.

The following file shows the content of the auto.centos file. By means of this configuration file, we are indicating the NFS or Samba paths to the autofs daemon. When someone (or something) accesses the /mnt/tmp/nfs directory, this filesystem will be automatically imported from centos02 via NFS. The same occurs for the /mnt/tmp/samba directory imported from centos03 via Samba.

[root@centos01 ~]# cat /etc/auto.centos
...
nfs     -fstype=nfs                                        centos02:/nfs
samba   -fstype=cifs,username=samba_user,password=xxxxxx   ://centos03/samba

When the timeout has expired and there has been no activity on the directories during that time, the directories will also be automatically dismounted.

Finally, you just have to restart the autofs service.

[root@centos01 ~]# service autofs restart


No comments:

Post a Comment