You are on page 1of 13

Configuracin del servidor NFS

http://web.mit.edu/rhel-doc/3/rhel-rg-es-3/s1-nfs-server-export.html

Anterior

Red Hat Enterprise Linux 3: Manual de referencia Captulo 9. Sistema de archivos de red (NFS)

Siguiente

9.3. Configuracin del servidor NFS


Existen tres formas de configurar un servidor NFS bajo Red Hat Enterprise Linux: usando la Herramienta de configuracin del servidor NFS (redhat-config-nfs), modificando manualmente su archivo de configuracin ( /etc/exports), o utilizando el comando /usr/sbin/exportfs. Para las instrucciones sobre como utilizar Herramienta de configuracin del servidor NFS, consulte el captulo llamado Sistemas de archivo de red (NFS) en el Manual de administracin del sistema de Red Hat Enterprise Linux. El resto de esta seccin discute la modificacin manual de /etc/exports y el uso del comando /usr/sbin/exportfs para exportar sistemas de archivos NFS.

9.3.1. Archivo de configuracin del servidor NFS


El archivo /etc/exports controla cules sistemas de archivos son exportados a las mquinas remotas y especifica opciones. Las lneas en blanco son ignoradas, se pueden comentar lneas con el smbolo # y las lneas largas pueden ser divididas con una barra invertida (\). Cada sistema de archivos exportado debe tener su propia lnea y cualquier lista de hosts autorizadas colocada despus de un sistema de archivos exportado, debe estar separada por un espacio. Las opciones para cada uno de los hosts deben ser colocadas entre parntesis directamente detrs del identificador del host, sin ningn espacio de separacin entre el host y el primer parntesis. Una lnea para un sistema de archivos exportado tiene la estructura siguiente: <export> <host1>(<options>) <hostN>(<options>)...

En esta estructura, reemplace <export> con el directorio a exportar, reemplace <host1> con el host o la red a la cual est siendo compartida la exportacin y reemplace <options> con las opciones para cada host o red. Los hosts adicionales se pueden especificar en una lista separada por espacios. Se pueden usar los mtodos siguientes para especificar nombres de host: una sola mquina Cuando una mquina en particular es especificada con nombre completo de dominio, nombre de mquina o direccin IP. comodines Usamos un carcter * o ? para referirnos a un grupo de nombres completos de dominio o direcciones IP o que coincidan con una cadena particular de letras. Los comodines no son usados con direcciones IP; sin embargo, es posible para estos funcionar accidentalmente si fallan las bsquedas de DNS inversas. Tenga cuidado cuando especifique comodines con nombres de dominio
1 of 5 27/03/2007 9:16

Configuracin del servidor NFS

http://web.mit.edu/rhel-doc/3/rhel-rg-es-3/s1-nfs-server-export.html

completos, pues tienden a ser ms exactos de lo que usted cree. Por ejemplo, el uso de *.example.com como comodn, permitir a ventas.domain.com acceder al sistema de archivos exportado, pero no a bob.ventas.domain.com. Para permitir ambas posibilidades, debera usar *.example.com y tambin *.*.example.com redes IP Permite la coincidencia de hosts basados en sus direcciones IP dentro de una red ms grande. Por ejemplo, 192.168.0.0/28 permite al acceso a las primeras 16 direcciones IP, desde la 192.168.0.0 a la 192.168.0.15, acceder al sistema de archivos exportado, pero no a la 192.168.0.16 y superiores. grupos de redes Permite usar un nombre de grupo de red NIS, escrito como @<group-name>. Esto pone al servidor NIS controlando el acceso de este sistema de archivos, donde los usuarios pueden ser aadidos o borrados de un grupo NIS sin que afecte a /etc/exports. En su forma ms sencilla, /etc/exports slo necesita saber el directorio a exportar y los hosts que pueden usarlo, como en el ejemplo siguiente: /exported/directory bob.example.com

En el ejemplo, bob.example.com puede montar /exported/directory/. Como no se especifica ninguna opcin en este ejemplo, tomarn efecto las siguientes opciones predeterminadas de NFS: ro Se montan los sistemas de archivos como de slo lectura (read-only). Los host remotos no pueden hacer cambios a los datos compartidos en el sistema de archivos. Para permitir que los hosts puedan hacer cambios, debe especificar la opcin rw (lectura-escritura, read-write). async Permite al servidor escribir los datos en el disco a intervalos irregulares. Esta configuracin funciona mejor si el sistema de archivos exportado es de slo lectura. Si el sistema de archivos de lectura/escritura y los hosts estn haciendo cambios al sistema de archivos cuando el servidor se cae o se apaga, se pueden perder datos. Especificando la opcin sync, todas las escrituras en el disco se efectan antes de que la peticin de escritura del cliente se haya completado. Sin embargo, la opcin sync, puede que disminuya el rendimiento. wdelay Provoca que el servidor NFS retrase el escribir a disco si sospecha que otra peticin de escritura es inminente. Esto puede mejorar el rendimiento reduciendo las veces que se debe acceder al disco por comandos de escritura separados. Use no_wdelay para desactivar esta opcin, la cual slo funciona si est usando la opcin sync. root_squash Prevents root users connected remotely from having root

2 of 5

27/03/2007 9:16

Configuracin del servidor NFS

http://web.mit.edu/rhel-doc/3/rhel-rg-es-3/s1-nfs-server-export.html

privileges and assigns them the user ID for the user nfsnobody. This effectively "squashes" the power of the remote root user to the lowest local user, preventing unauthorized alteration of files on the remote server. Alternatively, the no_root_squash option turns off root squashing. To squash every remote user, including root, use the all_squash option. To specify the user and group IDs to use with remote users from a particular host, use the anonuid and anongid options, respectively. In this case, a special user account can be created for remote NFS users to share and specify (anonuid=<uid-value>,anongid=<gid-value>), where <uid-value> is the user ID number and <gid-value> is the group ID number.

Importante Por defecto, las listas de control de acceso (ACLs) son soportadas por NFS bajo Red Hat Enterprise Linux. Para desactivar esta funcionalidad, especifique la opcin no_acl cuando est exportando el sistema de archivos. Para ms informacin sobre esta funcionalidad, vea el captulo Sistemas de archivo de red (NFS) en el Manual de administracin del sistema de Red Hat Enterprise Linux.

Cada valor predeterminado para un sistema de archivos exportado debe ser explcitamente ignorado. Por ejemplo, si no se especifica la opcin rw, entonces el sistema de archivos es exportado como de slo lectura. Lo siguiente es una lnea de muestra de /etc/exports la cual sobreescribe dos opciones predeterminadas: /another/exported/directory 192.168.0.3(rw,sync)

En este ejemplo 192.168.0.3 puede montar /another/exported/directory/ como lectura/escritura y todas las transferencias al disco son efectuadas antes de completar la peticin de escritura del cliente. Adicionalmente, hay otra opciones que estn disponibles que no tienen especificado un valor predeterminado. Estas incluyen la habilidad de desactivar la verificacin por subdirectorios, permitir el acceso desde puertos inseguros y permitir bloquear archivos inseguros (necesario para algunas implementaciones antiguas de clientes NFS). Vea la pgina man de exports para estas opciones menos usadas.

Aviso La manera en que el archivo /etc/exports est organizado es muy importante, particularmente lo que concierne a los espacios en blanco. Recuerde separar siempre los sistemas de archivos exportados de

3 of 5

27/03/2007 9:16

Configuracin del servidor NFS

http://web.mit.edu/rhel-doc/3/rhel-rg-es-3/s1-nfs-server-export.html

una mquina a la otra, con un espacio. Sin embargo, no debera haber otros espacios en el archivo a menos que se usen en lneas comentadas. Por ejemplo, las siguientes dos lneas significan cosas distintas: /home bob.example.com(rw) /home bob.example.com (rw)

La primera lnea permite slo a los usuarios de bob.example.com acceder en modo de lectura/escritura al directorio /home. La segunda lnea permite a los usuarios de bob.example.com montar el directorio de slo lectura (el predeterminado), pero el resto del mundo puede instalarlo como lectura/escritura.

Para instrucciones detalladas sobre la configuracin de un servidor NFS modificando /etc/exports, consulte el captulo titulado Sistemas de archivos de red (NFS) en el Manual de administracin del sistema de Red Hat Enterprise Linux.

9.3.2. El comando exportfs


Cada sistema de archivos que se exporta a usuarios remotos a travs de NFS, as como los niveles de acceso relativos a ellos, son listados en el archivo /etc/exports. Cuando comienza el servicio nfs, el comando /usr/sbin/exportfs lanza y lee este archivo y pasa a rpc.mountd y a rpc.nfsd los sistemas de archivos disponibles a los usuarios remotos. Cuando se ejecuta manualmente, el comando /usr/sbin/exportfs permite al usuario root exportar o no directorios concretos sin reiniciar los servicios NFS. Cuando se le pasan las opciones apropiadas, el comando /usr/sbin/exportfs escribe los sistemas de archivos exportados a /var/lib/nfs/xtab. Como rpc.mountd se refiere al archivo xtab para decidir privilegios de acceso a un sistema de archivos, los cambios en la lista de sistemas de archivos exportados toman efecto inmediatamente. Lo siguiente es una lista de las opciones ms comunes disponibles para /usr/sbin/exportfs: -r Provoca que todos los directorios listados en /etc/exports sean exportados construyendo una nueva lista de exportacin en /etc/lib/nfs/xtab. Esta opcin refresca la lista de exportacin con cualquier cambio que hubiramos realizado en /etc/exports. -a Provoca que todos los directorios sean exportados o no, dependiendo de qu otras opciones hemos pasado a /usr/sbin/exportfs. Si no se pasan otras opciones, /usr/sbin/exportfs exporta todos los sistemas de archivos

4 of 5

27/03/2007 9:16

Configuracin del servidor NFS

http://web.mit.edu/rhel-doc/3/rhel-rg-es-3/s1-nfs-server-export.html

especificados en /etc/exports. -o file-systems Permite especificar directorios a exportar que no estn listados en /etc/exports. Reemplace file-systems con los sistemas de archivos adicionales a exportar. Estos sistemas de archivos deben tener el mismo formato en que fueron especificados en /etc/exports. Consulte la Seccin 9.3.1 para ms informacin sobre la sintaxis de /etc/exports. Esta opcin es usada para probar un sistema de archivos antes de aadirlo permanentemente a la lista de sistemas a exportar. -i Ignora /etc/exports; slo las opciones dadas desde la lnea de comandos son usadas para definir los sistemas de archivos exportados. -u No exporta todos los directorios compartidos. El comando /usr/sbin/exportfs -ua suspende la comparticin de archivos NFS mientras que mantiene todos los demonios NFS activos. Para reactivar la comparticin NFS, teclee exportfs -r. -v Operacin descriptiva, donde los sistemas de archivos exportados o dejados de exportar son mostrados en gran detalle al ejecutarse el comando exportfs. Si no se pasan opciones al comando /usr/sbin/exportfs, mostrar una lista de los sistemas de archivos actualmente exportados. Para ms informacin sobre /usr/sbin/exportfs, vaya a la pgina man de exportfs. Anterior Iniciar y detener NFS Inicio Subir Siguiente Archivos de configuracin de clientes NFS

5 of 5

27/03/2007 9:16

NFS Client Configuration Files

http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/ref-gui...

Search Docs:

Go

Red Hat Docs > Manuals > Red Hat Linux Manuals > Red Hat Linux 9 >

Prev

Red Hat Linux 9: Red Hat Linux Reference Guide Chapter 9. Network File System (NFS)

Next

9.3. NFS Client Configuration Files


Any NFS share made available by a server can be mounted using various methods. The share can be manually mounted, using the mount command. However, this requires that the root user type the mount command every time the system restarts. Two methods of configuring NFS shares to be mounted automatically at boot time include modifying the /etc/fstab or using the autofs service.

9.3.1. /etc/fstab
Placing a properly formatted line in the /etc/fstab file has the same effect as manually mounting the exported file system. The /etc/fstab file is read by the /etc/rc.d/init.d/netfs script at system startup and any NFS shares listed there will be mounted. A sample /etc/fstab line to mount an NFS export looks like the following: <server>:</path/of/dir> </local/mnt/point> nfs <options> 0 0

The <server-host> corresponds to hostname, IP address, or fully qualified domain name of the server exporting the file system. The </path/of/directory> is the path to the exported directory. The </local/mount/point> specifies where on the local file system to mount the exported directory. This mount point must exist before /etc/fstab is read or the mount will fail. The nfs option specifies the type of file system being mounted. The <options> area specifies mount options for the file system. For example, if the options area states rw,suid, the exported file system will be mounted read-write and the user and groupid set by the server will be used. Note that parentheses are not to be used here. For more mount options, see Section 9.3.3 Common NFS Mount Options.

9.3.2. autofs
One drawback to using /etc/fstab is that, regardless of how infrequently a user

1 of 4

27/03/2007 9:16

NFS Client Configuration Files

http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/ref-gui...

may access the NFS mounted file system, the system must dedicate resources to keep that mount in place. This is not a problem with one or two mounts, but when the system is maintaining mounts to a dozen systems at one time, overall system performance can suffer. An alternative to /etc/fstab is to use the kernel-based automount utility, which will mount and unmount NFS file systems automatically, saving resources. The autofs script, located in the /etc/rc.d/init.d/ directory, is used to control automount through the /etc/auto.master primary configuration file. While automount can be specified on the command line, it is more convenient to specify the mount points, hostname, exported directory, and options in a set of files rather than typing them all by hand. By running autofs as a service that starts and stops in designated runlevels, the mount configurations in the various files can be automatically implemented. The autofs configuration files are arranged in a parent-child relationship. A main configuration file (/etc/auto.master) refers mount points on your system that are linked to a particular map type, which take the form of other configuration files, programs, NIS maps, and other less common mount methods. The auto.master file contains lines referring to each of these mount points, organized like this: <mount-point> <map-type>

The <mount-point> element of this line indicates the location of the mount on the local file system. The <map-type> relates to the way in which the mount point will be mounted. The most common method for auto mounting NFS exports is to use a file as the map type for the particular mount point. The map file, usually named auto.<mount-point>, where <mount-point> is the mount point designated in auto.master, contains lines that look like this: <directory> <mount-options> <host>:<exported-file-system>

The <directory> refers to the directory within the mount point where the exported file system should be mounted. Much like a standard mount command, the host exporting the file system, as well as the file system being exported, are required in the <host>:<exported-file system> section. To specify particular options to be used when mounting the exported file system, place them in the <mount-options> section, separated by commas. For NFS mounts that use autofs, place -fstype=nfs in the <mount-options> section. While autofs configuration files can be used for a variety of mounts to many types of devices and file systems, they are particularly useful in creating NFS mounts. For example, some organizations store a user's /home/ directory on a central server via an NFS share. Then, they configure the auto.master file on each of the

2 of 4

27/03/2007 9:16

NFS Client Configuration Files

http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/ref-gui...

workstations to point to an auto.home file containing the specifics for how to mount the /home/ directory via NFS. This allows the user to access personal data and configuration files in their /home/ directory by logging in anywhere on the internal network. The auto.master file in this situation would look similar to this: /home /etc/auto.home

This sets up the /home/ mount point on the local system to be configured by the /etc/auto.home file, which may look similar to this: * -fstype=nfs,soft,intr,rsize=8192,wsize=8192,nosuid server.example.com:/home

This line states that any directory a user tries to access under the local /home/ directory (due to the asterisk character) should result in an NFS mount on the server.example.com system within its exported /home/ file system. The mount options specify that each /home/ directory NFS mounts should use a particular collection of settings. For more information on mount options, including the ones used in this example, see Section 9.3.3 Common NFS Mount Options.

9.3.3. Common NFS Mount Options


Beyond mounting a file system via NFS on a remote host, a number of different options may be specified at the time of the mount that can make it easier to use. These options can be used with manual mount commands, /etc/fstab settings, and autofs, and other mounting methods. The following options are the most popular for NFS mounts: hard or soft specifies whether the program using a file via an NFS connection should stop and wait (hard) for the server to come back online if the host serving the exported file system is unavailable, or if it should report an error (soft). If hard is specified, the user cannot terminate the process waiting for the NFS communication to resume unless intr option is also specified. If soft, is specified, the user can set an additional timeo=<value> option, where <value> specifies the number of seconds to pass before the error is reported. intr allows NFS requests to be interrupted if the server goes down or cannot be reached. nolock is occasionally required when connecting to older NFS server. To require locking, use the lock option.

3 of 4

27/03/2007 9:16

NFS Client Configuration Files

http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/ref-gui...

noexec does not permit the execution of binaries on the mounted file system. This is useful if the system is mounting a non-Linux file system via NFS that contains incompatible binaries. nosuid does not allow set-user-identifier or set-group-identifier bits to take effect. rsize=8192 and wsize=8192 may speed up NFS communication for reads (rsize) and writes (wsize) by setting a larger data block size, in bytes, to be transferred at one time. Be careful when changing these values; some older Linux kernels and network cards may not work well with larger block sizes. nfsvers=2 or nfsvers=3 specify which version of the NFS protocol to use. Many more options are listed on the mount man page, including options for mounting non-NFS file systems. Prev NFS Server Configuration Files Home Up Next Securing NFS

4 of 4

27/03/2007 9:16

Mounting NFS File Systems

http://www.redhat.com/docs/manuals/enterprise/RHEL-3-Manual/...

Search Docs:

Go

Red Hat Docs > Manuals > Red Hat Enterprise Linux Manuals >

Prev

Red Hat Enterprise Linux 3: System Administration Guide Chapter 23. Network File System (NFS)

Next

23.2. Mounting NFS File Systems


Use the mount command to mount a shared NFS directory from another machine: mount shadowman.example.com:/misc/export /misc/local

Warning The mount point directory on local machine (/misc/local in the above example) must exist.

In this command, shadowman.example.com is the hostname of the NFS file server, /misc/export is the directory that shadowman is exporting, and /misc/local is the location to mount the file system on the local machine. After the mount command runs (and if the client has proper permissions from the shadowman.example.com NFS server) the client user can execute the command ls /misc/local to display a listing of the files in /misc/export on shadowman.example.com.

23.2.1. Mounting NFS File Systems using /etc/fstab


An alternate way to mount an NFS share from another machine is to add a line to the /etc/fstab file. The line must state the hostname of the NFS server, the directory on the server being exported, and the directory on the local machine where the NFS share is to be mounted. You must be root to modify the /etc/fstab file. The general syntax for the line in /etc/fstab is as follows: server:/usr/local/pub /pub nfs rsize=8192,wsize=8192,timeo=14,intr

The mount point /pub must exist on the client machine. After adding this line to /etc/fstab on the client system, type the command mount /pub at a shell prompt, and the mount point /pub will be mounted from the server.

1 of 4

27/03/2007 9:16

Mounting NFS File Systems

http://www.redhat.com/docs/manuals/enterprise/RHEL-3-Manual/...

23.2.2. Mounting NFS File Systems using autofs


A third option for mounting an NFS share is the use of autofs. Autofs uses the automount daemon to manage your mount points by only mounting them dynamically when they are accessed. Autofs consults the master map configuration file /etc/auto.master to determine which mount points are defined. It then starts an automount process with the appropriate parameters for each mount point. Each line in the master map defines a mount point and a separate map file that defines the file systems to be mounted under this mount point. For example, the /etc/auto.misc file might define mount points in the /misc directory; this relationship would be defined in the /etc/auto.master file. Each entry in auto.master has three fields. The first field is the mount point. The second field is the location of the map file, and the third field is optional. The third field can contain information such as a timeout value. For example, to mount the directory /proj52 on the remote machine penguin.example.net at the mount point /misc/myproject on your machine, add the following line to auto.master: /misc /etc/auto.misc --timeout 60

Add the following line to /etc/auto.misc: myproject -rw,soft,intr,rsize=8192,wsize=8192 penguin.example.net:/proj52

The first field in /etc/auto.misc is the name of the /misc subdirectory. This directory is created dynamically by automount. It should not actually exist on the client machine. The second field contains mount options such as rw for read and write access. The third field is the location of the NFS export including the hostname and directory.

Note The directory /misc must exist on the local file system. There should be no subdirectories in /misc on the local file system.

Autofs is a service. To start the service, at a shell prompt, type the following commands:

2 of 4

27/03/2007 9:16

Mounting NFS File Systems

http://www.redhat.com/docs/manuals/enterprise/RHEL-3-Manual/...

/sbin/service autofs restart

To view the active mount points, type the following command at a shell prompt: /sbin/service autofs status

If you modify the /etc/auto.master configuration file while autofs is running, you must tell the automount daemon(s) to reload by typing the following command at a shell prompt: /sbin/service autofs reload

To learn how to configure autofs to start at boot time, refer to Chapter 21 Controlling Access to Services for information on managing services.

23.2.3. Using TCP


The default transport protocol for NFS is UDP; however, the Red Hat Enterprise Linux 3 kernel includes support for NFS over TCP. To use NFS over TCP, include the -o tcp option to mount when mounting the NFS-exported file system on the client system. For example: mount -o tcp shadowman.example.com:/misc/export /misc/local

If the NFS mount is specified in /etc/fstab: server:/usr/local/pub /pub nfs rsize=8192,wsize=8192,timeo=14,intr,tcp

If it is specified in an autofs configuration file: myproject -rw,soft,intr,rsize=8192,wsize=8192,tcp penguin.example.net:/proj52

Since the default is UDP, if the -o tcp option is not specified, the NFS-exported file system is accessed via UDP. The advantages of using TCP include the following:

3 of 4

27/03/2007 9:16

Mounting NFS File Systems

http://www.redhat.com/docs/manuals/enterprise/RHEL-3-Manual/...

Improved connection durability, thus less NFS stale file handles messages. Performance gain on heavily loaded networks because TCP acknowledges every packet, unlike UDP which only acknowledges completion. TCP has better congestion control than UDP (which has none). On a very congested network, UDP packets are the first types of packet that are dropped. Which means if NFS is writing data (in 8K chunks) all of that 8K has to retransmitted. With TCP because of its reliability, one parts of that 8K data is transmitted at a time. Error detection. When a tcp connection breaks (due to the server going down) the client stops sending data and starts the reconnection process. With UDP, since its connection-less, the client continue to pound the network with data until server comes up. The main disadvantage is that there is a very small performance hit due to the overhead associated with the TCP protocol.

23.2.4. Preserving ACLs


The Red Hat Enterprise Linux 3 kernel provides ACL support for the ext3 file system and ext3 file systems mounted with the NFS or Samba protocols. Thus, if an ext3 file system has ACLs enabled for it and is NFS exported, if the NFS client can read ACLs, they are used by the NFS client as well. For more information about mounting NFS file systems with ACLs, refer to Chapter 8 Access Control Lists. Prev Network File System (NFS) Home Up Next Exporting NFS File Systems

4 of 4

27/03/2007 9:16

You might also like