Network-attached storage build log

This is a build log of a network-attached storage (NAS) device, or a small home server, built from a thin client. The NAS runs Ubuntu Server, with Docker and Nextcloud installed.

Assemble the hardware

The NAS hardware was assembled mostly following this tutorial (in Polish).

I personally used the following components:

Photo of the completed NAS

And the following tools:

I removed the card readed with the metal tray, to put the HDD in its place. The HDD is not permanently attached to the metal case so far. I also removed the built-in speaker. The motherboard still has a beeper, and it beeps every time the system starts up.

Photo of the dismantled metal tray

The SATA disk is connected to the motherboard with a cable that has SATA data and power connector on one side, connected to the HDD, and on the other side, a FDD power connector and a SATA plug. The FDD power connector should be corretly connected - the red wire carrying 5 V should be on the side towards the PCB edge, and the yellow wire carrying 12 V should be on the side towards the PCB center.

Photo of the connection

Finally, I put a thick opaque sticky tape over the power LED, so that it won't disturb people in the room.

Possible future hardware improvements

In principle, more HDDs can be added, by using a PCI-SATA controller (and manually assembling power cables by soldering wires in SATA power splitters to wires in the FDD-SATA adapter), or by using USB to SATA connectors. This way, more reliable RAID setups can be assembled. This can be helpful particularly when using inexpensive second hand HDDs.

Don't forget that RAID is not a full backup - while it protects against a single disk failure, it doesn't protect against accidental deletion of files, or against a fire or a flood.

Install the operating system

Download Ubuntu Server image and install it on a USB stick. I used balenaEtcher to do that.

By pressing delete when starting up, open BIOS menu, and select boot order so that the system starts from USB. After rebooting, select the option to install Ubuntu Server from the menu that will appear on the screen.

I accepted most of the default options. I used the following custom partition scheme:

When presented with option to install SSH, install it, and allow it to login the user with a password. This would be highly insecure if the SSH server was accessible over public Internet - use SSH keys in such case, and harden your installation with tools such as fail2ban AND with additional methods such as nonstandard port.

After the installation completes, remove the USB stick and press Enter, so that the computer will reboot. After startup, the system should allow the user to login with user name and password. Login with the chosen credentials.

Then, install and run ifconfig to obtain your IP address, usually in the form 192.168.0.xxx - you'll be using this IP address to connect to the NAS using SSH. To do that, use the following commands:

sudo apt install net-tools
ifconfig

Don't forget to write down the the IP address. After completing this step, you won't need to use the keyboard and monitor connected to the NAS anymore, and you'll be able to connect using SSH. To do that, from another computer, use the command:

ssh enteryourusernamehere@192.168.xxxx.xxxx

Replace the user name (enteryourusernamehere) with the user name you chose when installing, and the IP address with the address of your NAS (192.168.xxxx.xxxx), as noted down in the previous step. After running the command, you'll be presented with the password input.

After logging in using SSH, you can update the system packages using the following commands:

sudo apt update
sudo apt upgrade

Install Docker

Following the Docker installation instruction using the quick install script, we run the command:

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

Then, following the post-install instruction, we run the commands:

sudo groupadd docker
sudo usermod -aG docker $USER
exit

The last command will log you out of the SSH session. This is required to apply the permissions to run Docker commands without sudo. Disconnect and connect again to the NAS using SSH, to run the next steps.

Verify Docker installation

Verify that Docker runs correctly, using the following command:

docker run hello-world

The command should write a message beginning with Hello from Docker!. Because the container image takes only 13 kB, you don't really need to delete it afterwards, but you can, if you want to keep the list of containers and images clean.

Install Nextcloud

cd ~
mkdir data-nextcloud
docker run -d -v /home/enteryourusernamehere/data-nextcloud:/var/www/html -p 8080:80 nextcloud

The option -p 8080:80 connects the external port 8080 as visible in the host system to port 80 as visible from the container. The code inside the container will use port 80, but the application will be available from other computers on port 8080.

You can verify that by running curl localhost:8080 command, it should return some HTML.

After setting up the container, open a browser and open the URL http://192.168.xxxx.xxxx:8080/ (replace the IP address with the address of your NAS as determined in previous steps). It should show the Nextcloud configuration screen, with fields to enter username and password for the Nextcloud user with admin permissions. Enter these values and click Install. The installation process took several minutes.

After that, you can add some additional apps that extend Nextcloud functionality. I personally didn't install any, they can be installed later. To see the files stored in Nextcloud, select the folder icon from in the top left corner of the screen. There will be some example files added, feel free to remove them.

Check your disk usage

A highly useful command is df - it shows the. In my case, after installing several containers, it displayed, among other lines:

Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sdb2       15283560 4511008   9974396  32% /
/dev/sda2      476498864   39272 452181272   1% /home

In my case, /dev/sda2 is the partition on the large (but slow) HDD, while /dev/sdb2 is the partition on the small (but fast) SSD.

Disk usage will change depending on what exact software you install.

Install lm-sensors to monitor hardware temperature

Following the tutorial at https://www.cyberciti.biz/faq/howto-linux-get-sensors-information/ you need to run these commands:

The output of sensors command looks like that:

k10temp-pci-00c3
Adapter: PCI adapter
temp1:        +63.0°C  (high = +70.0°C)
                       (crit = +100.0°C, hyst = +97.0°C)

radeon-pci-0008
Adapter: PCI adapter
in0:         888.00 mV 
temp1:        +63.0°C  (crit = +120.0°C, hyst = +90.0°C)

sch5627-isa-0000
Adapter: ISA adapter
VCC:           3.31 V  
VTT:           1.49 V  
VBAT:          3.28 V  
VTR:           3.31 V  
in4:           1.13 V  
fan1:           FAULT  (min =    0 RPM)
fan2:           FAULT  (min =    0 RPM)
fan3:           FAULT  (min =    0 RPM)
fan4:           FAULT  (min =    0 RPM)
temp1:        +63.0°C  (high = +60.0°C, crit = +100.0°C)
temp2:        +50.9°C  (high = +60.0°C, crit = +191.0°C)
temp3:        +50.9°C  (high = +60.0°C, crit = +191.0°C)
temp4:        +50.9°C  (high = +60.0°C, crit = +191.0°C)
temp5:        +50.9°C  (high = +60.0°C, crit = +191.0°C)
temp6:        +50.9°C  (high = +60.0°C, crit = +191.0°C)
temp7:        +50.9°C  (high = +60.0°C, crit = +191.0°C)
temp8:        +63.0°C  (high = +60.0°C, crit = +191.0°C)

In my case, the temperatures are around 59 C when idle (as reported by htop), and when installing a large Docker package, the temperature rises to 65 C. I'm not comfortable with running a task taking 100% of the CPU, so I didn't measure the temperatures under steady 100% load. The ambient CPU load as reported by htop is roughly 3-4%, of which htop itself takes 2.6%. As the thin client doesn't include any fans by default, and the fan I installed is powered from the USB header, the measurements displayed above show "FAULT" for the fan speeds.

There exists a binding of lm-sensors to Python so that the data can be read in Python scripts. In the future, this may be useful for monitoring the system.

Install other software

PostgreSQL

I installed PostgreSQL to have a very slow instance for experiments with query optimization.

This is how I installed PostgreSQL, so that it stores the data on the HDD instead of SSD.

cd ~
mkdir data-postgres
docker run -d -e POSTGRES_PASSWORD=enteryourdatabasepasswordhere -e PGDATA=/var/lib/postgresql/data/pgdata -v /home/enteryourusernamehere/data-postgres:/var/lib/postgresql/data postgres

See PostgreSQL Docker image documentation for more details.

Go back to home page