How to mount your media server or NAS drive to a Raspberry Pi

[su_button url=”https://trendblog.net/raspberry-pi-basic-headless-setup-without-cables/” style=”flat” background=”#00aeef” size=”5″ center=”no” radius=”0″]<– PART 3[/su_button] [su_button url=”https://trendblog.net/install-sonarr-and-nzbget-for-total-tv-show-automation/” style=”flat” background=”#00aeef” size=”5″ center=”no” radius=”0″]PART 5 –>[/su_button]

In the fourth part of our series “Automatically download TV show episodes as soon as they are available”, we’ll show you how to mount (or connect) a home/media server, also called NAS (network attached storage) to your Raspberry Pi. The benefit of this procedure is that all downloaded episodes on your Raspberry Pi will be automatically moved onto your NAS. If your TV or streaming device (e.g. Amazon Fire TV, Kodi) is connected to your media server, then you can access and watch new episodes without lifting a finger.

Enabling NFS sharing protocol on your NAS

Now, before we mount your media server to your Raspberry Pi, you need to make sure that NFS sharing is enabled on your server. NFS stands for Network File System and allows your NAS to share directories with other clients and programs over a network. They can access, add and edit files on your server as if they were stored on them locally.

How do you do that? Well, that depends on the media server. Covering all popular NAS servers would be beyond the scope of this guide. As always, Google is your friend. Since I mentioned the WD MyCloud server before, I will go through the process based on that model as an example.

  1. Go to the MyCloud dashboard at http://wdmycloud.local/UI/.
  2. Go to Settings and select Network in the left sidebar menu.
  3. Under ‘Network services’, switch SSH to On and write down the username and password in the pop-up window
  4. Open up your terminal / command line on your computer and SSH into MyCloud. What?? Don’t panic, it’s actually quite easy. In your terminal or command line window, type in
    ssh root@MYCLOUDIP

    Replace the last part with your server’s IP, which you can find in Settings > Network. Now, type in the password you wrote down earlier. Now you’re logged in. Don’t do anything you don’t understand here as this could deal serious damage to your NAS.

  5. Once logged in, open the exports file by typing the following
    sudo nano /etc/exports

    Add the following line at the bottom of the text editor

    /nfs/SHAREDFOLDER 192.168.0.0/24(rw,subtree_check,secure)

    Replace SHAREDFOLDER with an existing folder on your MyCloud that you want to be shared (e.g. /nfs/TVShows). Also, replace the IP address (192.168.0.0) with your network’s IP. If your router’s IP is 192.168.1.0, for example, then replace the third number with ‘1’. The last number should stay ‘0’.
    Save the changes with CTRL + X, then hit ‘Y’ and ‘Enter’.

  6. That should be it. Remember that this is an example for the MyCloud NAS from Western Digital. If you have a different device, then search for instructions on Google.

Mounting your NAS to your Raspberry Pi

Alright, let’s get to it. For demonstration purposes I will use the following as the IP address of your NAS: 192.168.0.50. Obviously, you need to replace that with the correct one. Another assumption is that the folder on your NAS that should be shared with your Raspberry Pi is named ‘TVShows’ and is located in your MyCloud’s root folder.

  1. Log into your Raspberry Pi (SSH into it). If you don’t know what this means, check out the previous part of this guide.
  2. Now we need to create a folder on your Raspberry Pi that will be connected with the TVShows folder on your NAS. Create this folder with the following line
    sudo mkdir /home/pi/TVShows

    To keep things easy I chose /home/pi/ as the directory and the same folder name as on your NAS. Feel free, however, to use a different location or name.

  3. Open the fstab file in the nano text editor by typing the following
     sudo nano /etc/fstab
  4. Copy and paste the following line at the bottom
    192.168.0.50:/nfs/TVShows /home/pi/TVShows nfs nouser,atime,auto,rw,dev,exec,suid 0   0

    Make sure to use the correct IP address of your NAS and to correct the folder locations and/or name if you chose something different. If you want to add a second folder (e.g. /nfs/Movies) then simply add the same line under the first and replace the folder name.

    Save the file with CTRL+X, then ‘Y’ and ‘Enter’.

  5. Now, we need to mount all partitions that are in your fstab file. Execute the following
    sudo mount -a

    If this process is successfull then you should see nothing but a new empty line. Several people with a Raspberry Pi Model 2 encountered a problem at this step. They got a message saying that the mounting process wasn’t successful. What helped most of them was to execute the following:

    sudo rpcbind start

    This should spit out something along “Starting rpcbind   [OK]”. Now, repeat the sudo mount -a command.
    More info about that solution can be found here.

  6. That’s it. Now, whenever you place something into the TVShows folder on your Raspberry Pi, it will show up in the TVShows folder on your NAS.

Alright, if you followed all parts of the guide, then you have a working Raspberry Pi which is connected to your media server. All downloaded media will be automatically moved onto the NAS and can be easily watched on your TV and other connected devices.

In the next and last part we’ll give you the resources to install and set up the Usenet downloader NZBGet and Sonarr on your Raspberry Pi.

[su_button url=”https://trendblog.net/install-sonarr-and-nzbget-for-total-tv-show-automation/” style=”flat” background=”#969899″ size=”5″ center=”yes” radius=”0″]PART 5[/su_button]

9 Comments
  1. Jared Kindred says

    This works perfectly for me to access my public share. Although it doesn’t work for private shares.

    Do you know how to go about adding my username and password to the /etc/fstab file to get private shares to work?

    Thanks,
    Jared

    1. Dilip says

      try this

      192.168.0.50:/nfs/TVShows /home/pi/TVShows nfs user=USERNAME, passwd=PASSWORD,atime,auto,rw,dev,exec,suid 0 0

      1. Àlex says

        That won’t work 🙁

  2. John Reasor says

    Thank you this was very helpful.

  3. Tom says

    If you’re editing /etc/fstab and you have drive names, username, passwords, etc. which contain spaces, you may want to try replacing the spaces with ’40’ as escaping backslashes and quotes doesn’t seem to be permitted in the fstab file

  4. Dimitrij Oksana Spasow says

    Hi, my problem is, that pi don’t mount at boot. I must type “sudo mount -a” at restart.

  5. Àlex says

    How do I mount password protected folders?

  6. Raphael says

    I get the error mounting process wasn’t successful because rpc.statd is not running. When I enter sudo rpcbind start I am returned to the prompt but the same error comes up again? So I am stuck

  7. Jared Kindred says

    It would appear that after the last my cloud update that this no longer works. I have tried everything that I can to get this to work and I am stuck. Any updates from anyone else?

Comments are closed.