Required Items:
A 3D printer to print the case
Raspberry Pi 5 (8GB preferred)
Radxa Penta SATA Hat
2.5″ Hard Drive or SSD
NF-A8 Noctua Fan
12V 5A Power Adapter
Minimum 8GB MicroSD Card
Build Instructions:
Begin by downloading the 3D print files here and print the Pi NAS case.
Using the Raspberry Pi Imager, flash the latest PiOS Lite to your MicroSD card.
Attach the Radxa SATA Hat to your Raspberry Pi 5 and the boot up with the MicroSD card that you just flashed. Create a user account and setup SSH if you’d like. Also, setup all of the localization settings. Now edit the /boot/firmware/config.txt file and add the following lines at the end:
dtparam=pciex1 dtparam=pciex1_gen=3
Save the file and then reboot. After rebooting, you should see the hard drive(s) listed using the command ‘lsblk’. Now we can partition and format the drive if it hasn’t already been done:
$ sudo fdisk -l $ sudo fdisk /dev/sda
Note: the d command will delete a partition and the n command will create a new partition.
Once the partition is created we can format the drive:
$ sudo mkfs -t ext4 /dev/sda1
We want the drive to auto-mount at boot. This usually means editing /etc/fstab.
Firstly, it’s always best to use the drives UUID. To find the drive’s UUID, run the following:
$ ls -al /dev/disk/by-uuid/
Copy the resultant UUID (for your disk) and then open fstab for editing (note I’m using vim here but use whatever editor you prefer):
$ sudo nano /etc/fstab
You want to add an entry for the UUID and mount point. Below is an example of an fstab file with an entry added for the mount above:
# /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/sdb1 during installation UUID=63a46dce-b895-4c1f-9034-b1104694a956 / ext4 errors=remount-ro 0 1 # swap was on /dev/sdb5 during installation UUID=b9b9ee49-c69c-475b-894b-1279d44034ae none swap sw 0 0 # data drive UUID=19fa40a3-fd17-412f-9063-a29ca0e75f93 /volume1 ext4 defaults 0 0
Note: the entry added is the last line.
While we are editing this file, let’s also add a bind mount to store our Docker containers:
/var/lib/docker /volume1/docker none defsults,bind 0 0
Test fstab
We always want to test the fstab before rebooting (an incorrect fstab can render a disk unbootable). To test do:
$ findmnt --verify
Check the last line for errors. Warnings can help in improving your fstab. Now install Docker using the following command:
$ sudo apt install docker.io
After Docker finishes installing, we need to give our user account access to Docker. Replace [user] with the name of your user account.
$ sudo usermod -aG docker [user]
Now create a directory on your hard disk to store the Docker containers and create a symlink to this folder. Also, we are going to make the file system read-only using raspi-config:
$ mkdir /volume1/docker $ sudo systemctl stop docker $ sudo rm -rf /var/lib/docker/* $ sudo systemctl start docker $ sudo raspi-config
Select ‘Performance options’ and ‘ P2 Overlay File System Enable/disable read-only file system’. Select yes to enable.
$ sudo reboot
Now we are going to run a command to download the latest Portainer image:
sudo docker pull portainer/portainer-ce:latest
Our final step is to create a new container that will run Portainer:
sudo docker run --restart always -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
You should now be able to navigate to the IP address of your Raspberry Pi and port 9000 to access Portainer. When you get there, create a username and password.
http://[RASPBERRY_PI_IP_ADDRESS]:9000
Set up your Docker Containers such as Webmin, Nextcloud, TVHeadend, and Syncthing.
Sources
https://cults3d.com/en/3d-model/gadget/pi-5-nas-tower-for-radxa-hat-with-option-noctua-fan
https://confluence.jaytaala.com/display/TKB/Mount+drive+in+linux+and+set+auto-mount+at+boot
https://www.wundertech.net/portainer-raspberry-pi-install-how-to-install-docker-and-portainer/