5 steps in mounting a shared NAS folder to a Raspberry Pi

Mounting a shared NAS folder onto a Paspberry Pi
Published: by
Last updated:

Network Attached Storage (NAS) devices are popular to add large amounts of data storage space to a network. A networked Raspberry Pi can also make use of this storage to, for example, make use of its space or to have access to its files. 5 steps in mounting a shared NAS folder to a Raspberry Pi will go through the process using NFS (Linux Network File System).

Assumptions & requirements

All the steps, including the mounting command and making the process automatic after boot-up, will be done from the terminal. The process can also be done through PuTTY.

With this post, it is assumed to have an up and running Raspberry Pi with Raspbian installed. Root (sudo) permissions will be necessary. The NAS and the Raspberry Pi is connected to the same network (LAN) via Ethernet or Wi-Fi (not USB).

It is also assumed that the NAS folder (directory) to be mounted is already shared and broadcasted on the LAN. On most NAS devices, folders can be shared on a network using NFS. Other NFS-related settings that might be relevant, e.g. IP (host) filtering and read/write permissions must also be conducive to the purpose of the shared folder. NAS systems with a static IP address will make the process more permanent to maintain.

Note: Not all NAS devices have the ability to grant access to a Raspberry Pi through NFS. Connecting to newer NAS devices, that uses the NFS4 protocols, will not need a different method for connecting and will not be discussed in this post.

The following steps are to be done on the (target) Raspberry Pi.

Step 1 Installing the software

Installing/updating the required packages:

sudo apt-get install nfs-common
sudo apt-get install portmap

nfs-common contains the showmount command.

Step 2 Create the local mount directory

Any mount directory can be used, but Raspbian has a very convenient /mnt directory recommended being used as a central mounting point.

Assuming the Raspberry Pi’s mount directory was decided to be /mnt/music, it can be created with the following terminal command:

sudo mkdir /mnt/music

Note that the Linux directory structure is case sensitive. Different user permissions/ownerships can be used, but to make the directory accessible to all users on the network use:

sudo chmod -R 777 /mnt/music
sudo chown pi:pi /mnt/music

Step 3 Run rpc.statd

rpc.statd is a little daemon script that ‘listens’ for a reboot notification from other hosts and tells other hosts when the Raspberry Pi reboots. It manages mounted drives after the drive was rebooted. In older versions, it was automatically included in the Raspbian boot sequence, but apparently to save space and time it was excluded in later versions.

To run rpc.statd use the following terminal command:

sudo service rpcbind start

To automatically include this daemon in the Raspbian boot sequence, use:

sudo update-rc.d rpcbind enable

and to remove rpc.statd from the Raspbian boot sequence, use:

sudo update-rc.d rpcbind disable

To stop the rpc.statd service, use:

sudo service rpcbind stop

The rpc.statd service only needs to be added to the boot sequence once.

Step 4 Collect the correct data for the mounting command

The following information will be necessary for the mounting command:

  • NAS device’s IP address: 192.168.1.xx
  • The local mounting directory created in step 2 (/mnt/music)
  • The shared folder from the NAS device to be mounted

The showmount command will list all the NAS device folders that are shared through NFS:

showmount -e 192.168.1.xx

where 192.168.1.xx is the IP address of the NAS device. Some NAS devices will also be able to give the shared folder address on the folder sharing section.

Step 5 Run the mount command

Assuming the NAS shared folder address is /shares/Music, The NFS Mount command is used as follows:

sudo mount -t nfs 192.168.1.xx:/shares/Music /mnt/music

which will mount the NAS’s /shares/Music directory to the Raspberry Pi’s /mnt/music directory.

To unmount the device again, use:

sudo umount /mnt/music

where /mnt/music is the local Raspberry Pi directory. Unmounting will only take place when outside the mount directory.

Additional step – Mount at boot

To automatically mount a shared folder during the boot sequence of Raspbian, the mounting command can either be added to Crontab or the rc.local file.

To add the mount command to the rc.local file use:

sudo nano /etc/rc.local

and add the line from step 5 to the bottom of the file.

For Crontab, use:

crontab -e

and add:

@reboot sudo mount -t nfs 192.168.1.xx:/shares/Music /mnt/music

Errors & solutions

NFS Stale File Handle error

Sometimes, while trying to use the NFS Mount command, the following error is displayed:

mount.nfs: Stale NFS file handle

This NFS Stale File Handle error occurs if the directory is modified on the NAS server, but the directories modification time is not updated on Raspbian. To fix this issue, try unmounting the directory and remount it again.


To get started with the Raspberry Pi and Ethernet cable, you might need some of the following accessories.

Please support us by using these links - they come at no additional cost to you, but we get a little commission each time they are used. These and others are available from Amazon.com and BangGood.

We have tested most of these products ourselves. Other selection criteria include affordability, quality, availability and average user rating and popularity by other buyers.

Links will open in a new window.
(Dead or old links can be reported in the comments section below.)

Behind the Scenes is a free, informative website. If you find value in any of our content, please consider making a donation to our cause.
Donate via PayPal

Save, share & discuss

Your comment is important, but don't be a knob. Keep it constructive and polite.

6 thoughts on “5 steps in mounting a shared NAS folder to a Raspberry Pi”

  1. Hi Renier,
    I am also getting the message:

    clnt_create: RPC: Unable to receive

    when I enter the “showmount” command.
    I have successfully pinged the NAS drive, which is a Synology DS414. The nfs-common and portmap packages were installed successfully.

    Any help would be gratefully received.
    Thanks in anticipation

    David Robottom

  2. Have you installed nfs-common and portmap successfully? SMB uses different connection software. Also, the storage device needs to be ‘NFS compatible’. If you can manage SMB connections, you can also try https://behind-the-scenes.net/sharing-a-raspberry-pi-directory-on-a-local-area-network/ (I haven’t written anything specific, but with SAMBA installed on the Raspberry Pi you will have better success in connecting to the storage device using SMB commands.

Leave a Reply

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

More Raspbian related posts

Using the Raspberry Pi as a home web server
Using the Raspberry Pi as a home web server
18 January 2016 | Updated 19 November 2017
A web server is a computer that can send and receive data via a web browser. It uses, the very popular, Hypertext Transfer Protocol (HTTP), the basic network protocol used to distribute information on the internet. More…