Raspberry Pi Compute Module NAS

by Jormono in Circuits > Raspberry Pi

6537 Views, 12 Favorites, 0 Comments

Raspberry Pi Compute Module NAS

bfe15853-d10f-4ed9-b9f0-32540bd76e55_CM4+Featured+Image.png
Power Breakout.png
Waveshare Carrier Board.png
IOCrest Board.png

The goal of my project is to build a relatively robust NAS(Network Attached Storage) device with multiple high capacity hard drives with a small budget and have a fun project along the way. I use my NAS primarily as a media server running Plex. In my home, we have 3 devices that can connect to this media server (though I've never had the situation arise where more than one were in use simultaneously). So for my purposes, a super high end NAS would largely be wasted, if you need a machine for 4K video editing, this is not that. As with any project, you'll need to take into consideration what you need the project to do, and determine if a given solution will satisfy that need.

Before taking on this project, I had been running a Raspberry Pi 4B 4GB with a 4TB HDD (which I am still using in my new setup data intact). I used that setup for months with a SATA-USB adapter. I had read that you could expect a ~10% loss of transfer speed when going through USB vs SATA. I personally couldn't get more than one drive to work via USB simultaneously with any reliability. My Drive was beginning to fill up, and transferring files to it was a chore (relatively speaking), so I was looking for an upgrade. That is when I found Jeff Geerling on youtube doing interesting things with the CM4 and its PCI slot. Ultimately, I decided I wanted to try something in this vein and landed on using a M.2 SATA adapter.

I'll dive into the software at the end but know that this is NOT a guide to software. This Instructable is going to focus on the hardware I used in my build, that being said, the software is just as important and is something you'll want to consider before endeavoring on your own project.

Supplies

*** NOTE: These links are not necessarily where I purchased from, they are for your convenience only. These items may be available at lower prices elsewhere. Also note that this is not an exhaustive list, I am not including super specific items like screws or incidental items like the model of the case I used (I got it from Facebook marketplace, its a full size ATX, really anything in that form factor should work with little to no modification). ***

* Raspberry Pi CM4

* Waveshare "Mini Base Board (B) CM4 Carrier Board

* ATX Power Breakout Board

* IO Crest JMB585 SATA adapter for M.2 slot

Preparing the Build

Backplane Design.png

My plan for the build itself was to use an ATX Case + PSU to house and power my hardware, one thing I had learned from my RPi 4 + USB adapter based setup was that powering 4 hard drives, several fans, and a raspberry pi would not be a trivial matter. While I waited for the last few pieces of hardware to arrive, I came up with a plan to fabricate a "backplane" to secure the various circuit boards into an ATX form factor.

I started by finding the specifications for an ATX motherboard's anchor points that typically secure it to the case, and prepared a vector file (I used a CNC to cut my backplane and my machine + software uses vector art to guide the router, but you could print the image as a template and drill/cut the pattern for only a little more effort). Once I had the layout of the standoffs prepared, I started to gather dimensional information from the published specs of the various boards that I needed to mount on it. and added them to my file. The image I've shared here is the end result (plus a scale reference for anyone who wants to make this using the print + cut method).

My original plan was to use threaded inserts and standoffs, the inserts I ordered turned out to be the wrong size and I revised my plan to simply drill holes and run M3 screws from the back and held in place with nuts. This means that should I need to add/remove/replace any of this hardware, I'll need to take the whole backplane out of the case. Not ideal, but if I'm adding hardware I'll probably need to make modifications for that anyway.

I included a mounting for a future expansion project, which is to add a Rpi Zero W for a redundancy on my Pihole. There is plenty of space for expansion beyond even that, but I don't have any specific plans beyond adding Pihole. The Square blue box is where the power breakout board will go, the rectangular blue is the CM4 carrier board, all of the red marks are Holes to be cut/drilled, the green box is the Zero W, and the black outline around the Pi boards is the approximate location of a hole in my case where I was able to route the SATA connections through the back/under side of where the motherboard would go.

The only real problem I ran into with this plan is that the M.2 card I used is too long to fit on the carrier board, it snaps in and is a snug fit, but it isn't actually properly secured. I found that mounting it to the backplane more or less holds it in place.

The Build Itself!

1630947478449.jpg
1630947453599.jpg

Here is the exciting part (for me anyway, your mileage may vary).

I wound up using a scrap piece of hardboard to fabricate my backplane, something like plexiglass would probably be better, but this is what I had to work with and it worked out great so far.

I connected the case fans to 12V through the power breakout board, connected the CM4 carrier board to 5V via a modified USB C cable, this part was tricky as figuring out which wires were for power was not trivial (most reference material I could find did not resemble what I was working with once I had cut the cable open). I think I would recommend getting a USB type A breakout board and wire that to 5V if I were to do this again, in fact I probably will when it comes time to add the Zero W.

Testing Things Out

lspci.png
NAS TEST.png
1630947362363.jpg
1630947362360.jpg

Raspberry Pi OS now supports SATA out of the box, just make sure you've run an update, but to be sure things are working I would recommend opening the CLI (I set mine up headless, meaning it doesnt have a screen, keyboard, or mouse. I connect to it remotely from my desktop PC using a program called Putty) and running ls pci. This will identify any devices connected to the PCI connection on your pi, with the carrier board I've used the pci is exposed as an M.2 slot on the underside of the carrier board. I've included a screenshot of the result I got for your reference, but if you use a different card you could get a different result. I suggest doing this as a test to verify the card is functional before you get too far ahead of yourself configuring software.

After I had setup my software I had to answer the question of, is this actually an improvement? I'm pleased to say that yes, this is a noticeable improvement over my old setup. I've included a little chart with screenshots indicating transfer speeds of both my old and new setups which illustrates the improvement beautifully. It also feels alot more "snappy" than what it did before.

The last thing in my testing, is how much power does this use? I sadly don't have a base reference for my old setup, though I suspect that it was higher (I never bothered to build an enclosure or anything, the HDD and pi were sitting on a shelf in my basement with a deskfan blowing over them for cooling). As to my new build, the PSU I employed is a nominal 600W supply. I've found that at startup, when the drives and fans all need to spinup, it spikes to around 80W and settles down pretty quickly. Out of the box I was getting ~45-50W continuous power use with all 5 drives spinning. After some configuration, I've set it to spin down drives when not in use, which knocked the power consumption down to about half of that at 26W at idle.

Revisions

1630947453602.jpg
1630947453596.jpg
1630947362370.jpg

After running my NAS for a day or so, I quickly discovered that I did not have adequate cooling on the CM4. I had previously installed a heat sink for it, but the airflow in the case just wasn't taking the heat away fast enough. So I rummaged around and found some small fans, I hooked up a small 12V fan directly over the heat sink and that seems to be working wonderfully.

Someone pointed out to me that it is possible I will have problems with my PSU if I don't add a load to the 3.3V output. From previous experience of building a benchtop power supply, I know the typical solution for this is to add a large resistor. I would rather not add more heat to my case, so instead I've attached a 5V fan to the 3.3V output. I do not know if this will actually help or accomplish anything, It doesn't produce any functional amount of airflow, but it didn't do any better when I connected it to 5V either. My thought is for the small amount of energy it uses, it is probably doing more good than bad, and if it works, that is more than I can say about adding a resistive load. I am certainly not depending on this fan to actually do anything though, I mounted it with a twist tie to point out the back of the case, but even if it falls down into the case and "circulates air" it is accomplishing the same purpose for me.

Software

This is, as promised, not a guide to the software side of things. I am barely qualified to setup my own software so I wont pretend to know enough to tell you how to do it.

That said, below is a list of the main software packages I am employing in my system:

* Raspbian Lite - Operating system

* Open Media Vault (OMV) - Backbone of the NAS

* Docker/Portainer - "Intermediary" for OMV and Plex

* Plex - Media server platform that conveniently allows for streaming to devices on the local network

* Mergerfs - Pools storage drives together to act as a single drive (no redundancy like with RAID)

* Snapraid - Used to make a parity drive for redundancy, the parity drive can't be used for storage