Professional Documents
Culture Documents
NanoPi M4 Server Step-by-Step Guide
NanoPi M4 Server Step-by-Step Guide
NanoPi M4 Server Step-by-Step Guide
net
NanoPi M4 Server
Sep 14, 2019
Table of Contents
The Result
The Parts
Related Work
The 3D Print
Download
Important (PLA vs Temperature)
STL files
My print settings
The Setup
The OS
The FAN
Wiring
Controlling
Starting the fan at boot
Adding a Remote Widget
Setting up a mirrored RAID (level 1)
Prepare Partitions
Assemble RAID
Performance Tests (or Playing around with 2 SSDs and mdadm)
mdadm raid level=1 (mirror)
mdadm raid level=1 (single disk)
mdadm raid level=0 (stripe)
Writing via smbd (windows shares)
The Result
A small (20x16x9cm) server based on the NanoPI M4 + SATA hat. Check my youtube video
below:
https://p3dt.net/project/2019/09/14/nanopi-m4-server.html 1/14
7/9/2020 NanoPi M4 Server | p3dt.net
The Parts
Amount Part Type Datasheet Links
Depending on what you do, the 2GB version is sufficient for you. You will need a micro SD card
( >= 8GB ) to install your OS. The 16GB eMMC is optional. I chose to use the eMMC because it is
faster than (my) micro SD cards, and it frees the micro SD card slot (so I can quickly backup my
phone).
The 12V power supply is what I had lying around, and it works. You can use something different
here, for example an ATX PSU. Check with the wiki:
http://wiki.friendlyarm.com/wiki/index.php/NanoPi_M4_SATA_HAT. Do some calculations as to
how much power you will need.
https://p3dt.net/project/2019/09/14/nanopi-m4-server.html 2/14
7/9/2020 NanoPi M4 Server | p3dt.net
The highest power consumption I could manage with two 2.5” HDDs, Streaming 3 HD Videos
via WiFi, and sound via Bluetooth was 20W. You results will vary, especially when starting up 4
HDDs. The idle power consumption with this configuration was 6W (disks spinning).
You can check the wiki for more details about this board:
http://wiki.friendlyarm.com/wiki/index.php/NanoPi_M4.
Related Work
The are other approaches to building a NanoPI M4 NAS. For example
https://www.thingiverse.com/thing:3484008. Allthough, this version is a lot sturdier than mine
(aluminium profiles!), it requires more parts, and aims for bigger (3.5” disks). As I wanted to keep
it smaller (in size, not budget), and learn something, I designed my own.
The 3D Print
Download
💾 Download the V2 .STL (2.5” HDD, tested): /assets/prints/nanopim4-server-v2-stl.zip
While idling the cpu temperature remains at 35C, with active cooling inside the case (at 25C
ambient temperature).
https://p3dt.net/project/2019/09/14/nanopi-m4-server.html 3/14
7/9/2020 NanoPi M4 Server | p3dt.net
STL files
The following STL files are in the download zips:
https://p3dt.net/project/2019/09/14/nanopi-m4-server.html 4/14
7/9/2020 NanoPi M4 Server | p3dt.net
https://p3dt.net/project/2019/09/14/nanopi-m4-server.html 5/14
7/9/2020 NanoPi M4 Server | p3dt.net
My print settings
https://p3dt.net/project/2019/09/14/nanopi-m4-server.html 6/14
7/9/2020 NanoPi M4 Server | p3dt.net
The front and back parts are printed facing down, with 0
bottom and 0 top layers, using a 15% honeycomb infill.
You can experiment here with the infill parameters of your
slicer to achieve different patterns as the mesh to let air in
and out of the server. I printed the three top parts in
3h+2h+2h=7h.
Make sure the front and back faces point down. The front
and back faces are the faces with flat holes (to avoid
support).
The Setup
The OS
I installed Armbian Buster from here: https://www.armbian.com/nanopi-m4/. You will find
instructions on how to install it on their page.
The FAN
Wiring
The fan (from the parts list) comes with black cables of which the first on has grey/white stripes.
This (first) cable is GND. The middle cable is 12V, the third I left unused. As I didn’t have the
right connector I had to wirewrap the cables onto the pins:
https://p3dt.net/project/2019/09/14/nanopi-m4-server.html 7/14
7/9/2020 NanoPi M4 Server | p3dt.net
Controlling
The socket is connected to a MOSFET which is controlled by GPIO150 . This means when you
start the server the fan is default OFF.
If you want to control the other GPIOs with WiringPi you need to install a patched version of
WiringPi, see
http://wiki.friendlyarm.com/wiki/index.php/NanoPi_M4#WiringPi_and_Python_Wrapper.
#!/bin/bash
echo 150 > /sys/class/gpio/export && echo out > /sys/class/gpio/gpio150/direction
Make it executable:
chmod +x /root/bin/initFan.sh
@reboot /root/bin/initFan.sh
https://p3dt.net/project/2019/09/14/nanopi-m4-server.html 8/14
7/9/2020 NanoPi M4 Server | p3dt.net
Reboot your system and check with cat /sys/class/gpio/gpio150/value if the value 1 is
returned.
Prepare Partitions
In my case the devices where /dev/sdc and /dev/sdd . The installation on the eMMC chip is
on the device /dev/mmcblk1p1 . Both disks are the same, and will be formatted the same:
fdisk /dev/sdc
fdisk /dev/sdd
Create a new primary partition with default parameters (i.e. the entire disk):
https://p3dt.net/project/2019/09/14/nanopi-m4-server.html 9/14
7/9/2020 NanoPi M4 Server | p3dt.net
Assemble RAID
Then assemble the raid (⚠make sure to adapt this to the correct disks first (the /dev/sd[c-
d]1 part)!):
Format it with
mkfs.ext4 /dev/md0
Make sure to use a sensible value for <pass> for your system.
mount /mnt/SSD
I got the following results using two SSD SanDisk SDSSDP256G (2013 era):
The SATA hat shows promising speeds, especially if you consider the size of the setup. With a
Marvell 88SE9215 chip which is connected via PCI-E 2.0
(https://www.marvell.com/storage/system-solutions/assets/Marvell-88SE92xx-002-product-
brief.pdf), we get max theoretical speeds of up to 500MB/s
(https://en.wikipedia.org/wiki/PCI_Express#PCI_Express_2.0).
For the size and cost of the setup, I am more than happy with these results
https://p3dt.net/project/2019/09/14/nanopi-m4-server.html 11/14
7/9/2020 NanoPi M4 Server | p3dt.net
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 9.74968 s, 220 MB/s
80+0 records in
80+0 records out
8388608000 bytes (8.4 GB, 7.8 GiB) copied, 27.3931 s, 306 MB/s
Let’s check if the measured write speeds get better with larger files (in my theory this represents
a better average of writespeed, again only for bulk):
200+0 records in
200+0 records out
20971520000 bytes (21 GB, 20 GiB) copied, 71.0981 s, 295 MB/s
Lightning read and write performance of up to 490mb/s read speeds and 350mb/s write speeds.
https://p3dt.net/project/2019/09/14/nanopi-m4-server.html 12/14
7/9/2020 NanoPi M4 Server | p3dt.net
Recreate the disks, see above. Some more details how to destroy your raid config:
https://forum.ivorde.com/mdadm-how-can-i-destroy-or-delete-an-array-t85.html
Recreating the disks with fdisk and rebooting already worked for me.
Create a RAID0:
200+0 records in
200+0 records out
20971520000 bytes (21 GB, 20 GiB) copied, 52.7125 s, 398 MB/s
This looks like twice the speed obtained vs the mirrored raid configuration.
p3dt.net
pauls-3d-
things
pauls_3d_things
https://p3dt.net/project/2019/09/14/nanopi-m4-server.html 14/14