Maker.io main logo

High-Speed Raspberry Pi 5 Mini NAS

2,263

2025-01-17 | By Maker.io Staff

License: See Original Project Raspberry Pi SBC

Copy of case-assembled-alt

With the addition of a PCIe interface, the Raspberry Pi 5 now supports high-speed devices like ‎NVMe SSDs, which makes building a robust network-attached storage (NAS) system at home ‎more accessible than ever. This article explores how to construct a NAS that uses an NVMe ‎SSD buffer to boost performance and Samba for seamless file sharing across devices and ‎operating systems. It also briefly introduces RAID for redundancy and dives into various ‎strategies for selecting suitable storage media, including the pros and cons of using regular ‎HDDs, dedicated NAS drives, and SSDs.‎

What You Must Know About Network-Attached Storage

‎A NAS is a device that provides file storage and sharing over a network. It lets multiple users ‎access shared files across various devices, thus eliminating the need to copy files to removable ‎media and carrying around a physical device. A NAS may work locally within a single home ‎network or let users access files online.‎

Building and managing a NAS at home eliminates the cost associated with monthly cloud ‎storage fees. It also puts users in control of their data and privacy, allowing them to better control ‎who can access their sensitive files. Conversely, operating a NAS at home means always ‎leaving a computer running. Therefore, a low-power solution, such as a Raspberry Pi, is an ‎excellent option for most individuals, as it reduces the initial cost and long-term price of operating ‎a NAS at home. ‎

This build leverages the Raspberry Pi 5’s onboard PCIe connection, allowing the computer to ‎interface with high-speed NVMe storage. However, as NVMe storage can be costly, the finished ‎NAS utilizes slower but cheaper 2.5” high-capacity HDDs, offering a fantastic trade-off between ‎price, performance, and capacity. The NVMe SSD acts as the device’s buffer that caches files ‎before persisting the data on the slower drives. These HDDs are connected to the Pi using ‎straightforward SATA to USB 3.0 converter cables, meaning those who do not want to upgrade ‎to the newest Pi can still follow the build by omitting the NVMe buffer.‎

Choosing the Storage Media

‎The previous section briefly mentions the main trilemma of selecting storage media: you must ‎choose between storage capacity, access speed, and price per storage unit, usually measured in ‎Gigabytes. In long-term storage, you must also consider reliability and robustness to errors. ‎Compared to hard disk drives (HDDs), solid state drives (SSDs) typically offer high access ‎speeds and good robustness to physical damage, as they do not contain any mechanical moving ‎parts. However, SSDs usually come in lower capacities, and high-capacity SSDs can quickly ‎cost lots of money. Finally, HDDs usually require more power to run because they contain ‎powerful motors needed to spin the disks within the SSDs at high speeds when reading and ‎writing data. Therefore, HDDs also produce more heat and noise, which may also be a factor to ‎consider when choosing suitable drives, especially when opting for the larger 3.5” HDDs, which ‎usually require an additional external 12V power supply in addition to the 5V provided by USB.‎

Typically, selecting drives boils down to a trade-off between all these factors, with most users ‎opting to use high-capacity HDDs for long-term storage due to their reduced cost. Additional ‎SSDs can serve as short-term buffers that hold incoming data before copying it to the HDDs. By ‎doing so, they help increase transfer speeds from and to devices. If additional long-term ‎reliability is needed, you may want to invest in high-quality NAS storage devices engineered to ‎operate 24/7 and offer reliability over many years. However, due to their increased reliability, ‎these particular HDDs are often more expensive and often not warranted in a consumer-grade ‎NAS.‎

Increasing the Storage Space and Reliability With RAID

‎Besides using NAS HDDs, you can also increase the overall system’s reliability by introducing ‎redundancy using multiple cheaper HDDs in a RAID configuration. RAID, or Redundant Array of ‎Independent Disks, describes how a system spreads data across multiple independent storage ‎devices, such as HDDs.‎

While many different RAID configurations exist, RAID 0 and RAID 1 are the most common. ‎RAID 0 effectively increases the overall storage capacity by combining the space of multiple ‎drives. This configuration splits data into chunks and spreads it across drives in a process called ‎striping to make more efficient use of the available storage. RAID 1 focuses on increasing the ‎system’s overall reliability by introducing redundancy. It keeps multiple copies of files on several ‎drives, thus preventing data loss if one of the drives fails. Combining RAID 0 and RAID 1 is also ‎possible, and this approach simultaneously improves a NAS's storage capacity and reliability. ‎However, the NAS can quickly become too expensive to build because it requires more drives.‎

Required Materials for Building this Project

This project utilizes the following materials:‎

Qty Part

‎1‎ Raspberry Pi 5

‎1‎ Official Raspberry Pi 5 active cooling ‎fan

‎1‎ Official Raspberry Pi 5 NVMe HAT

‎1‎ ‎512GB VNMe SSD

‎1‎ Official Raspberry Pi 5 power supply

‎1‎ SATA to USB 3.0 converter cable

‎1‎ ‎2.5” SATA HDD or SSD (5V only)

Preparing the Electronics

‎This project involves minimal electronics assembly and no soldering. The process starts with ‎attaching the heatsink and fan to the Pi using the plastic pegs on the heatsink. They push into the ‎provided holes on the SBC, and the fan cable attaches to the white connector near the USB ‎ports on the Pi:‎

Copy of cooler-assembly

Follow the outlined steps to install the Pi’s active cooling solution.‎

Installing the NVMe SSD is a bit more involved but not more difficult. Start by verifying that all ‎the necessary parts are in the package:‎

Copy of nvme-hat-components

The kit should include the NVMe HAT, a silver thumb screw, a 40-pin GPIO extension, and a ‎short flex ribbon cable. The 40-pin extension is not shown in this image. Further, you’ll need a ‎compatible SSD, which is depicted to the right of the HAT.‎

Push the 40-pin GPIO extension onto the Pi’s GPIO port, and then insert the SSD at a 45-degree ‎angle, making sure not to force it if it doesn’t fit to prevent damage:‎

Copy of nvme-assembly-1

Insert the SSD into the NVMe HAT, as shown in this image.‎

Next, secure the SSD with the silver thumb screw. Note that the screw has a small grove for the ‎SSD to sit in. Make sure that it attaches as shown in the following image:‎

Copy of nvme-assembly-2

Pay attention to the grove in the screw that ensures proper spacing between the SSD and the ‎HAT.‎

Next, open the PCIe connector’s small locking tab on the HAT by gently pulling up the black ‎plastic piece, as indicated by the arrows. Do not pull up on the white part to prevent breaking the ‎delicate connector:‎

Copy of nvme-assembly-3

Pull the black part of the connector out to unlock it.‎

Then, insert the ribbon cable with the pins facing up and push the black plastic piece back in to ‎lock the cable in place:‎

Copy of nvme-assembly-4

This image shows the installed ribbon cable on the HAT side.‎

Repeat the cable installation steps on the Raspberry Pi and then finish the installation by gently ‎bending the ribbon cable to relieve some strain from the delicate PCB connectors:‎

Copy of nvme-assembly-6

This image shows a correctly inserted ribbon cable that connects the boards.‎

3D-Printing the Enclosure and Assembly

‎The 3D-printable case is designed to work with the Raspberry Pi 5 and the official active cooling ‎solution and NVMe HAT. However, it can also fit a Raspberry Pi with or without either of these ‎attachments by adding spacers to compensate for the SBC’s reduced height. Similarly, it uses ‎‎2.5” HDDs to create a more space-saving design. However, the enclosure is modular, and you ‎can adjust the HDD enclosure to fit larger drives. Finally, the basic NAS utilizes only a single ‎HDD. However, the case is designed to allow the stacking of additional external drives.‎

Copy of case-design

This screenshot shows the case design in an exploded view, with the Raspberry Pi depicted in ‎orange and the HDD shown in blue.‎

The Pi’s enclosure sandwiches the SBC and the additional boards between the top and bottom ‎halves:‎

Copy of case-open

This image shows how the pegs on either half of the case securely lock the Pi into place within ‎the enclosure.‎

The small plastic pegs on either half ensure the electronic devices have enough space, and ‎ventilation holes dissipate heat:‎

Copy of bottom-pegs

This image shows the SBC enclosure from underneath without the drive caddy attached. The ‎screw holes align with the Raspberry Pi’s mounting points, and they are used for connecting the ‎topmost drive caddy to the SBC enclosure.‎

The external drive slides into the bottom half of the drive caddy and is secured using two ‎standard M3 screws on the diagonal corners. The top half attaches to the SBC enclosure or the ‎next HDD caddy if more than one drive is used with 2.5mm screws, which are the same ‎diameter used on the Pi. Therefore, the screws that join the topmost HDD caddy and the SBC ‎enclosure’s bottom half also screw into the standoffs that come with the NVMe HAT. Similarly, ‎the topmost case lid also attaches to the same standoffs from the other side, thus securely ‎sandwiching the Pi between the case halves.‎

Copy of top-pegs

This image highlights how the plastic pegs of each enclosure’s halves rest flush on the board. ‎The 2.5mm screws directly connect the case to the standoffs provided with the NVMe HAT.‎

Finally, the drive caddy’s other half attaches to the remaining screw holes on the HDD. No ‎additional screws are needed to close the case.‎

Copy of case-assembled

This image depicts the fully assembled enclosure.‎

The finished enclosure has cutouts to access the Pi’s power connector, USB hub, and ethernet ‎port, and the drive caddy exposes the HDD’s SATA pins, leaving enough space for the USB to ‎SATA converter cable:‎

Copy of wires-attached

The cutouts offer enough space to attach all the necessary wiring.‎

The design files for 3D printing are available for download here: ‎https://www.printables.com/model/1113056-raspberry-pi-5-nvme-nas

Preparing the NAS Software

‎At this point, all that remains is to install and configure a few tools to get the NAS up and running. ‎Even though the recommended SSDs come with Raspbian preloaded, this project utilizes the ‎default SD card method to boot the Raspberry Pi. Therefore, start by setting up a bootable SD ‎card and configuring a network interface and SSH, for example, by following this guide. Make ‎sure to update the package manager and all pre-installed programs once the computer is up and ‎running by typing the following commands in a terminal:‎

Copy Code
sudo apt update
sudo apt upgrade

Once these steps finish, use the lsblk command to ensure the Pi detects all external drives and ‎the NVMe. The program should produce output similar to this:‎

Copy of lsblk-1

This screenshot shows the output created by lsblk

Take note of the device names after verifying that all devices are present. Then, install the ‎following programs:‎

Copy Code
sudo apt install lvm2 samba samba-common-bin

Setting Up Cached Storage

The Logical Volume Manager, or LVM in short, is a system for managing disk drives in Linux. ‎This program also allows the creation of volume groups that can be used for caching. Using this ‎program’s pvcreate command lets users define physical volumes to be used in LVM:‎

Copy Code
sudo pvcreate /dev/nvme0n1
sudo pvcreate /dev/sda1

‎After preparing the volumes for use in LVM, creating a volume group pools them together to ‎create a single storage resource, allowing dynamic allocation and storage management across ‎multiple logical volumes within the same group:‎

Copy Code
sudo vgcreate vg_nas /dev/nvme0n1 /dev/sda1

The following command states that the entire HDD space should be used for storing data within ‎the vg_nas volume group:‎

Copy Code
sudo lvcreate -n lv_data -l 100%FREE vg_nas /dev/sda1

Similarly, the subsequent command defines that the entire NVMe SSD should be used as the ‎cache pool:‎

Copy Code
sudo lvcreate --type cache-pool -n lv_cache_pool -l 100%FREE vg_nas /dev/nvme0n1

Next, lvconvert transforms the previously defined volume group into a single, cached device ‎where the NVMe drive acts as the cache and the HDD as the final backing storage:‎

Copy Code
sudo lvconvert --type cache --cachevol vg_nas/lv_cache_pool vg_nas/lv_data

Running these commands ensures that the logical volume, consisting of multiple physical ‎storage media, acts as if it were a single drive, which can be accessed in /dev/vg_nas/lv_data ‎like any other physical disk. Therefore, it can also be formatted and mounted like an actual ‎physical device using the following commands:‎

Copy Code
sudo mkfs.ext4 /dev/vg_nas/lv_data
sudo mkdir -p /mnt/nas
sudo mount /dev/vg_nas/lv_data /mnt/nas

Finally, the following command appends the newly created logical volume to fstab to ensure that ‎the logical storage group is always automatically mounted during startup to the mount point ‎‎/mnt/nas:

Copy Code
echo "/dev/vg_nas/lv_data /mnt/nas ext4 defaults 0 0" | sudo tee -a /etc/fstab

Initializing Samba for Network Sharing

Once the storage devices are set up, formatted, mounted, and ready to go, you can grant users ‎access to the mount points by registering them within the previously installed Samba service. To ‎accomplish this, all you need to do is add each shared location to the end of the configuration file, ‎which can be edited by typing the following command:‎

Copy Code
sudo nano /etc/samba/smb.conf

For example, the following configuration creates a single shared folder, named SharedNAS, that ‎spans the entire mounted drives and grants read and write rights to the Pi user:‎

Copy Code
[SharedNAS]
path = /mnt/nas
valid users = pi
read only = no
browsable = yes
create mask = 0777
directory mask = 0777
guest ok = no
public = yes

After saving the modified configuration file, the Pi user must have a password to access the ‎shared location through Samba. It’s worth noting that this password can deviate from the system ‎password. However, each user who wants to access files through Samba also requires a ‎corresponding Linux user account. In either case, the Samba password can be set by typing:‎

Copy Code
sudo smbpasswd -a pi

Finally, the service needs to be restarted to apply the changes:‎

Copy Code
sudo systemctl restart smbd

To access the shared location, type in the Raspberry Pi’s IP address or hostname into the ‎location bar in the file explorer of the other device, for example, in Windows Explorer, and log in ‎with the username and password when prompted:‎

Copy of find-nas-windows

This screenshot demonstrates that the SharedNAS location appears in the Windows file ‎explorer when the Pi’s hostname is entered.‎

Managing Access Rights to Shared Locations

‎It’s also worth mentioning that the Pi user, or whoever is assigned access rights to a shared ‎location, must also be allowed to access the folder within Linux. The simplest way to achieve this ‎in this case is to make the Pi user the owner of the entire shared mounting point:‎

Copy Code
sudo chown -R pi:pi /mnt/nas

For multi-user systems, the Samba configuration can contain one shared folder per user and ‎access rights can be granted to individual folders within the shared volume, for example:‎

Copy Code
sudo chown -R pi:pi /mnt/nas
sudo chown -R dan:dan /mnt/nas/dan
sudo chown -R ben:ben /mnt/nas/ben
sudo chown -R marlene:marlene /mnt/nas/marlene

Aside from giving each user a separate folder, multi-user systems can also use individual hard ‎drives for users or groups or separate partitions or logical volumes on the same hardware. ‎

Summary

‎Building and managing a custom Network-Attached Storage device (NAS) at home offers ‎numerous benefits, such as better access control, security, and monthly expense savings. The ‎Raspberry Pi 5’s new PCIe interface makes building a high-speed storage solution that leverages ‎fast NVMe storage more accessible than ever.‎

The process of building a custom NAS is straightforward. It starts by attaching the Raspberry Pi ‎to an active cooling solution to keep it working reliably over extended periods. Then, you must ‎assemble and mount the NVMe adapter to interface fast SSD storage through the PCIe ‎interface. Finally, the build concludes by placing the Pi and all external hard drives in a beautiful ‎‎3D-printed custom case that protects the delicate electronics.‎

On the SBC, you must install three programs to create and manage virtual volumes and share ‎them over the network. In this build, the SSD storage acts as a buffer device that temporarily ‎holds incoming data before automatically copying it to the slower, more spacious HDD. This ‎approach results in faster access rates when copying data to and from the NAS.‎

When configuring Samba for network sharing, remember to add a Linux user for each user or ‎group needing access to one of the shared locations. Then, you can instruct Samba to grant ‎access to specific users and certain locations by modifying the service’s configuration file. Each ‎user must also be allowed to access the shared location within Linux. Upon setting a Samba ‎password and restarting the service, users can log into their account and access the shared ‎folders from any device within the network bounds.‎

製造商零件編號 SC1148
ACTIVE COOLER
Raspberry Pi
製造商零件編號 SC1166
M.2 HAT+
Raspberry Pi
製造商零件編號 MMR-NV2242-512
SSD 512GB M.2 PCIE TLC NVME
Cytron Technologies Sdn Bhd
製造商零件編號 SC1153
27W USB-C PSU UL(US), WHITE
Raspberry Pi
製造商零件編號 ADP001
SATA USB TO SERIAL
Pimoroni Ltd
製造商零件編號 HDKGB13A2A01T
HDD 1TB 2.5" SATA III 5V
Toshiba Semiconductor and Storage
製造商零件編號 SC1432
SBC 2.4GHZ 4 CORE 8GB RAM
Raspberry Pi
Add all DigiKey Parts to Cart
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.