Build the ultimate home server with Raspberry Pi

Revolutionise your home network with shared storage, media serving, network management, home automation and more. All in one tiny box!

Raspberry Pi also makes a great home server. Why do you need a home server? Well, there’s all kinds of uses: file sharing, protecting your network from dodgy advertisers, controlling your smart devices; the list goes on. In this new series, we’ll build a home server with all the bells and whistles to inspire you to create your own ultimate build, with plenty of ideas and tips along the way.

It’s probably no surprise that we’re using a Raspberry Pi 4 with 8GB RAM model for our ultimate server. It’s the most powerful Raspberry Pi. However, you can go for lower memory sizes and get similar performance. If you’re interested in using advanced file systems like ZFS for protecting your data, you’ll need at least 4GB for it to work effectively. Then consider what the server will be doing. Serving files doesn’t require much effort and is well within the capabilities of Raspberry Pi Zero, and we strongly recommend a wired network connection.

Our Raspberry Pi 4 needs a good home if it’s going to be a server. There’s no shortage of cases available and if you’re lucky enough to have a 3D printer, many more designs are available for download. Have a think about storage requirements such as additional disks or access to USB or GPIO connectors. We’ve chosen the Argon One case. Not only is it beautiful, it also features passive cooling (as well as a fan) and support for M.2 storage devices. As a server is intended to be running 24/7, make sure your choice of case is well ventilated and will be placed where it can ‘breathe’.

The standard application for a server is file sharing: the ability for anyone in your household to access a library of files. If you’re thinking of a media server, consider carefully what type of storage to use and how much you need. Movies, especially in high-definition formats, eat up a lot of space but don’t require fast storage to play back reliably. We’re making use of the Argon One’s M.2 interface to add 1TB of fast SSD-based storage, but you may prefer one or more USB SSD drives. Using a microSD card is still an option, but slower and less reliable.

By default, a Raspberry Pi 4 and Raspberry Pi 400 will try to boot from the microSD card and then from a USB attached drive. So you will not need to do any additional tweaks to get the M.2 drive working. USB boot is also available on most other Raspberry Pi models, including Raspberry Pi 2, 3A, 3B, and Compute Modules 3+ and 4. However, you will need to update the bootloader on these devices. See magpi.cc/bootloader for info and instructions.

Now we have the computer, case and storage, it’s time to put them together. The Argon One comes with a comprehensive installation guide. Add the expansion board to bring all the connections to the rear of the case, then mount in the case as instructed, using the supplied thermal pads to get a good connection between the board and the heatsink. Install your M.2 SSD drive in the lower part of the case, then screw the two halves together. The M.2 SSD device is connected to Raspberry Pi 4 using an external USB-to-USB bridge.

Preparing an M.2 SSD device is identical to preparing an SD card, but connecting the M.2 device may be tricky. Either purchase an inexpensive M.2 to USB device or start with an existing Raspberry Pi build and use Argon One M.2’s USB bridge to connect it. Then use Raspberry Pi Imager to ‘burn’ a Raspberry Pi OS disk image onto the SSD device so it’s ready to boot. As this is a server, we don’t need a graphical user interface, so we can keep things lightweight. Using Raspberry Pi Imager, select Raspberry Pi OS Lite and check out the advanced menu (CTRL/CMD+SHIFT+X) to set things like hostname and networking before burning the image to the card. We are naming our hostname ‘ultimate’ so it is easy to find on the network.

Full-time servers are not normally connected to your network over wireless LAN. Whilst wireless is a great technology for end-users, servers crave reliability and the best way of delivering that is a wired Ethernet connection. We recommend placing your server close to your home broadband router (or whichever device handles your network traffic). That way, the network is not trying to handle two wireless conversations: one between you and the router and another between the router and the server. Wired will be much faster and reliable. If this isn’t an option, don’t worry: it’ll still work, but larger files may be slow to transfer.

Let your server boot for the first time, making sure no microSD card is inserted. Even if you configured it as headless, it’s worth plugging a monitor in so you can check everything is OK. It will quickly reboot to resize the file system and then start up. We used the Advanced menu in Raspberry Pi Imager to set the hostname to ‘ultimate’, so with a wired connection we can ping ‘ultimate.local’ from another computer to confirm it’s on the network. If you didn’t do this, set up your hostname by running sudo raspi-config from a Terminal. You can also set up networking here if you need to. Update everything with: sudo apt update && sudo apt -y full-upgrade

There is an argument to be made for still using a microSD card as the primary boot device. This dedicates your M.2 SSD to data only. In the event of an operating system failure, your data can still be accessed by removing the SSD drive. Likewise, if you need to increase your storage capability, you avoid having to rebuild your operating system from scratch. If you want to take this approach, make sure your bootloader prioritises the SD card (you can check in raspi-config > Advanced Options > Bootloader Version). You will you’ll need to partition and format the second USB drive with an ext4 file system.

The Argon One case incorporates not only passive cooling but also has a fan for keeping our Raspberry Pi 4B nice and cool. It’s not the quietest but does support active control. To install this, enter the following command in a Terminal: curl https://download.argon40.com/argon1. sh | bash This will download the drivers and install them automatically. The fan will now adjust its speed based on temperature. It will also allow the power button to cleanly shut down after being pressed for three seconds. To change these settings, run argonone-config from the command line.

Let’s go back to networking. Our server’s hostname is ‘ultimate’, so using the ZeroConf DNS system (aka mDNS), it should be on the network as ‘ultimate.local’. To test this from another machine, run ping ultimate.local from the command line and see if you get a response from the server. If you get no response, check your network settings on Raspberry Pi using sudo raspi-config. If using wireless LAN, try a wired connection instead. You can also use utilities like Fing (fing.com) to see if your server has acquired an IP address. (Note that versions of Windows prior to 10 do not natively support .local addresses.)

All Raspberry Pi operating systems start with a pre-installed user called ‘pi’. So we can share files and manage permissions, it makes sense to create our own user accounts. To do this, open a Terminal as the ‘pi’ user and run this command: sudo adduser <name> ...where <name> is the username you would like (avoid spaces and special characters). It will ask you a few optional questions about your full name and location. Finally, you can set a password (be sensible!). To give the user ‘super user’ or ‘sudo’ rights: sudo adduser <name> sudo To give the new user all the same permissions as the ‘pi’ user: sudo usermod -a -G adm, dialout, cdrom, sudo, audio, video, plugdev, games, users, input, netdev, gpio, i2c, spi <name> You should now be able to log in as your new user. You can create as many of these as you need.

A fast and secure way to log into your new server is SSH key exchange. If you anticipate lots of logging into your new server with SSH, this is an essential step. If you’re using Windows, start by installing the free OpenSSH client from Microsoft’s instructions (magpi.cc/msopenssh). From a command line, first generate your keypair (if you don’t already have one): ssh-keygen This stores a public and private key in your home directory under ~/.ssh. Copy your public key over to your server: ssh-copy-id <name>@ultimate.local ...where <name> is the username you created previously. Now you can log into your server without a password using SSH: ssh <name>@ultimate.local If your local username matches the server’s, you don’t even need to include it or the ‘@’.

You’ve now got the basis for building a powerful home server. Next month we’ll move on to the most useful aspect of any home server: file sharing.