DIY Raspberry Pi NAS: A Practical and Elegant Solution

DIY Raspberry Pi NAS: A Practical and Elegant Solution

MAKER: Frank Bernhardt /Translated by: Qu Wujin (Please cite the source)

Due to the high cost of NAS devices on the market, if you have a Raspberry Pi, it is very economical for engineers to DIY one.

We can customize the shell shape according to our preferences: – Only keep the power and network cable interfaces – Both connection ports are located at the back and adjacent to each other – USB connectors and cables must all be inside the shell to ensure a clean and beautiful design – Simple printing, no overly complex parts required – Compatible with Raspberry Pi 4 and 5 – Multi-line OLED display – All components are cheap and easy to obtain

DIY Raspberry Pi NAS: A Practical and Elegant Solution

DIY Raspberry Pi NAS: A Practical and Elegant Solution

The production process of this NAS device not only requires certain manual skills but also involves 3D printing shell components, soldering techniques, and software configuration skills.

Component List

– 3D printer that supports printing over 200 x 200 mm × 1 – Soldering iron, recommended for threaded inserts × 1 – Utility knife × 1 – Screwdriver × 1 – Dupont connector crimping tool (optional) × 1 – Raspberry Pi 4 or Raspberry Pi 5 with power supply, 2GB RAM is sufficient – 32 GB microSD card, recommended using SanDisk Extreme PRO × 1 – 2.5 inch SATA hard drive, recommend one or two SSDs – USB 3.0 to SATA adapter, recommended using one or two Sabrent adapters – Raspberry Pi OS system image (64-bit headless version) – NAS software for Raspberry Pi OS, recommended openmediavault – M3 brass threaded inserts × 10 – M3 x 5 screws (4 more screws for the second hard drive) × 10 – M2.5 brass threaded inserts × 4 – M2.5 x 6 screws × 4 – M3 x 6 countersunk screws × 4 – Keystone module RJ45 Cat 6 × 1 – RJ45 Cat 6 patch cable (length or color does not matter) × 1 – USB C male connector for soldering × 1 – USB C female connector with 2 pins and wire × 1 – SH1106 1.3 inch OLED module I2C 128X64 4 pins × 1 – 4 pin cable with Dupont female connector × 1

Configuring Raspberry Pi

Installing the Raspberry Pi Operating System Image

DIY Raspberry Pi NAS: A Practical and Elegant Solution

DIY Raspberry Pi NAS: A Practical and Elegant Solution

The easiest way to install the operating system image on the Raspberry Pi is to use the Raspberry Pi Imager. You can download it here: Raspberry Pi Imager https://shumeipai.nxez.com/download#tools

The Raspberry Pi Imager is very easy to use: – Insert the micro SD card into the computer – Start the Raspberry Pi Imager – Select the Raspberry Pi model – Select the operating system -> choose “Raspberry Pi OS (other)” -> choose “Raspberry Pi OS Lite (64-bit)” – In “Select storage”, choose your micro SD storage card – Click “Next” and follow further instructions

Customize Raspberry Pi boot settings: – Hostname – Username – Password – Time zone – Keyboard layout – Enable SSH -> check

After the imaging process is successfully completed, insert the SD card into the SD card slot of the Raspberry Pi. Then connect the power cable and network cable to the Raspberry Pi and wait for it to boot. After a few minutes, check the router to determine the IP address assigned to the Raspberry Pi. Now, you can log in to the Raspberry Pi via SSH.

Assigning a Static IP Address

Tip: Network devices like NAS should always have a fixed IP address. A fixed IP address can be set in the Raspberry Pi operating system through openmediavault or statically assigned on the DHCP server.

Network Name Resolution

Name resolution can be done through DNS. If there is no DNS server in your network, the hostname can also be stored in the hosts file on all computers in the network. The NAS can also operate without name resolution but can only be accessed via its IP address.

Updating and Installing Program Files

For a freshly installed operating system, we recommend installing any missing updates immediately. Log in to your Raspberry Pi via SSH and run the following command (if you are in China, please be cautious about updating due to slow download speeds):

sudo apt-get -y update && sudo apt-get -y upgrade && sudo reboot

This command will search for and install all available updates in the system and reboot the system when completed.

After successfully rebooting the Raspberry Pi, log in to SSH again and run the following commands one by one to install some software packages we will need:

sudo apt-get -y install i2c-tools sudo apt-get -y install python3-pip sudo apt-get -y install python3-psutil sudo apt-get -y install python3-luma.oled

After installing all the packages, you can shut down and power off the Raspberry Pi.

Printing Shell Components and Assembly

DIY Raspberry Pi NAS: A Practical and Elegant Solution

DIY Raspberry Pi NAS: A Practical and Elegant Solution

DIY Raspberry Pi NAS: A Practical and Elegant Solution

DIY Raspberry Pi NAS: A Practical and Elegant Solution

DIY Raspberry Pi NAS: A Practical and Elegant Solution

The NAS case consists of only four parts, and you can download the shell blueprint for printing from the project repository:

https://make.quwj.com/project/510

Installing the Device in the Rack

DIY Raspberry Pi NAS: A Practical and Elegant Solution

DIY Raspberry Pi NAS: A Practical and Elegant Solution

After printing the shell, use a soldering iron to melt the four M2.5 brass threaded inserts into the rack, and after installing the Raspberry Pi and hard drive using M2.5 brass threads and screws, connect the hard drive to the Raspberry Pi using a SATA to USB cable.

Preparing the Shell Tray

DIY Raspberry Pi NAS: A Practical and Elegant Solution

DIY Raspberry Pi NAS: A Practical and Elegant Solution

After printing the shell tray, use a soldering iron to insert six M3 brass threaded inserts into the bottom of the shell tray to secure the rack, and then insert another four M3 brass threaded inserts at the cover connection points.

DIY Raspberry Pi NAS: A Practical and Elegant Solution

DIY Raspberry Pi NAS: A Practical and Elegant Solution

The next step is to prepare the power connection. Since the power opening in the printed shell is too small, the wires of the USB socket must be soldered to the USB plug inside the shell. When starting to solder the plug, remember to slide the connector shell over the wire. Solder the black wire to pin G and the red wire to pin V. The positions of these pins may vary depending on the manufacturer of the USB plug. Finally, slide the shell over the USB plug and drop a bit of hot glue on the shell to better secure the plug.

DIY Raspberry Pi NAS: A Practical and Elegant Solution

DIY Raspberry Pi NAS: A Practical and Elegant Solution

Since the OLED screen is very sensitive, do not apply too much pressure when connecting the OLED screen. You can slightly bend the shell to place the display into the bracket. The top side of the display has four terminal connectors; place the bottom side of the display into the bracket, and then snap it into place with the top side and two brackets.

Installing the Rack in the Cabinet

DIY Raspberry Pi NAS: A Practical and Elegant Solution

Place the rack into the cabinet and secure it with six M3 screws, and insert the USB-C connector into the power port of the Raspberry Pi.

Assembling the Network Cable

Using a keystone module for network connections has many advantages compared to direct wiring. The LAN port can be accessed from the outside, and you can easily connect and disconnect the LAN cable. If you are currently using Raspberry Pi 4 as a NAS and wish to upgrade to Raspberry Pi 5 later, you do not need a new shell, as the internal adapter is very flexible and fits both Raspberry Pi 4 and Raspberry Pi 5.

Connecting the network cable:

DIY Raspberry Pi NAS: A Practical and Elegant Solution

– Cut one end of the jumper cable to 25 cm and strip 3 cm of insulation from the cable opening end. – Bend the shielding layer back to touch the wire and wrap the shielding layer around the cable.

DIY Raspberry Pi NAS: A Practical and Elegant Solution

DIY Raspberry Pi NAS: A Practical and Elegant Solution

– Remove the cling film around the wire

DIY Raspberry Pi NAS: A Practical and Elegant Solution

– Pass the wire through the frame: wires for pins 1, 2, 3, and 6 are on the left side, and wires for pins 4, 5, 7, and 8 are on the right side.

DIY Raspberry Pi NAS: A Practical and Elegant Solution

– Secure the wire in the frame and cut it with side cutting pliers

DIY Raspberry Pi NAS: A Practical and Elegant Solution

– Push the frame onto the contacts and close the metal shell until it securely snaps into place

DIY Raspberry Pi NAS: A Practical and Elegant Solution

– Use zip ties to eliminate stress

DIY Raspberry Pi NAS: A Practical and Elegant Solution

– Install the keystone correction module onto the cabinet. First, insert the module from the top, then swing it down until the plastic hook snaps into place – Connect the jumper connector to the network socket of the Raspberry Pi – Now connect the network cable and power to the NAS and check if the network connection is normal

Assembling the OLED Display

DIY Raspberry Pi NAS: A Practical and Elegant Solution

DIY Raspberry Pi NAS: A Practical and Elegant Solution

DIY Raspberry Pi NAS: A Practical and Elegant Solution

DIY Raspberry Pi NAS: A Practical and Elegant Solution

DIY Raspberry Pi NAS: A Practical and Elegant Solution

DIY Raspberry Pi NAS: A Practical and Elegant Solution

Connect the four pins of the OLED to the GPIO pins on the Raspberry Pi that are closest.

– GPIO Pin 1 <=> VCC – GPIO Pin 3 <=> SDA – GPIO Pin 5 <=> SCK – GPIO Pin 9 <=> GND

The pin positions on the OLED display may vary by manufacturer. Be sure to check the pin names on the display before connecting it to the GPIO pins of the Raspberry Pi!

Installing the OLED Program

DIY Raspberry Pi NAS: A Practical and Elegant Solution

You can find the program file oledinfo.py in the project repository:

https://make.quwj.com/project/510

This program will display different interfaces on the OLED screen, containing useful information about the NAS. The interface changes every 10 seconds in a loop. The brightness of the display will be reduced between 10 PM and 7 AM. Since this program is Python code, it can be easily modified according to your needs.

Before installing the software, you need to enable the I2C interface on the Raspberry Pi by logging in via SSH:

Enter the following command to launch the Raspberry Pi configuration tool

sudo raspi-config

In the configuration tool, go to “3 Interface Options” and select “I4 I2C”. You will then be asked, “Would you like the ARM I2C interface to be enabled?” Choose “” to enable the I2C interface. After confirming the success dialog, select the “” button or press the Esc key to exit the configuration tool.

Run the command

sudo i2cdetect -y 1

You will see the following:

 0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f00:             -- -- -- -- -- -- -- --10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- --40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

If you see “3c” in this table, it means the OLED display has been detected and everything is working fine. If not, please check the wiring according to the previous steps.

The oledinfo.py contains the Python code for displaying output. When your OLED display is working properly, you can copy the file oledinfo.py to the user home directory on the Raspberry Pi. The easiest way is to use the scp command to copy the file.

scp oledinfo.py [email protected]:/home/admin

Here I used the username and IP address “admin” and “192.168.1.4”, adjust the values according to your configuration.

Next, log in to your Raspberry Pi and run the following commands:

sudo mv /home/admin/oledinfo.py /usr/local/bin/ sudo chown 0:0 /usr/local/bin/oledinfo.py &amp;&amp; sudo chmod 755 /usr/local/bin/oledinfo.py

Move the file to the correct location and set the owner and permissions for the file.

Run the following command to test if the display is working properly:

/usr/local/bin/oledinfo.py

If everything is fine, your OLED screen will start displaying some output. You can stop the execution of the program by pressing Ctrl + C.

Finally, configure the file to execute every time the Raspberry Pi starts:

sudo crontab -e

Edit the crontab

@reboot /usr/bin/python3 /usr/local/bin/oledinfo.py

At the end of the crontab, when you save the file and exit the editor, the new crontab will be installed.

Reboot your Raspberry Pi to see if the display is activated at system startup:

sudo reboot

If the display does not show the openmediavault icon, do not worry, as we need to install openmediavault next to display the icon.

Installing NAS Software Openmediavault

Once the hardware is ready to run, the most important thing is: NAS software.

Of course, you can install any NAS software you like. Below, the installation of openmediavault is described because it is easy to execute and the web-based user interface makes it easy to manage.

Installing openmediavault is very simple. To install the openmediavault software, log in to the Raspberry Pi via SSH and run the command:

sudo wget -O - https://github.com/OpenMediaVault-Plugin-Developers/installScript/raw/master/install | sudo bash

After installation is complete, launch a browser on your computer and go to:

http://192.168.1.4

(Use your own IP address)

Important: Use the http:// prefix, as HTTPS is not enabled by default. You can enable HTTPS later.

The openmediavault login page should appear in the browser, and you can log in to the openmediavault instance using the following credentials:

User: admin Password: openmediavault (You can use a custom user password)

Now, you can start configuring the NAS.

The links in the article can be clicked at the end for “Read the original text.”All project files can be downloaded from the project repository:https://make.quwj.com/project/510

DIY Raspberry Pi NAS: A Practical and Elegant Solution

Leave a Comment

Your email address will not be published. Required fields are marked *