The perfect cheap DIY NAS – SAMBA server and PLEX on Raspberry Pi
SO … GDPR is inforcing, and why should I keep my personal photos on Google Photos, Dropbox, OneDrive, Box or similar? It’s my data and I want to keep ’em. That’s why I decided to create the perfect cheap DIY NAS, that anyone could set up with no real knowledge of Servers, Terminals, and code.
What do you need:
You probably have the most of the things underneath except for the Raspberry Pi – and its cheap, like $45 on eBay.
- Raspberry Pi (2B and above will do … But 3B+ is just a better choice) ~ $45
- Fairly fast 16GB SD card (usually comes with the Pi)
- USB Mouse or/and a USB Keyboard
- HDMI Screen
- USB powered Hard Drive ~ $50
- Internet Router with a free LAN port
- LAN internet cable
- A PLEX Player (I use Apple TV 4G, but you could use a Raspberry Pi)
And we don’t really care if we use MAC or windows as it’s all UNIX. Aint that great? 😀 If you are on a MAC, then just use the built-in Terminal. If on Windows install the PuTTY tool from here.
Setting up your perfect cheap DIY NAS
First, we should install Raspbian on your SD Card. I have experienced that installing it from the Raspbian image is quite slower in performance in comparison to installing Raspbian with NOOBS. So grab your copy from the Raspberry Pi webpage here. Dont get the “LITE” version.
Download the NOOBS package and unzip it. Then copy all the files directly to your SD Card (pre formatted to FAT).
After that, insert the SD Card in the pi, connect the Pi to a mouse or/and keyboard and to the screen and internet LAN connected to the router. And finally, turn it on.
In my experience, a great power supply (the one that comes with the Pi) is always the better choice, as power always should be stable in order to make the pi bulletproof in performance.
When the Pi boots up, you’ll see this screen. It’s preselected the Raspbian OS. Just click it and then the (quite long) install process will start.
Sit back and enjoy a coffee.
Turn on SSH
Wuhuu! Raspbian is installed successfully and we can get to work, installing Apps on the Pi. But in order to do that I’d recommend setting up SSH, so you can access the Pi from your other computers. The rest of the guide can be done only on the Pi though.
In order to enable SSH: Go to menu -> Prefrenced -> Raspberry Pi Configuration -> Check the enable under SSH as shown underneath. Click OK.
Now SSH is enabled. We only need to find the IP of the new Pi. Do that by (in the Pi) open terminal and type:
Or if you only have a mouse, you can find the Ip through the router that the Pi is connected to under LAN connections. Alternatively, you can use one of many IP scanners.
Now you can with your Mac or Windows (PuTTY) connect to the Pi and start doing awesome stuff.
On mac open terminal and enter
You will be prompted for the password to Pi, and the default is “Raspberry” (we should change that asap).
On windows, open PuTTY and create a new profile. Use the IP of the PI and click connect. Then you will be prompted for the user and password. Same as above. Username = pi and Password = Raspberry.
Now we are in – so let’s start changing the password. Simply type:
sudo passwd pi
You will be asked to type your new password in two times. Do that. And voila! Password changed.
Setting up SAMBA (SMB) for filesharing
When logged in to the Pi with SSH lets install SAMBA bu typing in:
sudo apt-get install samba samba-common-bin
It’ll take some time. If asked to continue; type y and enter to proceed.
Now we need to let our user access the shared folders, so we should set up a password for the user pi in Samba also. Type:
sudo smbpasswd -a pi
Now let’s plug in the Hard Drive be USB. Give it a minute to detect. To see where it is mounted, type:
Find the line with /dev/sa1/ and you can see where it is mounted. Usually, it’s in /media/pi/<name of your disk>
That path, we need to remember. Write it down.
Now we need to let SAMBA know where to store files? It’s in the Hard Drive of course. So let’s edit the conf-file of SAMBA:
sudo nano /etc/samba/smb.conf
NB: I use the nano editor, but you can use whatever you’d like.
In the file, make sure these parameters are set:
workgroup = WORKGROUP wins support = yes
And add these lines at the end of the file:
[YourNamedPiShare] comment=Raspberry Pi Share path=/media/pi/name-of-your-Hard-Drive browseable=Yes writeable=Yes only guest=no create mask=0777 directory mask=0777 public=no
Enter ctrl+X to save. Type Y+enter to agree to save.
Now your SAMBA server is running and you can start to access it through both Mac and Windows.
Easiest is on mac. Here he “YourNamedPiShare” you entered above will automatically appear in your networks in the Finder. Connect to it with the user pi and your selected SAMBA password.
On windows, you need to do a little something more. Here you need to navigate to your computers pathfinder and to your computer. Click the “Add a network place” and select the “Choose a user-defined network place”.
After inserting the path of the SAMBA (eg “\\<Raspberry Pi IP>\YourNamedPiShare” fx: \\192.168.1.22\YourNamedPiShare) – you’ll be prompted to login. Just use the user pi and the password you have created for the pi to log in.
Yeppii! It works. You have a SAMBA server installed, where you can store all your files and access it from all computers in your crib.
Now we only need to be able to use all your movies and music in our media center. Let’s install PLEX Media server also!
Install PLEX Media Server on Raspberry Pi
Now lets install PLEX. It’s a straightforward process like installing Samba, but we need to able to read https repositories. So we’ll start installing the ability to do that. Type:
sudo apt-get install apt-transport-https
Then we need to aff a crypt-o-key to that:
wget -O - https://dev2day.de/pms/dev2day-pms.gpg.key | sudo apt-key add -
Now we need to add the dev2day repository to our package source list.
echo "deb https://dev2day.de/pms/ jessie main" | sudo tee /etc/apt/sources.list.d/pms.list
Then we need to update our package list – which will install the plex server, as we just added the package to the repository:
sudo apt-get update
Now lets edit the config of the Plex Media server:
sudo nano /etc/default/plexmediaserver
Add the line underneath to tell Plex that the user pi, may use the server:
Restart the server after the edits:
sudo service plexmediaserver restart
Finally lets set a static IP, so that It cant change over time. Remember the IP? Else get it by:
Insert it into this file in a new line:
sudo nano /boot/cmdline.txt
in the bottom line insert your IP like this:
To save – Type ctrl+X. Confirm typing Y and then Enter.
In the end – just reboot in order to make sure everything works:
Access your new server through your favorite web browser, typing your Pi’s IP followed by the port of the media server, 32400:
You’ll need a profile to log in. After that, you can start setting up your library from your Hard Drive, that you can transfer movies, music and series to through SAMBA.
In my research, I found that PLEX won’t find files in the default location of your mounted hard drive. Therefore we could mount it in another place. Fx. at /media/plex. But that folder does not exist. So let’s create it:
sudo mkdir /media/plex
That’ll create the folder. Check it by typing:
cd /media/ ls
Type “cd” agin to get to root.
If it’s listed here – then we need to mount your Hard drive to that folder. Do that by entering:
sudo mount /media/plex
Now it should be recognized by plex plyers. Eventuall,y you need to mount th drive into the plex-foldedr everytime you restart your Raspberry Pi NAS/Media Center.