Since NAS devices on the market are usually worth a lot of money, if you have a Raspberry Pi in hand, it's very affordable for engineers to DIY one themselves.
We can customize the shape of the shell according to their own preferences:
- Only the power and cable ports remain.
- Both ports are located on the back and next to each other.
- The USB connectors and cables must all be located inside the enclosure to ensure a clean and aesthetically pleasing design.
- Simple to print, no need for overly complex components
- Available for Raspberry Pi 4 and 5
- Multi-line OLED display
- All components are inexpensive and readily available.
The process of building this NAS device required not only a certain amount of hand-building experience, but also skills in 3D printed enclosure components, soldering techniques, and software configuration.
Component List
- 3D printer that can print 200 x 200 mm or more × 1
- Soldering iron, recommended for threaded insert tips × 1
- Cutter × 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, SanDisk Extreme PRO recommended × 1
- 2.5-inch SATA hard drive, one or two SSDs recommended
- USB 3.0 to SATA adapter, one or two Sabrent adapters recommended
- Raspberry Pi OS system image (64-bit without desktop)
- NAS software for Raspberry Pi OS, openmediavault recommended
- M3 brass threaded inserts × 10
- M3 x 5 screws (4 screws for second hard disk drive) × 10
- M2.5 brass thread inserts × 4
- M2.5 x 6 screws × 4
- M3 x 6 countersunk head screws × 4
- Keystone Module RJ45 Cat 6 × 1
- RJ45 Cat 6 patch cable (length or color does not matter) × 1
- USB C type male connector plug for soldering × 1
- USB C-type female connector jack 2-pin with cable × 1
- SH1106 1.3-inch OLED module I2C 128X64 4-pin × 1
- 4-pin cable with DuPont female connector × 1
Configuring the Raspberry Pi
Installing the Raspberry Pi Operating System Image
To install an operating system image on the Raspberry Pi visit the following URL: https://rockbee.cc/pages/raspberry-pi-os.
Raspberry Pi Setup:
- Hostname
- Username
- Password
- Time zone
- Keyboard Layout
- Enable SSH -> Checked
Once the mapping process has completed successfully, insert the SD card into the SD card slot of the Raspberry Pi. Then connect the power and network cables to the Raspberry Pi and wait for the Raspberry Pi to boot up. After a few minutes, check your router to make sure that an IP address has been 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 a NAS should always have a fixed IP address. A fixed IP address can be set in the Raspberry Pi operating system via openmediavault or as a static assignment on a DHCP server.
Network name resolution
Name resolution can be accomplished through DNS. If you do not have a DNS server on your network, hostnames can also be stored in a hosts file on all computers in the network.The NAS can also operate without name resolution, but can only be accessed through its IP address.
Update and Installation Programs
For a fresh installation of the operating system, we recommend installing any missing updates immediately. Log in to your Raspberry Pi via SSH and run the following commands (be careful with the update operation if you are in the country as download speeds can be slow):
1
|
sudo apt-get -y update && sudo apt-get -y upgrade && sudo reboot
|
This command will search for and install all available updates on the system, and reboot the system when it is done.
Once the Raspberry Pi has rebooted successfully, log in to SSH again and run the following commands one by one to install some of the packages we will need to use in a moment:
1
2
3
4
|
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 turn the Raspberry Pi off and power it down.
Printing Enclosure Parts and Assembling
The NAS enclosure consists of only four parts and can be printed by downloading the enclosure drawings from the Project File Library:
https://make.quwj.com/project/510
Mounting the unit in the rack
Once the enclosure has been printed, use a soldering iron to melt the four M2.5 brass threaded inserts into the rack.
After installing the Raspberry Pi and the hard disk through the M2.5 brass threads and screws, connect the hard disk to the Raspberry Pi using the SATA to USB cable.
Preparing the enclosure tray
After printing the enclosure tray, use a soldering iron to attach six M3 brass threaded inserts to the bottom of the enclosure tray to hold the rack in place, and another four M3 brass threaded inserts to the lid attachment points.
Next, prepare the power connections. The wires for the USB receptacle must be soldered to the USB plug inside the enclosure since the enclosure's printed power opening is too small.
Remember to slide the connector housing over the wires as you begin to solder the plug. Solder the black wire to pin G and the red wire to pin V. The connector will not be able to be used as a power supply. The location of these pins may vary depending on the USB plug manufacturer. Finally, slide the housing onto the USB plug, dropping a little hot melt glue onto the housing to better secure the plug.
Because OLED screens are very sensitive, do not put too much pressure on the display when attaching the OLED screen. Bend the case slightly to place the display into the stand, which comes with four lug connectors on the top side of the display, place the bottom side of the display into the stand, and snap it into place with the top side and the two brackets.
Installing the rack in the cabinet
Place the rack into the cabinet and secure it with six M3 screws and plug the USB-C connector into the power port on the Raspberry Pi.
Assembling the network cable
Using the keystone module for network connectivity has many advantages over direct cabling. the LAN port is externally accessible, and you can connect and disconnect LAN cables very easily. If you are currently using a Raspberry Pi 4 as a NAS and wish to upgrade to a Raspberry Pi 5 at a later date, a new enclosure is not required as the internal adapter is very flexible and fits both the Raspberry Pi 4 and Raspberry Pi 5.
Connect the network cable:
Connect the network cable:
- Cut 25 cm off one end of the patch cable and strip 3 cm of insulation from the open end of the cable.
- Wrap the shield around the cable by bending it back to touch the wires.
- Remove the plastic wrap from around the wire
- Pass the wires 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.
- Secure the wires in the frame and cut them off with the side cutter
- Push the frame over the contacts and close the metal half shell until it snaps securely into place
- Use tie wraps to remove stress
- Install the trapezoidal correction module to the cabinet. Insert the module into the top first, then swing it down until the plastic hooks snap into place
- Plug the patch cord connector into the Raspberry Pi's network socket
- Now connect the network cable and power supply to the NAS and check that the network connection is working properly
Assemble the OLED display
Connect the four pins of the OLED to a few GPIO pins on the Raspberry Pi that are close to each other.
- GPIO pin 1 <=> VCC
- GPIO pin 3 <=> SDA
- GPIO pin 5 <=> SCK
- GPIO Pin 9 <=> GND
Pin locations on the OLED display may vary depending on the manufacturer. Be sure to check the pin names on the display before connecting it to the Raspberry Pi's GPIO pins!
Installing the OLED Program
You can find the program files in the project file repository:
oledinfo.py
In this program, a different interface is displayed on the OLED display containing useful information about the NAS. The interface changes every 10 seconds and the cycle repeats. The brightness of the display will decrease between 10pm and 7am. Since the program is Python code, you can easily modify it to suit your needs.
Before installing the software, you need to enable the Raspberry Pi's I2C interface and log in to your Raspberry Pi via SSH:
Start the Raspberry Pi Configuration Tool by entering the following command
1
|
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?"
Select " " to enable the I2C interface. After confirming the success dialog, select the "<Finish>" button or press Esc to exit the configuration tool.
Run the following commands
1
|
sudo i2cdetect -y 1
|
You will see the following
1
2
3
4
5
6
7
8
9
|
0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- |
If you see "3c" in this table, the OLED display has been detected and everything is fine. If not, check the wiring as described in the previous steps.
The program file oledinfo.py contains the Python code to display the 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 to do this is to copy the file using the scp command.
1
|
scp oledinfo.py admin@192.168.1.4: /home/admin
|
The username and IP address I'm using here are "admin" and "192.168.1.4", adjust the values according to your configuration.
Next log into your Raspberry Pi and run the following commands:
1
2
|
sudo mv /home/admin/oledinfo .py /usr/local/bin/
sudo chown 0:0 /usr/local/bin/oledinfo .py && 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 commands to test that the display is working properly:
1
|
/usr/local/bin/oledinfo .py
|
If all is well, your OLED screen will begin to display some output.
You can stop the execution of this program by pressing Ctrl + C.
Finally, configure the file to be executed each time the Raspberry Pi starts up:
1
|
sudo crontab -e
|
Edit the crontab
1
|
@reboot /usr/bin/python3 /usr/local/bin/oledinfo .py
|
Go to the end of crontab and when you save the file and leave the editor, a new Crontab will be installed.
Reboot your Raspberry Pi to see if the display is active at system startup:
1
|
sudo reboot
|
If the display does not show the openmediavault icon, don't worry as we will need to install openmediavault next to get the icon to show.
Installing the NAS software Openmediavault
Once the hardware is ready to run, the most important thing is: the NAS software.
Of course, any favorite NAS software can be installed. In the following, the installation of openmediavault is described because it is easy to perform 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:
1
|
sudo wget -O - https: //github .com /OpenMediaVault-Plugin-Developers/installScript/raw/master/install | sudo bash
|
Once the installation is complete, launch a browser on your computer and go to:
1
|
http://192.168.1.4 |
(IP address as per your own)
IMPORTANT: Use the http:// prefix as the HTTPS protocol is not enabled by default. HTTPS can be enabled later.
The openmediavault login page should be displayed in your browser and you can log in to the openmediavault instance using the following credentials:
User: admin
Password: openmediavault
(You can use a customized user password)
Now, it's time to start configuring the NAS.
Source: MAKER: Frank Bernhardt / Translation: RockBee Team