Furthermore, you have to take into account another additional problem when you mount a remote directory through Samba. If the connection between the server and the client is cut off (this one is restarted, any kind of network problem turns up, etc.), Samba does not automatically reconnect it and the mount point will remain in an unstable state, with which any sort of existing synchronization would be lost.
In this way, it is very important to always mount remote directories by using automount.
Automount automatically mounts a filesystem when you use it, and unmounts it later when you are not working on it, based on a timeout. When the timeout (600 seconds by default) is used up, the filesystem is automatically dismounted. Thus, you can achieve a decrease in network traffic (there may be long periods of time that you are not accessing the filesystem) and avoid lack of synchronization. Also point out that automount is managed by the autofs daemon.
Then let's put forward our work infrastructure. It will be made up for three Linux servers (all of them running CentOS 6.2). The main server, centos01, will mount a filesystem from centos02 via NFS, and another one from centos03 via Samba.
First of all, we have to install autofs and create a directory which will be used to mount the file systems. Afterwards, we have to edit the auto.master file in order to define the mount point handled by autofs.
[root@centos01 ~]# yum install autofs [root@centos01 ~]# mkdir /mnt/tmp [root@centos01 ~]# cat /etc/auto.master ... /mnt/tmp /etc/auto.centos -g,--timeout=300
The above line means that all available mount points for the tmp directory will be set inside the auto.centos file. With "-g" option, autofs shows the content of the directory without mounting it, that is to say, if you run for example "ls /mnt/tmp", you will see those directories which will be able to be mounted through automount. Otherwise, no directory will be output.
This last option is really useful if you want to serve a filesystem by means of Apache and import it via automount, since Apache will be able to list the content of the directory without previously mounting it.