A Raspberry Pi is a great computer to set up a simple Samba sharing media server. It’s affordable, coming in at only £34 for the base model of the latest Pi (4 at the time of writing). Coupled with a large hard drive, often you’ll be able to easily put together a ~£100 media server. In this guide, I’ll go over setting up the Pi headlessly and connecting to it on Windows, MacOS and Linux, as well as setting up a Samba share that will allow you to connect to your media whilst you are on your local network.
Gathering the gear
Firstly, you’ll want to pick up a Raspberry Pi. I would suggest trying to pick up the highest RAM model you can afford – this will give growing space if you want to start running a few more intensive programs on your Pi. You’ll also want to get the Pi 4 over the 3B as it gives you ethernet gigabit and USB 3.0, which is much faster than 2.0 (good for your hard drive). I would also suggest getting heatsinks for your Pi – these are often around £10, and will allow your Pi to keep relatively cool without active cooling – very useful if you have it in your university dorm or where you sleep. You can get cases with fans, but these are often quite loud and high pitched, so I wouldn’t suggest it. A heatsink is perfectly adequate as we will mostly be using RAM and not much CPU power.
Pick up the official Raspberry Pi power supply. The Raspberry Pi is powered via a USB-C port, and you want a reliable power supply so it doesn’t switch off all the time.
You’ll need a micro-SD card for your Pi. I would suggest anything over 16 GB – don’t worry about formatting as that will be done automatically later in the guide.
You’ll also want to get a hard drive and a powered drive container. There are a few approaches to this. The reason you cannot simply plug a drive into the Pi is because the Pi cannot power drives via USB.
- You can choose to buy a powered USB hub, and plug hard drives into that. This means you can pick up the relatively inexpensive passport and other portable drives, and plug them into the hub that is plugged into the Pi. Whilst this could be cheaper than the option I went with (below), the disadvantage is the lack of high capacity drives that work this way.
- Purchase a hard drive, and a powered hard drive container. This will support much larger drives, and also give you a little more flexibility in your setup. In the feature you could purchase a hard drive bay as your storage needs grow, which will allow you to store huge amounts on your server.
Setting up the Pi
First, plugin your drive and format it to NTFS. You can do this by right clicking on the drive in Explorer, and then clicking on format. I am not sure how to do it on MacOS as I’m not a Mac user.
Now install Raspbian OS onto your Pi. You can download the image here, and I highly recommend you use Etcher to install it onto your SD. Etcher will format it all correctly for you, and it’s incredibly easy to use. Once you have Raspbian OS installed, go into the Boot directory of your Pi (the only accessible one) and create a file simply called
ssh, with no extensions. This will enable SSH for your pi meaning you don’t need to connect it to a monitor.
Plug in your external disk and an ethernet cable into your wifi. Log into your wifi settings, which is usually
192.168.0.1. Find your Raspberry Pis IP address – usually your Pi will be under the SSID of
Raspberry Pi. I would strongly suggest you give it a fixed IP, which will make connecting to it in the future easier as the IP will not change.
Now, enter your terminal and enter
ssh pi@YOURIP. SSH tells your computer you want to activate the SSH protocol, pi is your Raspberry Pi username, and YOURIP is the IP address your wifi gave you. When you get prompted for your password, enter
raspberry. If all is well, you should now be logged into your Raspberry Pi.
I would now strongly suggest that you change your accounts password. You can do this by typing
sudo raspi-config into SSH. Select the change password option, and set the password you want. You may also want to rename your Pi to something other than
RaspberryPi here too.
Now, we want to enable VNC. This will let us use the graphical interface of Raspbian. In the raspi-config menu, enter
Interfacing options, and then
VNC. Enable it. Restart your pi with
Download VNC onto your computer. When prompted, enter your Pi IP address, and the username and password. You should not see the desktop of the Pi, which should show a prompt to update packages. Click on start, and then wait for your packages to update – this may take some time. If you want, you can connect it to your wifi if you don’t have the ability to keep it on ethernet all the time, otherwise don’t bother. Now you have managed to log into your Pi graphical interface remotely, which will come in handy later.
Setting up Samba
Now let’s set up our Samba share. Go into your SSH window again, and enter the following command:
sudo apt-get install samba samba-common-bin. This will install everything that you need for Samba on your Pi. Make sure that your folder that you want to share via Samba is available, and then move onto the next step.
Now that Samba is installed, we want to point it to the folder that our external hard drive lives in. Enter
sudo nano /etc/samba/smb.conf into the SSH window. Jump to the bottom of the file by entering
CTRL + _, and then
CTRL + V. Now, you can set up your Samba share. Here is my one as an example:
[MSAdmin] path = /media/pi/Media server writeable = Yes create mask = 0777 directory mask = 0777 public = no
[MSAdmin]– This is the share name, which is used to login to the Samba share. For example,
//raspberrypi/msadmin. If you have changed your Pi name, it will be
path– This shows Samba what directory is to be shared. Here, I have pointed it to my external hard drive.
writeable– Can be changed if you want to give editing access or not.
directory mask– Gives maximum permissions for files and folders.
0777gives read, write and execute access. You can find out more about this here.
public– If you want anyone to access the share, you can set this to
yes. If you want a username and password to be required, you set this to
Once you have made the appropriate changes, save your config by entering
CTRL + X, and then
y and finally
Enter. If you want, you can add multiple of these with different permissions if you want to share certain folders with friends, or share your media server with your local network.
Finally, a user needs to be assigned to the Samba share. If you haven’t renamed your username, and it is still
pi, you can set the password by running
sudo smbpasswd -a pi, and then entering the password you want when prompted.
Once you have done this, restart Samba by running
sudo service smbd restart.
To view content on your server, as well as transfer content to it, it has to be connected to on your desktop or laptop. This will not only allow content to be streamed and edited, but also content to be uploaded from your local PC to your server.
If you want to download from the internet on the Pi, you can use VNC to use the Chromium browser that is built in with Raspbian.
To transfer via FTP, there are a few options. For users more experienced with command line, LFTP is a great FTP tool that supports segmented downloads. If you want a graphical interface, you can get Filezilla by running
sudo apt-get install filezilla. Then simply open it by typing
filezilla into the Run command in the Raspbian menu. LFTP will be quicker at downloading, so I would recommend to learn it.
Anyway, onto connecting the Samba share to your devices.
Open up File Explorer, then click on
This PC, followed by
Computer and then
Map Network Drive.
You will be prompted with the below screen. Fill in the appropriate details, and then click on finish.
You will then be asked to login. Enter your username, which will still be
pi if you haven’t changed it, and then the Samba password you set. Hit enter, and you should now be logged into your Samba share.
MacOS and Linux
If you want to watch stuff on your server on your phone or iPad, you can use Infuse 6 to connect to local Samba shares. Infuse is a really impressive media player, and I recommend it to anyone who watches stuff on their phone or tablet.
You can also use the slightly cheaper PDF Expert 6, which will let you connect to local Samba shares to browse and view files. It also supports video streaming.
You’ll now have access to all the files on your hard drive. You can browse and use files in your server on devices that are connected to your local network. If you have any issues, please feel free to comment below.