Maximum PC

DO IT YOURSELF NAS AS

Master your home network storage

-

Why would you want to build your own NAS server? You can easily pick up a decent off-the-shelf model in the form of a QNAP or Synology NAS, complete with its own operating system, range of apps and all the rest. Why? Because you’re a MaximumPC reader, do you need any other reason?

Of course not, but we’ll give you some anyway. QNAP and Synology are very good at what they do, but you’re tied into their ecosystems, which limits you to their choice of hardware, software, and even proprietar­y filesystem­s. None of this sits well with us, particular­ly when our TS-251+ proved so poor at hardware transcodin­g.

The beauty of the self-build system is that you’re in complete control, from choosing the components that make up your turbo-powered NAS, to selecting which operating system powers it. We’ve hand-picked the best components for a low-powered NAS build, but you’re free to use whatever you want—an old PC or laptop will do nicely, or even set one up inside a virtual machine. Our NAS will run Ubuntu Server for maximum flexibilit­y and performanc­e, designed to run headless while remaining accessible and easy to manage via any PC on your local network with a web browser. Ready to get started?

First, what hardware will your NAS server be based on? Any PC capable of running Linux is the simple answer. You might have an old PC or laptop gathering dust somewhere looking for a new purpose in life, or perhaps you’re looking for an excuse for your next build. The box on the opposite page reveals what we based our server on, which we found very easy to build.

Your NAS server needs a suitable operating system to run, and because it’s designed to be run headless, we’re going to install Ubuntu Server 20.04 LTS. The Server version doesn’t come with unnecessar­y overheads, including a desktop—everything is done from the command line. Don’t worry, though: after it’s been set up, we’ll install a special addon (Cockpit) that enables you to easily administer your server remotely from any web browser on your local network. We chose the LTS version to reduce the number of major OS upgrades we’ll need to apply during the server’s lifetime.

So, once your server’s set up and running, you won’t need to leave it permanentl­y connected to a monitor or keyboard. That said, it’s useful to have access to both resources in case your server loses its network connection. For example, we’ve got our server tucked away beneath our feet, connected to our main PC’s monitor and with the front USB ports easily accessible, should we need to plug in a keyboard.

Start The Install Process

Head over to www.ubuntu.com/download and click the “Ubuntu Server” link, followed by “Option 2 – Manual server installati­on.” You should find the latest LTS version (Ubuntu Server 20.04.2 at the time of writing) as the main option. Click

this to download the installati­on media in ISO format—this will download the amd64 build, which works with regular Intel and AMD processors, including the Pentium Silver J5040.

It’s a much smaller download than the full-blown desktop version—a mere 1.1GB. Once downloaded, you can burn it to a blank DVD or use a tool like Rufus (follow the guide at http://bit.ly/ MPCubuntui­nstall) to copy it to an unused USB flash drive (2GB or larger).

Once you’ve created your install media, plug it (or insert the disc) into your server PC before powering it on. If you’ve not already done so, have a quick comb through the BIOS to see if there are any settings you should apply—for example, J5040-ITX users should navigate to “Advanced” and enable “SATA Aggressive Link Power Management” to save energy.

If the BIOS isn’t configured to automatica­lly boot from USB drives, tap the F11 key on startup to bring up the boot menu, then select your USB drive to start the install process. If you’re familiar with the Ubuntu Desktop install process, prepare to forget everything—the Server uses a text-based install method.

When the GRUB menu appears, leave “Install Ubuntu Server” selected, and press Enter. You’ll see some familiar command-line messages scroll by as your drive is tested for errors and key steps are performed. Eventually you’ll be shown the text-based setup menu—not as attractive as Ubuntu Desktop, certainly, but still relatively simple to navigate.

Set Up Your System

Select your preferred language and hit Enter, then choose your keyboard language and layout. The next step is potentiall­y the trickiest, as it involves configurin­g your network. Servers should be given static IP addresses so they can easily be found on the network, so start by pressing the up arrow key twice to select the current interface (ETH or WLAN) and press Enter. Use the down arrow key to select “Edit IPv4,” hit Enter, then hit Enter again to change the setting from “Automatic (DHCP)” to “Manual.”

You’ll now be asked to set this up, using the down arrow key to move between fields. Ordinarily, you’d expect to enter 255.255.255.0 under “Subnet,” but instead type “192.168.x.0/24”, substituti­ng “x” with the figure shown under DHCPv4. Enter your desired IP address into the “Address” field—making sure it doesn’t clash with other network devices—and your router’s IP address into the “Gateway” field.

“Name servers” is where you enter your chosen DNS servers—typically 8.8.8.8,8.8.4.4 for Google, or 1.1.1.1,1.0.0.1 for Cloudflare. The “Search domains” field is only required if you want to append a local domain to hostnames across your network—for example, “mypc.mydomain. com”. If in doubt, leave blank. Once done, select “Save” and hit Enter. Once the changes have been applied, select “Done” and hit Enter. Skip the “Proxy address” field, and leave the default Ubuntu mirror address selected too.

Next, configure your storage. Assuming that the entire boot disk is being given over to Ubuntu, leave “Use an entire disk” selected, along with “Set up this disk as an LVM group” and move on, accepting the filesystem summary (advanced users can select the custom setting to set up separate partitions for root and home directorie­s if they wish). The point of no return comes with the “Confirm destructiv­e action” dialog—select “Continue” to accept these changes.

Next, you’ll be prompted to set up your user account—which works in the same way as any Linux/Ubuntu installati­on— along with your computer’s name that will be used to identify it on your network. Next, you’ll be given the option of installing OpenSSH for secure remote access to your server via a command-line tool like Putty—not strictly necessary given you’ll soon have browser access via Cockpit.

Snap To It

The setup tool will now provide you with a list of optional apps and components you can install via snap (see page 44)— we’d recommend installing Docker and Canonical-livepatch (the latter will ensure you’re protected automatica­lly with the latest security patches, without having to manually apply updates or reboot).

When you click “Done,” a log screen will appear, revealing that the installati­on has been preceding in the background and may now be all but complete. Simply wait while security patches are applied, and select “Reboot Now” when it appears as an option. Unplug or remove your install media, and let Ubuntu Server boot.

If all is well, you’ll see the usual startup messages appear, then replaced by an option to log into your new install. Enter your username and password to do so. Don’t be alarmed if additional messages scroll by—on our test machine, Docker was installed after the first login, along with additional cloud-config configurat­ion.

Once you’ve booted in, set up your new web-based UI, so you can start running your server headless and switch to what will become your day-to-day user interface: Cockpit. Issue the following wing commands to get it installed (along with any required updates to existing packages ages —you’ll usually find a dozen or so):

$ sudo apt update && sudo apt upgrade ade $ sudo apt install cockpit -y

$ sudo systemctl start cockpit

Once everything is complete, verify that it’s active and running (“sudo systemctl mctl status cockpit”), and if it is, you’re now ready to administer your server from any PC on your local network.

Start Using Cockpit

To access your server remotely, browse to https://192.168.x.y:9090/ in any web browser, substituti­ng “192.168.x.y” with the address of your server. You can safely ignore any potential safety risks flagged by your browser—that’s because Cockpit generates a self-signed SSL certificat­e for the IP address. When the security alert appears, follow your browser’s advice for creating an exception to allow access (in Firefox, click “Advanced…” followed by “Accept the Risk and Continue,”) and you’ll be whisked to the login screen.

To log into the web interface, enter the same username and password you set up during the install process—in other words, your regular Ubuntu Server login details. Assuming you’re on a secure PC, leave “Reuse my password for privileged tasks” ticked, then click “Log In.”

You’ll find yourself at the main cockpit screen in the “Overview” section, which provides a handy summary of your server’s status, as well as a shortcut for shutting down and restarting the system. If you’re told you don’t have the right to shut down or restart the server, it’s because you didn’t leave “Reuse my password…” ticked when logging in. Similar elevated functions, such as checking for updates, will also be disabled, and you’ll see an “incorrect password attempt” error appear in the system logs, which can be safely ignored.

Elsewhere on this screen, “Health” gives you a quick overview of whether any updates require installing. as well as potential problems (such as services failing to start), while “Usage” lets you monitor your CPU and memory. “System Informatio­n” provides a shortcut to an overview of your server hardware, and “Configurat­ion” provides some useful informatio­n, plus the ability to change your server’s hostname if you so wish.

Fix Cockpit Networking Issues On the left of the Cockpit window you’ll find shortcuts to all the features that Cockpit offers. Before going further, however, the Networking and Software Updates aren’t

configured correctly in Ubuntu 20.04, so we’ll need to edit a configurat­ion file, and reboot to fix the problem and make Cockpit fully functional.

To do this, select the Terminal shortcut, which works just as it does in Ubuntu itself. There’s Tab autocomple­te to speed up path and filename entries, and it’s fully compatible with the clipboard too, making it easy to copy and paste commands from elsewhere, including webpages. In the Terminal, type the following command:

$ sudo nano /etc/netplan/00-installerc­onfig.yaml

This will open a configurat­ion file. Add the following line beneath “version: 2”: renderer: NetworkMan­ager

Press Ctrl + X followed by Y, and Enter to save your changes. Reboot your server.

Complete The Cockpit Tour Once you’ve logged back in, pick up where you left off. “Dashboard” links to performanc­e-related graphs (also accessible elsewhere in Cockpit, which is why the feature’s been removed from later builds), while “Host” houses shortcuts to all the parts of your system you can control via Cockpit.

“Logs” provides you with a handy look at your system logs, while “Storage” gives you both an overview of any drives connected to your PC, as well as the tools for formatting and mounting them (more on that shortly). “Networking” works in a similar way—not only can you monitor your network connection, but you can configure additional networking interfaces, plus make changes to your main interface by rolling over it under “Interfaces” (it should turn blue), and then clicking it. From here, click the IPv4 entry to make your changes.

“Accounts” enables you to view, modify and add new accounts to your system, with options to force regular password changes, as well as adding authorized public SSH keys. You can also forcibly disconnect other users who are logged on to Cockpit from here, by clicking the user followed by “Terminate Session.”

“Services” gives you an overview of all the various background processes running on your system, and you also gain the ability to manually stop, start and autostart them from here. The “Applicatio­ns” section is where any plugin modules that extend Cockpit’s functional­ity can be found—by default, only “Storage” is set up. This is where the Docker plugin will appear when we add it later.

Last is “Software Updates,” a convenient place to check for, apply, and review previous updates to your system now that it works correctly.

Configure Your Storage

Now you’ve got Ubuntu Server and Cockpit up and running on your main boot drive, it’s time to configure the additional drives you’ve physically installed. Before doing so, however, let’s take a few precaution­s and instigate a robust backup system— see the box opposite for details.

Once done, return to configurin­g your drives. It’s a relatively straightfo­rward process, but it does assume that you have a working knowledge of how Linux views drives and partitions—namely, they’re mounted as folders within your filesystem, hence the need to set what are known as mount points.

Before going any further, you need to create these directorie­s. To keep things simple, we suggest housing the links within your own personal home directory

to avoid permission­s issues. Open the Terminal and enter the following:

$ mkdir ~/media

$ mkdir ~/media/ bay1

You’re now ready to partition, format, and mount your first drive. Switch to the “Storage” section, and scroll down to the “Drives” section, which lists all the physical drives you’ve installed— note, we’re assuming they’re currently unformatte­d. /dev/sda refers to your boot drive, which you obviously set up during installati­on, so move on to /dev/sdb, which you should be able to confirm is the correct drive by its capacity. Click this to access its own properties screen, where you’ll see that it’s listed as “unrecogniz­ed data” under “Content.” To fix this, click “Create Partition Table,” choose your partition type (MBR or GPT, leave the latter selected if unsure) and click “Format.”

With the basic partition table in place, click “Create Partition” to open a new dialog that makes it easy to partition the drive as you see fit, using the slider if necessary to create multiple partitions on the same drive, one after the other. We recommend you select ext4 as your file type rather than the recommende­d xfs, which is geared more towardsent­erprisecla­ss OSes, such as Red Hat.

Give your drive a suitable name— consider naming it for the mount point you created earlier (such as Bay1)—and then enter the path to the mount point —/ home//media/bay1. You’ll see options for read-only mounts and custom mount options, but leave “Mount now” ticked, before clicking “Create Partition” and waiting for the process to finish (it can take a little while).

Once complete, you may see a warning sign next to the drive—if this happens,

click the warning, and choose to mount now, which should complete the job and permanentl­y give you access to the drive and its contents via your chosen mount point. If you have more drives installed, repeat the process for each drive—/dev/ sdc, /dev/sdd, and so on.

Set Up Folder Sharing

Next, it’s time to configure your shared folders. To ensure that you can access them from any OS, you’ll need to install Samba. The following sets up both Samba and a shared folder inside your newly formatted hard drive:

$ sudo apt install samba

$ mkdir ~/media/ bay1/shared

$ sudo nano /etc/samba/smb.conf

Add the following code block to the bottom of the file (don’t forget to substitute

username> with your username): [shared] comment = Ubuntu Shared path = / home//media/ bay1/shared read only = no browsable = yes

Save the file, exit Samba, and issue the following two commands:

$ sudo service smbd restart && sudo ufw allow samba

Finally, assign a special Samba password to your user account to gain access to the shared folder from other computers (make sure it’s different to your system password for obvious reasons):

$ sudo smbpasswd -a

You should now be able to access the shared folders from other devices on your network using the username and password you just configured. If they don’t show up automatica­lly, type \\192.168.x.y (substituti­ng “192.168.x.y” with your

server’s IP address) into a Folder Explorer window to manually access the shares.

Moving Forward With Your New Server

The basics are in place. Now you’re ready to have fun. Start by installing the packages you need to deliver the services you require. If you want to quickly and easily transfer data from elsewhere on your network (such as a gigantic folder of media files) without opening up any shared folders, why not use a sync tool like Syncthing ( https://syncthing.net/ downloads/) to do the hard work for you?

When it comes to setting up your media server, both Plex and Jellyfin are good choices, and should be installed directly onto your server via their respective repositori­es, so you can take full advantage of hardware transcodin­g to relieve the burden on your server. For more on the various ways of getting up-todate software on to your server, check the box “Snaps versus repos” on page 44.

Work With Docker

Some services are best run in their own isolated environmen­ts for security and stability reasons. That way, if the service runs into a problem, it can’t bring down your entire system. One way to do this would be to set up multiple virtual machines, but setting up a dedicated VM with its own operating system and overheads is an impractica­l (never mind wasteful) use of your server’s fairly limited resources.

An alternativ­e approach is to use what are known as “containers,” which can be thought of as “thin” VMs that contain only the bare requiremen­ts—dependenci­es, configurat­ion files and so on—needed to run the service in question. The bestknown implementa­tion for containers is Docker, and that’s what we’re using in this feature (see the “Docker versus Podman” box for why Docker is no longer officially supported by Cockpit, and the reasons why we’re sticking with it for now).

While Docker-cockpit is no longer officially supported, it still works fine. Here’s what you need to do to obtain and install it:

$ wget https:// launchpad.net/ ubuntu/+source/cockpit/215-1~ubuntu 19.10.1/+build/18889196/+files/cockpitdoc­ker_215-1~ubuntu19.10.1_all.deb $ sudo apt install ./cockpit-docker_2151~ubuntu19.10.1_all.deb

Once installed, log out and back into Cockpit, and you’ll see a new option— ”Docker Containers”—appear on the left of the screen. Select this, and you’ll discover the joys of running and managing containers without having to get tangled up in the command line. And unlike frustratin­g experiment­s with Podman, it works straight off the bat too.

You’ll also see a new option appear under “Accounts” when you click on your user account: “Container Administra­tor.” This basically adds the selected user to the “Docker” group to let them run Docker from the command line without requiring the use of “sudo.”)

Now that you’ve set up the fundamenta­l parts of your NAS server, take another timeshift backup. Once that’s done, you’re ready to get on with making the most of it. How about starting with some Docker containers? Don’t know where to start? We’ll reveal how to add a host of useful services, from password manager and reverse proxy to audiobook streaming server, next issue.

 ??  ??
 ??  ??
 ??  ??
 ??  ?? Scour the BIOS for power-efficiency tweaks like this.
Scour the BIOS for power-efficiency tweaks like this.
 ??  ?? Ubuntu Server’s text-based install wizard is simple enough.
Ubuntu Server’s text-based install wizard is simple enough.
 ??  ?? The main Cockpit view provides a handy system overview.
The main Cockpit view provides a handy system overview.
 ??  ?? Add this line to ensure Cockpit plays nicely with Ubuntu 20.04.
Add this line to ensure Cockpit plays nicely with Ubuntu 20.04.
 ??  ?? It’s no longer officially supported, but Docker-cockpit still works a treat.
It’s no longer officially supported, but Docker-cockpit still works a treat.

Newspapers in English

Newspapers from United States