It’s a widely known fact that we are now creating more data each day than ever before. The data we produce is primarily digital which is great because it doesn’t take up physical space on your desk and requires minimal dusting. This shift has been hailed by those looking to simplify their lives because it means the number of objects that we need to buy, store, and care for has significantly decreased. For example, you no longer need to own a CD to listen to music, a DVD to watch a movie, or a newspaper to read the news.

Everything you produce on your computer, phone or tablet, however, needs to be physically stored somewhere. Each email sent, song listened to, or photo uploaded takes up very real space on a hard drive or a server. Once upon a time, most people were constrained by how much space their USB, computer, external hard drive or other device (like an iPod) had on it. In recent years, cloud storage has revolutionized the way that we store information, allowing people to upload a document (or photo or song) and be able to access it across any device. This has helped fuel our big data revolution and it’s likely that as storage space gets cheaper and easier to access we’ll continue to create even more data.

But using the cloud for storage has its downsides. From privacy concerns (yes, your data might be used to train machine learning algorithms without your consent) to ease of use, and cost, cloud storage hasn’t turned out to be the magic bullet it once promised to be.

Nevertheless, odds are you have digital data that needs storing ASAP. Luckily, there’s an easy and cheap solution to tidy your digital mess.

Enter the Raspberry Pi-fueled home server.

In this guide, we’re going to look at how to create your very own server, also known as wireless network-attached storage, that you connect to whenever you’re home and hooked up to your network. This means you can bring all of your digital stuff into one place and, at the same time, control all of your own data and with no subscription fee.

How to Create Your Own Server with Raspberry Pi

At the heart of this DIY is the Raspberry Pi 3 B+, which is effectively a pocket-sized computer that acts as the brain of your new digital file repository. With both WiFi and Bluetooth,

Unlike some of the earlier version, the Raspberry Pi 3 B+ comes fully equipped with both WiFi and Bluetooth which means it can easily communicate with your router or any other network attached devices you might have.

Alongside the Pi, a removable storage media (think high capacity USB external hard drive) handles the actual storing of your files – in exactly the same way as it would if connected directly to your computer. In this case however, our hard drive (and files) are connected to the Pi and will eventually be accessible from any other devices that is given permission.

When paired together, the Pi and the removable storage create a tiny, low-power, and affordable wireless server that acts as a repository for all of your digital stuff.

With this kind of setup in place, you’ll have a library for all of your files that can be accessed quickly and easily from any other computer on your network, at any time of the day. This means that you can stream your own music collection or movie library without having to use the storage space on your own computer or needing to plug in an external drive. It also allows you to have a dedicated sharing folder where you can seamlessly share documents, photos or other files to other computers on your network without sending email attachments or exchanging USB sticks.

All in all, it’s definitely worth spending an hour or two setting up your own server. It’s easy, cost effective and will make you sound really cool.

Essential Tools

To get building your own server, there are a few bits of hardware you’ll need first.

You will need:

Raspberry Pi 3 Starter Kit

There are a few excellent starter kits out there which come complete with everything you need to get your Raspberry Pi up and running, right out of the box. The biggest advantage of these kits is that they include all of the components for assembling the Pi, starting it up, and actually getting down to projects with minimal setup headaches.

Starter kits typically include the Raspberry Pi motherboard itself (the actual computer), an SD card for holding the Pi’s operating system (which is often pre-installed when you buy a kit), a power supply for the device, and a protective case for keeping the Pi safe and sound from dust and bumps.

Usually, these kits include everything you need to get your Raspberry Pi up and running with the exception of a screen (and HDMI cable to connect to it), a USB keyboard and a mouse. Once you have these extra bits to hand, all you’d need to do is connect the appropriate cables to the right ports on the Pi, insert the SD card, plug it in to the power and you’re good to go.

US | UK | EU

Raspberry Pi 3 B+

The Raspberry Pi 3 B+ motherboard is the micro-computer that handles all of the processing of tasks and wireless communicating between the devices in your network and the files stored on the attached hard drive.

The Pi 3 B+ is a good choice for this kind of project because it’s not only incredibly good value for money, but it also crams a ton of effective tech into a tiny little device that can get the job done while using almost no power. This makes it an even cheaper option in the long run.

The 3 B+ includes four USB ports which can be used for connecting an external USB hard drive and peripherals like keyboards and mice. It also includes both Bluetooth and WiFi for wireless connectivity and an Ethernet port for physical network connections, if required.

Micro SD Card

The operating system for the Raspberry Pi is stored on an external Micro SD card which is used to install the OS on before you get started and  is then inserted into the Pi where it remains for future use.

If you opt for a ready-to-go Raspberry Pi kit, then you’ll already have been provided with a Micro SD card (which may already have the OS installed, ready to plug in and go).

If not, you’ll have to pick up a separate Micro SD, install the OS and then continue as before. Luckily this is a straightforward task to carry out.

In terms of the type and specs of the card you choose, the only consideration is to ensure you go for the right sort of card (the Pi 3 B+ only accepts Micro SD cards) and that your card has sufficient capacity. I’d recommend going no lower than a 16 GB card but you can, of course, opt for a higher capacity SD card.

External USB Hard Drive

An external hard drive is key to this project because it actually stores your files. At the most basic level, the more storage space on your hard drive the more files you’re going to be able to store.

There’s one important distinction to make when running an external hard drive from a Pi as opposed to a regular computer, however, and that comes down to power supply.

Most external USB hard drives are ‘unpowered’ which means they don’t have their own independent power supply. Instead, they receive their power directly from the computer or device they’re connected to, through a USB cable.

This arrangement works fine when the drive is hooked up to a regular computer as there’s plenty of power to spare, but it can occasionally cause issues when the hard drive is drawing power from a smaller device, such as a Raspberry Pi.

Some unpowered external hard drives will work just fine with the Pi 3 B+, as long as there is an adequate power supply running through the Pi itself. If you’re not sure if there’s going to be enough power to spare and are looking to play it safe, I’d definitely recommend opting for a powered external USB hard drive which utilizes its own separate power supply – like this one.

USB Mouse and Keyboard

A USB mouse and keyboard are essential accessories for setting up and navigating your Raspberry Pi, as well as actually getting our wireless network system up and running.

The most important thing is to make sure that both the keyboard are USB. This is the input that the Pi is going to be utilizing.

If you already have a USB keyboard and mouse at home then you can use these and and either wired or wireless is going to be just fine. Wired devices are cool because they don’t need any batteries.

If you don’t own a separate USB keyboard or mouse, there are some excellent low-budget combination packs on the market (like the Logitech MK120 keyboard and mouse combo, pictured) which will get the job done perfectly without breaking the bank.

HDMI Cable

The Raspberry Pi is a really cool micro computer but without the ability to connect it to a screen, you’re not going to get very far.

This is where the humble HDMI cable comes into play, connecting your Pi and screen.

When your wireless network storage is set up, configured, and ready to go, then this cable can be unplugged and won’t be needed again unless you decide you need to do something on the Pi in the future. For things like initial setup, navigation, exploring, and tinkering on the Pi however, you will need an HDMI cable to connect to your screen. Luckily, these cables are super cheap and incredibly useful for a wide range of applications beyond Pi projects, so if you don’t already have one the investment is money well spent.

Visual Display

As already mentioned, you’re definitely going to need some kind of HDMI-capable screen, monitor, or visual display so you can connect to your Raspberry Pi and configure it.

You can always unplug the display once your Pi server is up and running but you  might want it further down the line to access the visual interface of your Pi. Luckily, the device doesn’t actually care what type of screen you use to do this, so long as it is HMDI-capable. What this means in practice is that as long as you have access to a TV with HDMI inputs, you’re good to go.

If you don’t have a suitable screen however, it’s worth investing in an LED monitor which will work for projects and applications going forward. Plus, once you use an LED monitor as a secondary screen to your laptop you’ll never want to go back to just one screen again.

Some of the best entry-level LED monitors are affordable and offer great performance which make them an excellent addition to your setup from Pi, Arduino, and coding projects through to watching movies and shows (streamed directly from your Pi home server storage, of course!)

A few notes before we dive in:

  • This tutorial assumes that you have your Rapsberry Pi to hand, that Raspbian is installed on a micro SD card, and that you have also connected it to a mouse, keyboard and screen. Before powering up your Pi you should also plug in the external hard drive that you will use to store all of your digital files. If you’re new to Raspberry Pi check out this tutorial on how to get started.
  • The hard drive used in this tutorial is a NTFS-formatted hard disk. This allows you to take the hard drive that you’re using as your server and plug it into a regular laptop and still access all of your files. Great if you want to quickly move files to another device, absolutely necessary if your Pi server ever fails for some reason. If you’re on a PC, you can check how your hard drive is formatted by going to Windows File Explorer > right click on your hard drive > select properties > look for your format under ‘File system’.
  • All work for this tutorial is going to be done in the Pi’s command line. If you’re new to the command line, this is a nice introduction.
  • Original code is from here.

Once your Raspberry Pi (with Raspbian installed) has a mouse, keyboard, and external hard drive plugged in and is connected to a screen, you’re ready to build your own server.

01. Mount Your External Hard Drive

First thing’s first – plug your Pi’s power supply in. Once the Raspbian Desktop is up and running, navigate to the Pi’s Terminal.

With the command line open, the first thing to do is add support to Raspbian for NTFS-formatted disks by typing the following:

sudo apt-get install ntfs-3g

This will download, unpack, and install a package and might take a minute or two.

Next, you need to look for the unmounted partitions of the attached external hard drive. An unmounted hard drive is one that’s not being used by the computer. When you mount a drive it integrates into your computer and is therefore ready to use.

sudo fdisk -l

You should see at least two disks.

In the above example, the first disk /dev/mmcblk0 is the SD card on which Raspbian is installed – ignore this, you won’t be touching it. We are, however, interested in the second disk /dev/sda2 as this is our external hard drive. Make note of the name of your external hard drive because you’re going to need it later.

Next, you need to create a directory (or folder) for the drives to mount to. I used a Seagate external hard drive when setting up my server so I called my directory seagate, but you’re free to call it whatever you want.

sudo mkdir /media/seagate

Now you can mount the external drive (that name you just wrote down) to the directory (that you just made), effectively connecting the external hard drive to the Pi.

sudo mount -t auto /dev/sda2 /media/seagate

02. Install and Configure Samba

Samba is an implementation of the SMB/CIFS networking protocol that lets you provide shared access to things, such as files. This is how you’ll share the directory that you made previously to other computers on the same network.

sudo apt-get install samba samba-common-bin

The command line prompt will ask you if you want to continue – type Y and hit enter. Wait while Samba installs.

Once installed, you’re going to make some changes to the Samba configuration file so you’ll want to create a backup. The below code will duplicate the config file, rename it as smb.conf.old and then place it in the same directory as the original configuration file. If you make a mistake (hey, typos!) you can always roll the configuration file back to the original version.

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old

To edit the Samba config file you’re going to open the Nano text editor which makes it really easy to edit files.

sudo nano /etc/samba/smb.conf

The Nano screen should look something like this:

Nano is a command line editor so you can only use your keyboard – use arrow keys to move your cursor. If for some reason you’ve changed the name of your home workgroup you’ll want to scroll through the config file until you reach the workgroup identified. By default this will be workgroup = WORKGROUP. If you’ve changed your workgroup name you can modify that here. If you have no idea what a workgroup is, odds are you should leave this as default.

Next, you’re going to add a new section to the config file. Scroll to the bottom of the file and add the following:

comment = Server
path = /media/seagate
valid users = @users
force group = users
create mask = 0660
directory mask = 0771
read only = no

You’re now done editing the config file. Press CTRL + X to exit the Nano editor. Type Y when asked whether you want to save then hit Enter to return to the main command prompt. When back at the command prompt enter the following command to restart Samba:

sudo /etc/init.d/samba restart

03. Add a User and Password

To make sure that your files are secure add a user that can access your Pi server. For the sake of this tutorial we’re going to make a user called u3er with the password passw0rd. You should make your own username and password.

sudo useradd u3er -m -G users

sudo passwd passw0rd

The command prompt will ask you to type your password twice for confirmation. After confirming your password you need add u$er as a Samba user.

sudo smbpasswd -a u3er

When prompted, enter the password that you just created.

04. Connect to Your Server from Another Machine

You’re now ready to connect to your new server from your own computer. How you connect to the Pi server will differ based on your computer’s operating system.

If you have a Windows computer then open Windows File Explorer > click on Network and then click on RASPBERRYPI.

You’ll be prompted to enter the username and password that you just created. If you’re following this tutorial verbatim, that will be u3er and passw0rd.

If your external hard drive had any files on it before attempting this tutorial you should now be able to see them. If your hard drive was empty you’re going to see an empty folder because there isn’t anything to share yet.

You can now test your server, to make sure everything is working a-okay. To do this, create a text file from your computer by right clicking in the empty folder and selecting New > Text Document

Go back to your Pi’s command line and type:

cd /media/seagate


If your file is there then you’ve successfully synced files between your Pi server and your computer.

05. Automatically Connect to Your Server

There’s one more thing to do if you want your computer to automatically connect to your server when you turn it on.

On your Pi first reopen Nano.

sudo nano /etc/fstab

Now, add the following line of code to the end of the file.

/dev/sda2 /media/seagate auto noatime 0 0

Remember, /dev/sda2 is the name of the external hard drive used in this tutorial, your hard drive may be named something different.

Press CTRL+X to exit the Nano editor and then press Y to save your changes. Hit Enter to return to the command prompt.

Congratulations, you now have a working home server!