How to Set Up a Raspberry Pi NFS Server?

Setting up a Network File System (NFS) server on a Raspberry Pi allows you to share files and folders over a network. This guide will walk through the entire process of installing and configuring an NFS server on Raspberry Pi OS.

How to Set Up a Raspberry Pi NFS Server?

What is NFS and Why Set It Up on Raspberry Pi

The Network File System (NFS) is a distributed file system protocol that allows a user on a client computer to access files over a computer network in a manner similar to how local storage is accessed.

Here are some of the main advantages of setting up an NFS server on a Raspberry Pi:

  • File sharing – Once set up, NFS allows files and folders to be shared with client devices on the local network. This enables central file storage that can be accessed from multiple devices.
  • Lightweight – The Raspberry Pi uses very little energy and has a small footprint, making it well-suited for always-on server applications like NFS.
  • Versatile – The NFS server can be accessed by Linux, macOS, and Windows computers, making it a cross-platform network file sharing solution.

By the end of this guide, you will have a fully functioning NFS server on your Raspberry Pi that can be accessed from other devices on your local network.

Equipment Needed

Before getting started, you will need the following:

  • A Raspberry Pi board running Raspberry Pi OS (previously called Raspbian). Any model will work.
  • MicroSD card loaded with Raspberry Pi OS.
  • Power supply for the Pi.
  • Network cable to connect the Pi to your router or an enabled WiFi adapter.
  • The Raspberry Pi and client devices should be on the same local network.

Step 1 – Install NFS Server on Raspberry Pi

Log into your Raspberry Pi board if it isn’t already and open the terminal application.

Update the package repository and installed packages by running:

sudo apt update

sudo apt upgrade

Install the NFS server components by running:

sudo apt install nfs-kernel-server

Step 2 – Make a Shared Directory

Next, we will make a directory that will be shared publicly across the network.

Run the following to create the new directory:

sudo mkdir /mnt/nfs_share

Set open permissions on the new share directory:

sudo chmod -R 777 /mnt/nfs_share

The directory is now ready to share out.

Step 3 – Configure NFS Exports and Shares

We need to define which folders to export from our NFS server. This is done by editing the exports file.

Open the exports file in nano:

sudo nano /etc/exports

Add the following line to share the nfs_share folder we made earlier:


Breaking down this exports configuration:

  • /mnt/nfs_share – The folder being shared
  • – The subnet in CIDR format allowed access, change for your network
  • (rw,sync,no_subtree_check) – Set read/write, sync for all clients, and disable subtree checking

When done editing exports, save the changes in nano using CTRL+X, Y, then Enter.

Finally, restart NFS to load the new configuration:

sudo systemctl restart nfs-kernel-server

The Raspberry Pi NFS server is now ready for clients to connect!

Step 4 – Connect to the Raspberry Pi NFS Share

On the client Linux/macOS/Windows devices that you want to access the NFS share, connect to the Pi’s IP address and share directory using the following command syntax:

sudo mount -t nfs <Pi’s IP>:/mnt/nfs_share /local/mount/point

For example:

sudo mount -t nfs /local/nfs_share

Users can then navigate to the local mount point directory to view files served from the Pi NFS share.

On Windows, mapping network drives can also be done through File Explorer instead of the command line.

Key Takeaways of Setting Up Raspberry Pi NFS

Some key takeaways of this Raspberry Pi NFS server guide:

  • By installing the NFS server components and properly configuring the /etc/exports file, folders on the Pi can be publicly shared over local networks.
  • Setting correct file permissions is crucial to enabling public access. The chmod command is used to set R/W permissions.
  • The exports file defines the shared folders, allowed IP addresses, and access parameters clients will have.
  • Once configured, connecting devices can mount the Pi’s NFS shared folders using the standard mount command.

Overall, setting up an always-on Raspberry Pi NFS server provides an excellent network attached storage and file sharing solution.


Setting up an NFS server on Raspberry Pi enables easy and central file access from any device on your local network. It serves as a lightweight, flexible, and low-power solution perfect for the Pi.

With just a few commands, shared folders are exported and connections are made from Windows, Mac and Linux computers. Whether needing more storage space or central file access, the Raspberry Pi makes for an excellent platform to host NFS shares.

Frequently Asked Questions

  1. What is the default NFS port?
    The default port is TCP 2049.
  2. Do I have to enable any services for the NFS server to work?
    You need the RPC bind service running. This is enabled by default on most Linux distributions.
  3. Is using a Raspberry Pi better than a NAS (Network Attached Storage)?
    For simple sharing between a few devices on a home network, the Raspberry Pi works very well as an affordable, low-power alternative. Commercial NAS devices have more capabilities for business networks.
  4. Can the Raspberry Pi handle multiple connected NFS clients accessing different shares?
    Yes, certainly. The Pi can handle dozens of lightweight connections without issue. For very heavy loads consider using a dedicated NAS appliance.
  5. How intensive is serving files over NFS for the Pi CPU and RAM usage?
    It’s not that intensive for general file serving. Performance will vary based on how many concurrent connections and the file sizes/types being transferred.
  6. Does the Raspberry Pi NFS server encrypt data and connections?
    By default, no encryption is implemented. Look into stunnel TLS or SSH tunneling for encrypted NFS if security is a concern.
  7. Can I use Samba/Windows file sharing instead of NFS for sharing files from the Pi?
    Absolutely. Samba better integrates sharing files from Linux to Windows devices, while NFS is better for Linux/UNIX clients.
  8. Will connecting a USB hard drive work for sharing more storage space?
    Yes, attaching an external drive will provide more shared storage capacity, access speeds will depend on the drive speed.
  9. Can you limit access per exports share depending on client IP address?
    Yes. Within /etc/exports you define IP addresses or ranges under each share to allow listing only certain client IPs.
  10. Is there a way to get faster read/write performance?
    Enabling sync writes, as shown in this guide, will improve write speeds. Using higher speed networking will also help significantly.
  11. Can I directly edit files on the Raspberry Pi over NFS shares?
    Yes! NFS exporting folders as read write enables seamless remote editing just as if the files were local.
  12. Where should shared NFS folders be located within the Raspberry Pi filesystem?
    Generally within the /mnt directory. This area stores mounted volumes, ideal location for shared network folders.
  13. What user permissions are required to configure and manage NFS exports?
    Root user access is required for managing all services, folders, and files associated with NFS shares and exports.
  14. What logs messages should I check if having issues with failed mounts?
    Relevant logging and troubleshooting can be found in /var/log/syslog pertaining to the nfs kernel server.
  15. Is there a limit to how many files can be stored on the NFS share?
    No set limit, available storage capacity depends on the SD card or external drives attached. Billions of files possible.
  16. Can different operating systems use the same NFS shares simultaneously?
    Yes definitely. Excellent cross-platform support with Windows, macOS and Linux able to concurrently access the same shares.
  17. Can I configure multiple exports to share different folders on my Pi NFS server?
    You can export as many unique folder shares as needed within /etc/exports, granting access selectively per share as desired.
  18. What permissions should I set so that all clients have full access?
    Use permissions 777 to enable full read, write, execute access for all users. Set ownership to nobody/nogroup.
  19. How do I stop and start the NFS server daemon?
    Use sudo systemctl [stop/start] nfs-kernel-server to safely stop or restart the NFS server.
  20. What firewall ports need to be opened for NFS?
    TCP and UDP ports 111, 662, 875, 2049 need to be opened on local firewalls. 111 is critical for RPC communication. 

Leave a Comment