Feb 26, 2012

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

Mounting a filesystem via Samba or NFS has the main problem that you are increasing the traffic in your network, since when the data are updated on the export server, they must also be brushed up on the clients.

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.


3 comments:

  1. No te has puesto a pensar que hay gente (como yo por ejemplo) que se le dificulta poder leer correctamente tus articulos por la fuente que has elegido para tus textos....?

    Saludos

    ReplyDelete
  2. Hola,

    a mí me gusta la fuente y por eso la utilizo. En tu caso, siempre tendrás la opción de copiar el artículo y pegarlo en cualquier editor de textos (no creo que te lleve más de diez segundos), y luego modificar la fuente a tu gusto.

    Un saludo,

    ReplyDelete
  3. Es muy posible que esto me facilite muchísimo la existencia. ¡Gracias!

    ReplyDelete