¡Esta es una revisión vieja del documento!
Tabla de Contenidos
NFS - Quick and Dirty Setup
Se sabe que funcionan con Slackware 14, 14.1 y 14.2
Supuestos
1) Este HOWTO asume que estás usando una instalación de Slackware vainilla no has cambiado las reglas predeterminadas de HOSTS_ALLOW, HOSTS_DENY o firewall.
2) Para este ejemplo, el directorio compartido en el servidor será /nfs_share
3) Para este ejemplo, el punto de montaje del recurso compartido NFS será /mnt/nfs_share
4) Queremos que cualquier persona en nuestra subred (192.168.1.x) tenga acceso RW al recurso compartido
Descripción general
1) Configurar el servidor
2) Configurar el cliente
3) Montar los directorios NFS en el cliente
Configuración del servidor
Agregue los recursos compartidos de NFS al archivo / etc / exports
vi /etc/exports
agregue:
- /etc/exports
/nfs_share 192.168.1.1/24(rw,sync,no_subtree_check)
Inicia los demonios NFS y RPC
chmod 755 /etc/rc.d/rc.nfsd chmod 755 /etc/rc.d/rc.rpc /etc/rc.d/rc.nfsd start /etc/rc.d/rc.rpc start
Exporte los compartidos
exportfs -a
Compruebe si los recursos compartidos se comparten
exportfs
Configuración del cliente
Crear el punto de montaje
mkdir /mnt/nfs_share
Inicia el demonio RPC
chmod 755 /etc/rc.d/rc.rpc /etc/rc.d/rc.rpc start
Montaje
En la máquina CLIENTE, tiene 3 opciones: montaje manual, montaje automático en el arranque o montaje semiautomático
MONTAJE MANUAL
mount my.nfs.server:/nfs_share /mnt/nfs_share
MONTAJE AUTOMÁTICO EN EL ARRANQUE
Agregue el comando mount a /etc/fstab
vi /etc/fstab
add:
- /etc/fstab
my.nfs.server:/nfs_share /mnt/nfs_share nfs rw,defaults 0 0
MONTAJE SEMI AUTOMÁTICO
Agregue el comando de montaje a /etc/fstab
vi /etc/fstab
agregue:
- /etc/fstab
my.nfs.server:/nfs_share /mnt/nfs_share nfs rw,noauto 0 0
entonces cuando quieras montar, simplemente ejecuta:
mount /mnt/nfs_share
NOTA SOBRE AUTO_MOUNTING
Si lo monta durante el arranque y la máquina del servidor no está disponible, la máquina cliente tardará mucho tiempo en iniciarse, ya que el cliente NFS hará múltiples intentos de conexión y tendrá que esperar a que se agote el tiempo de espera para cada intento. .
Para el impaciente
Todos los pasos sin explicación:
SERVIDOR:
echo "/SHARED_DIR YOUR_SUBNET/24(rw,sync,no_subtree_check)" >> /etc/exports chmod 755 /etc/rc.d/rc.nfsd chmod 755 /etc/rc.d/rc.rpc /etc/rc.d/rc.nfsd start /etc/rc.d/rpc start exportfs -a
CLIENTE:
mkdir /mnt/nfs_share chmod 755 /etc/rc.d/rc.rpc /etc/rc.d/rc.rpc start echo "YOUR_NFS_SERVER:/SHARED_DIR /CLIENT_MOUNT_POINT nfs rw,defaults 0 0" >> /etc/fstab mount /CLIENT_MOUNT_POINT
Problems/Solutions
PROBLEM: NFS shares won't mount on client box with a “Stale NFS file handle” error.
SOLUTION:
1) Forcibly unmount the directory on the CLIENT machine (if mounted):
umount -f /mnt/nfs_share
2) Flush the NFS registry on the SERVER machine:
exportfs -f
3) Remount the NFS share
4) No Root Squash: There are many options for NFS and I want to keep this article short but effective so I am leaving out many of the various configuration items that you could do. However there is one option that is worth mentioning, no_root_squash. By default NFS will downgrade any files created with the root permissions to the nobody user. This is a security feature that prevents privileges from being shared unless specifically requested. If I create a file as the root user on the client on the NFS share, by default that file is owned by the nobody user.
root@client:~# touch /shared/nfs1/file2 root@server:/nfs# ls -la file2 -rw-r--r-- 1 nobody nogroup 0 Nov 18 18:06 file2
Sometimes it is important to share files that are owned as root with the proper permissions, in these cases this can be done by simply adding the no_root_squash attribute to the /etc/exports configuration.
Edit the /etc/exports file:
/nfs_share 192.168.1.1/24(rw,sync,no_root_squash)
Sources
* Originally written by arfon