You are on page 1of 3

NFS Server Setup

NFS Server Installation


The first step is to install NFS server binaries. To do that use apt command to install nfs-kernel-
server package:
# apt-get install nfs-kernel-server

Confirm that NFS server is up and runing:


# systemctl status nfs-kernel-server
● nfs-server.service - NFS server and services
Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset:
enabled)
Active: active (exited) since Mon 2017-06-05 14:20:17 AEST; 1min 8s ago
Main PID: 1752 (code=exited, status=0/SUCCESS)

linuxconfig systemd[1]: Starting NFS server and services...


linuxconfig systemd[1]: Started NFS server and services.

Export NFS directory


Next, we need to export NFS directory. This directory will be eventual mounted remotely, hence
accessible via NFS client host. For the purpose of this tutorial we create and export directory called
/var/nfs-export. First, create a new nfs-export directory:
# mkdir /var/nfs-export

For testing purposes also create an arbitrary text file:


# cd /var/nfs-export/
# echo LinuxConfig.org > file.txt
# cat file.txt
LinuxConfig.org

Once ready, used your favorite text editor and create a new NFS export entry within /etc/exports
configuration file. For example :
/var/nfs-export *(rw,sync,no_subtree_check,no_root_squash)

The above export will export /var/nfs-export directory to any host with any IP address with
read-write access. This is a highly unsecure export. For more NFS export examples enter $ man
exports.

To apply changes within /etc/exports configuration file, reload all NFS exports with:
# exportfs -ra

The command showmount -e lists the available shares on your local machine (NFS
Server). The out
# showmount -e 127.0.0.1

If you wish to start your NFS server after reboot, you need enable it with systemctl systemd
command:
# systemctl enable nfs-kernel-server
Synchronizing state of nfs-kernel-server.service with SysV service script with
/lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable nfs-kernel-server

NFS Client
Now that the NFS export directory is available to a remote mount. Let's install NFS client on our client
system:
# apt-get install nfs-common

Create a new directory which will be used as a NFS mount point to remotely mount previously
exported /var/nfs-export directory:
# mkdir /mnt/nfs

he command showmount -e lists the available shares on your local machine (NFS Server). The out

# showmount -e 192.168.0.5

Mount remote NFS export directory:


# mount -t nfs 192.168.0.5:/var/nfs-export /mnt/nfs/

ou can also use df command to check the mounted NFS shares.

# df -hT

Automount NFS Shares

To mount NFS shares automatically on every reboot, you need to edit /etc/fstab file on your client
system.
vi /etc/fstab

Add the below line at the end of the file.


192.168.1.10:/nfsshare/ /mnt/share nfs rw,sync,hard,intr 0 0

Save and close the file.

Reboot the client machine and check whether NFS share is automatically mounted or not.
reboot
Verify the mounted share on the client-server using the mount command.
mount | grep nfs

• La segunda será una lista de opciones para compartir. Entre las opciones que podemos utilizar,
se encuentran las siguientes:
• ro(read-only): La carpeta compartida será de sólo lectura. Es la opción predeterminada.
• rw (read-write): El usuario podrá realizar cambios en el contenido de la carpeta
compartida.
• wdelay: El servidor NFS no escribe en el disco si espera otra solicitud de forma
inminente. Así se reducen los accesos a disco y mejora el rendimiento. Es la opción
predeterminada, pero sólo funciona cuando usamos la opción sync.
• no_wdelay: Deshabilita la característica anterior.
• root_squash: Evita que los usuarios con privilegios administrativos los mantengan, sobre
la carpeta compartida, cuando se conectan remotamente. En su lugar, se les trata como a
un usuario remoto más. Es la opción predeterminada.
• no_root_squash: Deshabilita la característica anterior.
• sync: Evita responder peticiones antes de escribir los cambios pendientes en disco. Es la
opción predeterminada.
• async: Deshabilita la característica anterior. Mejora el rendimiento a cambio de que
exista el riesgo de corrupción en los archivos o, incluso, en todo el sistema de archivos,
si se produjese una interrupción del fluido eléctrico o un bloqueo del sistema.
• subtree_check: Cuando el directorio compartido es un subdirectorio de un sistema de
archivos mayor, NFS comprueba los directorios por encima de éste para verificar sus
permisos y características. Es la opción predeterminada.
• no_subtree_check: Deshabilita la característica anterior, lo que hace que el envío de la
lista de archivos sea más rápido, pero puede reducir la seguridad.

You might also like