NFS (Network File System) is a protocol for sharing files over a network. It allows a user on one host to access files on another host as if they were local files, and enables file sharing between systems running different operating systems. NFS is typically used in Linux and UNIX environments, and is supported by most modern operating systems.

To ensure that a Raspberry Pi is up to date, open a terminal window on the Raspberry Pi and run the below command to update and upgrade any outdated packages to their latest version.

sudo apt update -y
sudo apt upgrade -y

It could take some time to complete depending on the number of packages that need to be updated.

Now install nfs-kernel-server package on the Raspberry Pi.

sudo apt install nfs-kernel-server -y

Check the status of nfs-kernel-server service, you can run the below command. Make sure the service is active and running,

sudo systemctl status nfs-kernel-server

Create a directory to share: Use the command mkdir to create a directory that you want to share over the network. For example,

sudo mkdir /share
sudo chown pi: /share
sudo chmod 755 /share

Edit the exports file: The exports file is used to define the directories that are shared and the clients that are allowed to access them. You can use the command sudo vim /etc/exports to open the exports file and add a line that specifies the directory you want to share and the clients that are allowed to access it. For example,

sudo vim /etc/exports
/share   *(rw,sync,no_all_squash,root_squash)

Use the command to reload the NFS service,

sudo systemctl reload nfs-kernel-server

Mount the shared directory on the client: On the client machine, use below command to mount the shared directory.

sudo mount <server-ip>:/share /mnt

This will make the files in the /share directory on the server available on the client in the /mnt directory.

Note: This is just a basic setup for NFS, there are more options to configure and secure your NFS server.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *