In Debian and Ubuntu Linux, you can set up an NFSv4 file server to share files with other systems on the network. Here are the basic steps to set up an NFSv4 file server:
- Install the NFS server software by running the following command:
sudo apt-get install nfs-kernel-server
- Create a directory that you want to share over NFS. For example:
sudo mkdir /srv/nfs
- Add the directory to the
/etc/exports
file. This file contains a list of directories that are exported by the NFS server. For example:
sudo nano /etc/exports
/srv/nfs *(rw,sync,no_subtree_check,no_root_squash)
The options in the parenthesis are:
rw
: allows read and write access to the shared directory.sync
: ensures that changes made to the shared directory are immediately written to disk.no_subtree_check
: speeds up directory lookupsno_root_squash
: allows the root user on the client systems to have the same level of access to the shared directory as the root user on the server.
- Start the NFS service:
sudo systemctl start nfs-kernel-server
- Enable the NFS service to start automatically at boot time:
sudo systemctl enable nfs-kernel-server
- On the clients, install the NFS client software:
sudo apt-get install nfs-common
- Mount the shared directory on the clients:
sudo mount server_ip:/srv/nfs /mnt
- You can check if the mount was successful by running
mount
command and looking for the entry of the NFS share in the output or byls /mnt
Please note that the above steps are a basic setup for NFSv4 and for more secure and robust setup please consider setting up firewall rules, setting up authentication and authorization and also implementing a backup strategy.
Also, it’s good practice to test the NFS setup with a small set of files and users before deploying it to a production environment.