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.
- Go to the MyCloud dashboard at http://wdmycloud.local/UI/.
- Go to Settings and select Network in the left sidebar menu.
- Under ‘Network services’, switch SSH to On and write down the username and password in the pop-up window
- 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
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.
- 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
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’.
- 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.
- Log into your Raspberry Pi (SSH into it). If you don’t know what this means, check out the previous part of this guide.
- 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.
- Open the fstab file in the nano text editor by typing the following
sudo nano /etc/fstab
- 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’.
- 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.
- 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]