So I have just moved into a nice new house and it has inspired me to clean up my tech mess. Currently I have two old PCs which I have stripped down and re-purposed as a torrentbox (including Network Attached Storage (NAS)) and a Media PC. They look terrible, use up a heap of space and use way too much power.
While moving house I found a couple of Raspberry Pi 2’s I forgot I had bought. I was going to use them on my electric car project. As they aren’t needed anymore (thanks to some smart work with a couple of PIC chips) I’m going to use these as a low powered NAS/torrentbox and the other as a Media PC replacement.
To make it easier (mostly for me writing this post) I’ll break up this instructable into four parts:
- Building a Raspberry Pi NAS box (this post);
- Building a Raspberry Pi torrent box;
- Automating your torrent downloads; and
- Building a Raspberry Pi Media Centre.
Building a Raspberry Pi NAS Box
What you need
To build your Raspberry Pi NAS you are going to need the following:
- Raspberry Pi (I’m using a Pi 2);
- Raspbian imaged (Micro)SD card;
- USB Hard drive; and
- Powered USB Hub (you will need this if your Pi can’t power your hard drive).
Before starting this project you are going to want to flash a new Raspbian image for your Pi. If you don’t know how to do this you can find one of my previous posts – here for Windows or here for Macs – these posts will walk you though the process.
Because this Pi NAS is going to be headless we are also going to have to ensure we have SSH setup on our Raspian images. If you don’t know how to do this you can check out my post here (I’ll write this up soon!!) to find out how to get it done.
Mounting the USB Hard Drive
Now we have everything ready to go lets get started. The first thing we need to do is format and setup our USB hard drive so it auto-mounts. I also want to use NTFS. To do this we will need to add in NTFS support for Raspbian. To install this use this command:
sudo apt-get install ntfs-3g
Next we want to find out the unique id of your hard drive. to do this type in the following command:
ls -l /dev/disk/by-uuid/
You should see something like this:
We are looking for the the number associated with the ../../sda1 (or similar) tag – note this number down. In my case it is A23CB9FFA23CBA2F.
Now we are going to need to create a directory to use as our mount point. use:
sudo mkdir /media/NAS
Now I am using the default pi user so I’ll keep on using this. We need to make sure that this User owns our new directory. To do this we use the following command:
sudo chown -R pi:pi /media/NAS
We could now go ahead and manually mount our USB hard drive but I want it to Auto Mount. To do this we need to change fstab. First make a copy of fstab (just in case we stuff it up) with:
sudo cp /etc/fstab /etc/fstab.old
Open up fstab in nano with the following command:
sudo nano /etc/fstab
And put the following line at the bottom of the file (make sure you use your copied UUID number):
UUID=A23CB9FFA23CBA2F /media/NAS auto,users,rw,uid=pi,gid=pi 0 0
Mine looks like this:
once you have finished exit with Ctrl-X and select Y. Now reboot with:
and your USB Hard Drive will now automatically mount every time.
Creating a Samba Share
To access our USB Hard Drive remotely we are going to need to share it across our home network. To do this I am going to use Samaba as it plays nicely with my Raspberry Pi’s and my Windows box. Firstly, install samba:
sudo apt-get install samba samba-common-bin
Next lets make a copy of the old Samba config file (again just in case we stuff up):
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old
Now we have done that we can dive into the Samba config file with nano and make the changes required so we can access our USH drive remotely.
sudo nano /etc/samba/smb.conf
You are going to want to scroll to the bottom of the file and copy in the something like the following:
comment=Raspberry Pi Share
I’ve put a screen shot of the end of my smb.conf below:
Don’t forget to change the header to what you want to call the share – in my case I have called it “torrentbox”. Also change the path to whatever your mount point was – in my case it is /media/NAS.
Once you have finished exit with Ctrl-X and select Y as before. Now reboot samba with:
sudo /etc/init.d/samba restart
To keep this simple we are going to set the samba password to be the same as the default login for your Pi i.e. the one you use for SSH access. Type in the following command:
sudo smbpasswd -a pi
Now type in raspberry twice as prompted and we are ready to test out if our NAS works! You can choose a different password and user if you want but don’t forget to add that user in to your default Pi User list.
I’m going to use my windows box with windows 10 installed to test out our share. First open up a file explorer window (I like to use th eWindows Key + E shortcut) and you will see something like this:
Select Network on the left hand side and you should see RASPBERRYPI – double click on it and you will see something like the following:
and Bobs your Auntie your NAS box is up and running!!
That completes this part of the series and you should now have a working NAS. The next part is dealing with setting up a torrent client on your NAS and you can find it here (well once I write it up!!). If you want to jump straight into using our NAS box with a Raspberry Pi media Centre you can find that part here (again I’ll link it once I have written it)
Let me know how your Pi NAS went!!