0% found this document useful (0 votes)
419 views31 pages

Build A Raspberry Pi RAID NAS Server - Complete DIY Guide - Ricmedia

This document provides instructions for building a Raspberry Pi RAID NAS server using USB flash drives. It details the necessary hardware, installing Raspbian on the Pi, updating packages, installing mdadm for RAID functionality, formatting and labeling drives, and creating a RAID volume.

Uploaded by

lijuncq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
419 views31 pages

Build A Raspberry Pi RAID NAS Server - Complete DIY Guide - Ricmedia

This document provides instructions for building a Raspberry Pi RAID NAS server using USB flash drives. It details the necessary hardware, installing Raspbian on the Pi, updating packages, installing mdadm for RAID functionality, formatting and labeling drives, and creating a RAID volume.

Uploaded by

lijuncq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

HOME TUTORIALS HELP FEED

You are here: Home / Linux / Build a Raspberry Pi RAID NAS Server –
Complete DIY Guide

Build a Raspberry Pi RAID NAS


Server – Complete DIY Guide
August 5, 2019 by Richie — 32 Comments

Introduction
Today I’ll show you how to build a Raspberry Pi 3 RAID NAS server using
USB flash drives and the Linux native RAID application mdadm, along with
SAMBA so the drive will show up as a normal network folder on Windows
PC’s. It’s an intermediate tutorial and shows you how to create a Linux RAID
array which is a good skill to have.

Hardware Requirements
Raspberry Pi
You can use Raspberry Pi’s from version 2 onward, so 2B, 2B+ and RPi 3’s
are fine, but I recommend the latest Raspberry Pi 4 with 4GB RAM. You’ll
also need a good quality micro-USB power pack suitable for the Raspberry Pi
you’re using, if in doubt, just buy a combo pack that comes with case, power
pack and other goodies.

Where to purchase a Raspberry Pi 3


Search eBay.com for “Raspberry Pi 3 Starter Kit”
RS Components (massive inventory, world wide online stores)
Farnell/Element14 (massive inventory, world wide online stores)

USB Flash Drives


We will be using USB2.0 flash drives for our RAID array, however you can
purchase USB3.0 drives if you’re using a Raspberry Pi 4 (which has 2 USB3.0
ports) and RAID levels 0 or 1. The drives should all be the same size and
preferably the same manufacturer for a good RAID array however, if you have
an odd one out, just make sure it’s the same size or larger than the smallest
drive.

In terms of drive size, your budget will be the determining factor, so just get
what you can afford. Remember that with RAID-0 you get the total amount of
all drives put together, so 2x 64GB drives will give you 128GB. RAID-1 will
halve your total capacity, so 2x 64GB drives will give you 64GB, and RAID-5/6
will give you roughly 2/3 of total capacity, so 3x 64GB drives will give you
128GB of storage. RAID-10 will halve your total capacity, so 4x 64GB drives
will give you 128GB storage (more about RAID levels further below).

Where to purchase USB drives


Search eBay.com for “USB Flash Drive”
NewEgg USB Flash Drives (available for most countries)
Scorptec USB Flash Drives (Australia)
Scan USB Flash Drives (U.K/Europe)

RAID Levels
The number of drives you have with determine what RAID level you’ll be able
to create. I suggest 3 (or more) drives which is the minimum required for a
RAID-4/5 array that offers a good balance between redundancy and speed. If
you only have 2 drives, I suggest using RAID-0, and even though there is no
redundancy, RAID-0 rarely fails on solid state media. I have had my
workstation running on SATA-3 SSD RAID-0 for years and it never skips a
beat, but If you’re storing important files, go with RAID-1.

If you’re confident in your Linux skills you can create a RAID-10 array with 4
drives, which is 2 sets of RAID-1, then each set is used to form a RAID-0
array giving you the benefit of speed and redundancy (I will show you how to
create all types of Linux RAID arrays).

NUMBER OF
RAID LEVEL AVAILABILITY
DRIVES

RAID-0 Stripe (Fastest, but no redundancy)


2 RAID-1 Mirror (Excellent redundancy, good speed)

RAID-0 Stripe (Fastest, but no redundancy)

RAID-4 Dedicated parity disk (Good speed &

redundancy)
3
RAID-5 Block-level striping with distributed parity

(Excellent speed & redundancy)

RAID-6 Block-level striping with two parity blocks

4 distributed across all member disks (Excellent speed &

redundancy)
RAID 10 (nested RAID 1+0) (Excellent speed and

redundancy)

Once you’ve chosen a desired RAID level, let’s move onto Install/Update
Raspbian and mdadm.

Installing Raspbian
Now we need to prepare our MicroSD card, install Raspbian, update the
system and install mdadm Linux RAID. You will need a MicroSD card of 8GB
or more and the application Etcher to transfer the .img file to it (Etcher
supports Windows, Linux and MAC).

1. Download the latest version of Raspbian Lite from raspberrypi.org


2. Click on and extract the .img file and take note of it’s location
3. If not already installed, download and install Etcher for Windows, Linux
or MAC
4. Insert your MicroSD card into a card reader, close any automatic
windows, prompts or alerts
5. Fire up Etcher which should detect the MicroSD card automatically
(important! if you have multiple choices, be sure to choose the SD card
we are working with)
6. Click on the Select Image button, navigate to your Raspbian .img file,
select it and/or click Open
7. Once you’re sure you have everything right by double checking, click on
the Flash! button
8. Etcher will now start the flashing process, click Yes to the Windows
prompt, and close any automatic alerts/windows that appear shortly
afterwards
9. Flashing should take about 5 minutes, then you’ll be presented with the
“Flash Complete!” dialog
10. Close Etcher, remove the card reader and MicroSD card
11. Insert the MicroSD card into your Raspberry Pi
Raspbian Initial Setup
Now we need to do some initial setup of Raspbian, so go ahead and hook up
a screen, keyboard and power up your Raspberry Pi and remember, on first
boot your RasPi
1. Choose your will automatically
2. Navigate expand
to 3. Click the file4.system
on the to fit your
Etcher will 5. MicroSD
Flash
microSD
card size,drive,
then it your RaspbianOnce
will reboot. Flash! button in
rebooted, flash
login theusername:
with .img complete
pi
then click raspberry
password: .img file and Etcher file to your
choose image select it microSD card

raspi-config Options
Now we’ll do some basic setup options for our RasPi NAS server, so enter
the following and use raspberry for the password prompt:

bash
sudo raspi-config

Then change the following:

Note* Use the Arrow keys to move up and down, use Enter key to
select/confirm, use Tab key to select Cancel or Finish
Select “Change User Password” and change user:pi’s password
Select Hostname, then type RASPINAS for host-name (or anything you
want) hit Ok
Select Interfacing Options > SSH, then Yes to enable
On Home Screen, hit Tab key until the <Finish> item is selected, hit
Enter to reboot
You Raspberry Pi is now configured

Step-by-step screenshots of the above process:

1. Enter 2. Enter 3. Select 4. Click OK 5. Enter your 6. Click OK


username pi sudo raspi- Change user to confirm new
and config password password
password
raspberry
Update & Install MDADM
Now we just need to update Raspbian and install the mdadm RAID package:

7. Select 8. Select 9. Click on 10. Enter 11. Select 12. Select


bash
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install mdadm -y
then click
OK
Setup Drives and RAID Volume
Just to make things easier for identifying our USB drives, we need to format
and label each one sequentially:

13. Select 14. Click on 16. Click on


1.
YesWindows
to OK Yes to
2. Insert
enable the one of your USB drives
reboot (close any automatic windows)
3. service
SSH (Win7,XP,Vista) Go to Start > Computer (Win8,10) search “File
Explorer” and open top result
4. Right-click on the USB drive icon, then select Format
5. In the Format window, change the following options: File system:
NTFS, Volume label: USB01
6. Now click the Start button, then Yes to alert box
7. Repeat this process for each USB drive you want to use, increment
Volume label: to USB02, USB03 etc

1. MAC OS X
2. Insert one of your USB drives (close any automatic windows)
3. Go to Finder > Applications > Utilities > Disk Utility
4. Locate the USB drive from the left hand-side and select it
5. Click on the Erase tab and choose the following options: Format:
ExFAT, Name: USB01
6. Now click on Erase button, then confirm the Erase on the alert box
7. Repeat this process for each USB drive you want to use, increment
Name: to USB02, USB03 etc

1. Linux (Ubuntu/Debian)
2. Insert one of your USB drives (close any automatic windows)
3. Open “All applications” icon bottom-left of your screen, then choose
Utilities > Disks
4. Select the USB drive from left side panel, then click the Gears icon,
select Format partition
5. Choose the following options: Erase: Don’t overwrite existing data
(quick), Type: NTFS, Name: USB01
6. Now click Format… button, then confirm by clicking Format button on
alert window
7. Repeat this process for each USB drive you want to use, increment
Name: to USB02, USB03 etc

Now it’s time to insert your USB drives into your Raspberry Pi, it doesn’t
matter which drive goes where. We need to find out the mount points for
each drive using the following command:

bash
sudo blkid

Which should produce something like the following:

bash
pi@RASPINAS:~ $ sudo blkid
/dev/mmcblk0p1: LABEL="boot" UUID="CDD4-B453" TYPE="vfat"
/dev/mmcblk0p2: LABEL="rootfs" UUID="72bfc10d-73ec-4d9e-a54a-
/dev/sda1: LABEL="8GB01" UUID="8A44B0F244B0E1DD" TYPE="ntfs"
/dev/sdb1: LABEL="8GB02" UUID="2CF48901F488CE90" TYPE="ntfs"
/dev/sdc1: LABEL="8GB03" UUID="A8CE3E46CE3E0D56" TYPE="ntfs"
/dev/sdd1: LABEL="8GB04" UUID="3AC2CC7DC2CC3F3F" TYPE="ntfs"
/dev/mmcblk0: PTUUID="498dcd43" PTTYPE="dos"
pi@RASPINAS:~ $

We need to confirm the mount points of our USB drives, most of the time it
will be /dev/sda1, /dev/sdb1, /dev/sdc1 and /dev/sdd1

bash
/dev/sda1: LABEL="8GB01"
/dev/sdb1: LABEL="8GB02"
/dev/sdc1: LABEL="8GB03"
/dev/sdd1: LABEL="8GB04"
If you have different mount points than shown here, it doesn’t really matter,
you’ll just need to replace the code snippets with the mount points you have.
It also doesn’t matter if the drive labels are out of order, just so long as they
match up to your mount points.

Depending on how many drives you have, choose your RAID level and follow
the instructions for your chosen level below.

Setup RAID-0 Volume


Enter the following code to setup two or more USB drives into a high-
performance RAID-0 array in parallel, replacing --raid-devices=X with
the number of drives you’re using, and /dev/sda1 /dev/sdb1 with your
mount points:

bash
sudo mdadm --create --verbose /dev/md0 --level=stripe --raid

If I were using 4 drives in my RAID-0 array the code would be as follows:

bash
sudo mdadm --create --verbose /dev/md0 --level=stripe --raid

Setup a RAID-1 Volume


To setup a redundant RAID-1 array using two drives, enter the following
code:

bash
sudo mdadm --create --verbose /dev/md0 --level=mirror --raid

Setup RAID-4/5/6 Volume


To setup a redundant RAID-4, RAID-5 with three drives, or RAID-6 array with
four drives, use the following code, replacing --level=X with the RAID
level you want:

bash
sudo mdadm --create --verbose /dev/md0 --level=4 --raid-devi
If I wanted a RAID-5 array using three drives and a hot spare, I would use the
following code:

bash
sudo mdadm --create --verbose /dev/md0 --level=5 --raid-devi

Setup RAID-10 Volume


To setup a fast, redundant RAID-10 (aka Nested RAID-1+0) use the following
code:

bash
sudo mdadm --create --verbose /dev/md0 --level=10 --raid-dev

Confirm your RAID Array


Now let’s confirm all went well creating your RAID array with the following
command:

bash
cat /proc/mdstat

Which should produce something like this (replace raid10 with whatever
RAID level you chose):

markup
pi@RASPINAS:~ $ cat /proc/mdstat
Personalities : [raid10]
md0 : active raid10 sdd1[3] sdc1[2] sdb1[1] sda1[0]
15319040 blocks super 1.2 512K chunks 2 near-copies [4/4] [UU
[>....................] resync = 0.4% (61504/15319040) finish
unused devices: <none>

Save your RAID array


For some reason Raspbian won’t let us save the RAID array as user:pi even
using sudo, so we need to temporarily change to root account, enter the
following:
bash
sudo -i

Now we can save our RAID array by entering the following code:

bash
mdadm --detail --scan >> /etc/mdadm/mdadm.conf

It’s also good to confirm it was saved by viewing the mdadm.conf file and
look for something like this at the bottom of the file:

bash
# This configuration was auto-generated on Fri, 19 Jan 2018
ARRAY /dev/md0 metadata=1.2 name=RASPINAS:0 UUID=0d7c55bd:ae5

Then exit from root user:

bash
exit

Create File System


You have a number of choices when it comes to Linux file systems, but I will
be using the EXT4 file system as it’s the best choice for our RAID array. If you
want to learn more about some of the flags (stride, stripe-width, block
options) see this article. The following code will produce an EXT4 filesystem
with a block size of 4096kb, stride of 32, a stripe-width of 64 and will leave
1% free so it won’t fill up and cause issues:

bash
mkfs.ext4 -v -m .1 -b 4096 -E stride=32,stripe-width=64 /dev

If successful, you should see the following output:

bash
pi@RASPINAS:~ $ sudo mkfs.ext4 -v -m .1 -b 4096 -E stride
mke2fs 1.43.4 (31-Jan-2017)
fs_types for mke2fs.conf resolution: 'ext4'
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=32 blocks, Stripe width=64 blocks 958464 inodes, 38297
First data block=0 Maximum filesystem blocks=2151677952 117 b
32768 fragments per group 8192 inodes per group Filesystem UU
Superblock backups stored on blocks: 32768, 98304, 163840, 22
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information:

pi@RASPINAS:~ $

We also need to mount the file system so we can access it using the
following command:

bash
sudo mount /dev/md0 /mnt

We need to automatically mount the file system at boot, so let’s find out the
UUID of our mounted file system by entering the following command:

bash
sudo blkid

Which should produce something like the following:

bash
pi@RASPINAS:~ $ sudo blkid
/dev/mmcblk0p1: LABEL="boot" UUID="CDD4-B453" TYPE="vfat"
/dev/mmcblk0p2: LABEL="rootfs" UUID="72bfc10d-73ec-4d9e-a54a-
/dev/mmcblk0: PTUUID="498dcd43" PTTYPE="dos"
/dev/sda1: UUID="0d7c55bd-ae5f-8fbc-0e04-8a1579de5064" UUID_S
/dev/sdb1: UUID="0d7c55bd-ae5f-8fbc-0e04-8a1579de5064" UUID_S
/dev/md0: UUID="394fd8f2-7b2a-474f-8e58-48b81a6ca8fb" TYPE
/dev/sdc1: UUID="0d7c55bd-ae5f-8fbc-0e04-8a1579de5064" UUID_S
/dev/sdd1: UUID="0d7c55bd-ae5f-8fbc-0e04-8a1579de5064" UUID_S

The item we’re after is the UUID of /dev/md0: which in my case is


394fd8f2-7b2a-474f-8e58-48b81a6ca8fb but yours will be different.
Highlight and copy the UUID, then add it to fstab and backup the original
fstab just in case:

bash
sudo cp /etc/fstab /etc/fstab.bak
sudo nano /etc/fstab

Just before the bottom comments, make a space and enter the following on
a single line (replace [your_uuid] with the UUID of your file system):

bash
UUID=[your_uuid] /mnt ext4 defaults 0 0

So, my fstab entry would look like this:

bash
UUID=394fd8f2-7b2a-474f-8e58-48b81a6ca8fb /mnt ext4 defaults

Now save Ctrl + O and exit Ctrl + X .

Install and Setup SAMBA


SAMBA is a Windows file sharing system that runs on Linux, works
flawlessly, and is easy to setup too. Let’s install SAMBA and then configure it
with the following command:

bash
sudo apt-get install samba samba-common-bin -y

After SAMBA finishes installing, let’s add user:pi and share password by
entering the following command (enter a password at the prompts):

bash
sudo smbpasswd -a pi

Which should produce the following result if successful:

bash
pi@RASPINAS:~ $ sudo smbpasswd -a pi
New SMB password:
Retype new SMB password:
Added user pi.
pi@RASPINAS:~ $

Before we start altering the SAMBA config file, let’s make a backup:

bash
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak

Now we edit the smb.conf file:

bash
sudo nano /etc/samba/smb.conf

Scroll down to the bottom of the file using your arrow key, then add the
following code to create your NAS file share:

bash
# NAS Share
[NAS]
path = /mnt
comment = RasPi NAS Share
valid users = pi
writable = yes
browsable = yes

The save Ctrl + O and exit Ctrl + X . Now let’s make sure our changes
work, enter the following:

bash
testparm

Which should product the following (if you want a full output, press Enter
at the prompt):

bash
pi@RASPINAS:~ $ testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows l
WARNING: The "syslog" option is deprecated
Processing section "[homes]"
Processing section "[printers]"
Processing section "[print$]"
Processing section "[NAS]"
Loaded services file OK.
Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

If the line reads “Loaded services file OK.” then you’re good to go.

Finally, we need to restart the SAMBA service by with the following


command:

bash
sudo /etc/init.d/samba restart

Connect to your NAS


Now let’s connect to your NAS share and make it automatically show up in
your Network drive. Open File Explorer (Win8/10 search “File Explorer” and
open top result) (WinXP/Vista go to Start > Computer), then click on the
Network item on left-side window pane. Click inside the address bar, then
type \\RASPINAS (or whatever you chose for a hostname during Debian
setup, if you’re unsure enter the hostname command) and hit Enter

1. Enter your 2. Inside 3. Click on 4. Inside 5. Click on 6. Your new


Raspberry your NAS your NAS your NAS Map network NAS folder
Pi’s folder, then folder drive, enter as a
hostname enter your your permanent
credentials Raspberry Pi drive
hostname
and nas
folder name
Summary
Well I hope this guide has shown you some cool RasPi and Linux stuff and
that you had fun 🙂 Something to think about is adding a USB hub to expand
the drive number capacity instead of forking out big $$ for large capacity
USB drives. You can also add normal 2.5″ or 3.5″ SATA drives via a USB
adapter, see this article. If you have any questions or comments, leave them
below.

Raspberry Pi (Official)
Linux RAID Wiki
9 commands to check hard disk partitions and disk space on Linux
RAID Pi – Raspberry Pi as a RAID file server
How to Build a Raspberry Pi File Server

Filed Under: Linux, Raspberry Pi


Tagged With: DIY, Linux, mdadm, NAS, NAS Server, Network-Attached
Storage, RAID, Raspberry Pi, Raspberry Pi 3, Raspbian, RasPi, SAMBA, USB
Flash Drive

Comments

Noob Sailboat says


August 14, 2019 at 1:49 pm

Is there a good tutorial on how to use madm to troubleshoot RAID,


rebuild, etc?

Reply

Richie says
August 14, 2019 at 2:35 pm
Howdy, yes there are a few good tutorials on troubleshooting
RAID arrays with mdadm:

Detecting, querying and testing Linux RAID

How To Manage RAID Arrays with mdadm on Ubuntu


16.04

Troubleshooting Linux Software RAID (MDADM)

Is there are particular issue you’re having?


cheers!
Richie

Reply

Nick says
August 27, 2019 at 5:34 am

Hi, Thanks for making a creat tutorial. I was able to complete


everything and get my volume mounted to my Windows system. I
am however running into a permissions issue when I try to create a
new folder or access the folder that is already inside the NAS
folder. I did add my user ‘pi’ in the samba configuration per the
tutorial and I can use the credentials to mount the volume. Is there
another place I need to set permissions to allow my windows
system to store things on this mounted partition?
Thanks,
Nick

Reply

Richie says
August 27, 2019 at 4:49 pm

Hi Nick, no worries glad you liked the guide. When you got to
the “Connect to your NAS” step, were you prompted to enter
username and password on Windows? And did you check the
“Remember Credentials” checkbox?

Cheers!
Richie

Reply

Thomas Lynn Skean says


August 27, 2019 at 11:42 pm

Hi!

In the “Setup Drives and RAID Volume” section of the guide, why
choose NTFS as the filesystem to place on the individual drives
when performing the step in Linux? Is there any disadvantage to
choosing ext4?

I like your guide quite a bit. Thanks!

Reply
Richie says
August 29, 2019 at 10:40 am

Hi Thomas, thanks mate. The only reason we need to format


the drives is so we can give them a label (in this case
USB1/2/3/4) so as to visually identify them on Linux. NTFS is
overwritten with EXT4 anyway but the labels remain.

cheers!
Rchie

Reply

Kelly Murphy says


September 4, 2019 at 11:39 am

How is the response time with USB 2.0? Are there any performance
bottlenecks?

Reply

Richie says
September 27, 2019 at 10:17 am

Hi Kelly, speed overall isn’t great, this guide is more leaning


toward learning Linux software RAID and it’s a really fun
project to do. I haven’t tried on new RasPi 4 yet which has
USB3.0 so I am guessing there would be speed improvements
there.

cheers!
Richie

Reply

Lance says
September 16, 2019 at 2:13 am

I think “sudo /etc/init.d/samba restart”


Needs to be changed to:

sudo service smbd restart


sudo service nmbd restart

Thanks for the article!

Reply

djkelly99 says
November 30, 2019 at 11:53 am

correct, this needs to change. samba doesn’t exist under init.d


directory

Reply

Nathan says
September 27, 2019 at 1:35 am

I’m excited to give this a shot in my own home as I’ve never built a
RAID before. With that said, how would I rebuild this raid in the
event one drive crashes? Is it as easy as plugging in a new blank
drive and the software does it for me? or would I have to rebuild the
project?

Reply

Richie says
September 27, 2019 at 10:14 am

Hi Nathan, no you won’t need to do the whole project again


just rebuild, it’s pretty easy to rebuild after a failed drive, see
this guide: https://www.thomas-krenn.com/en/wiki
/Mdadm_recovery_and_resync

Cheers!
Riche

Reply

Andy says
October 21, 2019 at 9:26 am

Thank you so much for this comprehensive step-by-step guide! I


am thinking about building my own RAID-5 using your tutorial.
However, I also want to know if one of the drives fails, e.g. sdb1
fails, then how do I do hot swap and rebuild?

Reply

Andy says
October 21, 2019 at 9:27 am

Sorry nevermind, didn’t see that you have posted a guide in


replying to Nathan’s question. Thank you so much again, this is
very helpful.

Reply

Richie says
October 21, 2019 at 9:45 am

no worries Andy, yes this guide is the best for rebuilding


RAID but also take a look at the Linux guide too.

cheers!
Richie

Reply

Dan says
November 5, 2019 at 6:46 am

Hi Richie, very interesting guide. I’m seriously considering this


among my options, but planning to build a much larger array to
store media and photos. Wonder if you’re aware if the Pi has a limit
on the size of drives which can be connected? My intent is to use 4
x either 1TB or 2TB drives, probably 2.5″ notebook drives on USB-
to-SATA cables. Using spindle drives rather than SSD it should be
possible to do this really on the cheap, like around $40 per drive (for
real brand name like WD) and 8-dollar USB cables. If the Pi can
hack it, this could provide a 3-4 TB RAID-6 NAS for under $200.
Do you know/think Pi would cooperate in such a scenario?

Reply

Richie says
November 5, 2019 at 10:42 am

Hi Dan, no problems. Speed is the only issue, although I have


not tested this guide with the RPi 4 (4GB RAM) which may be
faster. As Raspbian is simply a modified version of Linux I
can’t see any issue with the larger drives. If it turns out the
setup isn’t speedy enough you could use a mini-itx mobo that
has a PCIe x8 oe x16 slot and a RAID card (like a LSI
MegaRAID 9260 8i) on the cheap.

Would love to hear how it goes Dan.

Cheers!
Richie

Reply

Dan Martin says


November 12, 2019 at 12:23 am

I’ve ordered the pieces … decided to go with the Vilros kit


https://www.amazon.com/Vilros-Raspberry-RAM-Basic-
Heavy-Duty-Self-Cooling/dp/B07XTN5YRN/ as it has a
fanless aluminum case which I imagine should be good
for longevity plus heat dissipation, and Seagate 1TB
external drives https://www.amazon.com/Seagate-
Portable-External-Hard-Drive/dp/B07CRG7BBH/. Will post
back with how the setup goes.

Reply
Richie says
November 12, 2019 at 9:46 pm

Looks good Dan and should work well. I have a


similar or identical case (aluminum) and it’s
fantastic.

cheers!
Richie

Reply

Dan Martin says


November 14, 2019 at 12:08 pm

Hey Richie, so my first go isn’t looking too good.


Two problems I’m finding so far:

1) the drives don’t seem to be auto-mounting …


at least, when I do the “blkid” command I’m not
getting any mounts but the original SD card. If I
do a tail -f /var/log/messages (found it on
another thread) I see evidence of the drives
being recognized (as sda, sdb, sdc, etc), but not
mounted.

2) probably more importantly, it looks like by the


time I mount the 3rd drive I’m over the current
that the Pi wants to pass through the USB bus.
I’m actually seeing an “overcurrent” fail on the
messages occasionally. And if I connect all 4
drives the power lights on all four (but not on the
Pi itself) actually go off.

I’m thinking perhaps a powered USB3 hub might


solve problem #2 … what do you think? And do I
just need to manually mount the disks to solve
problem #1?

Richie says
November 14, 2019 at 1:05 pm

Hi Dan, ahh yes the Pi won’t be able to handle


the amps for a mechanical drives so you’ll need
to power via hub or directly (sorry I didn’t think of
that earlier). The power issue may have also
caused the mount to fail on boot. Once the
power has been sorted, it should auto mount as
there is no real difference between mechanical
and flash drives in terms of filesystems.

Choosing the right powered USB3 hub will be


important, the best I can find is the Orico here.

That should fix the problems you’re


experiencing.

cheers!
Richie
Dan Martin says
November 15, 2019 at 2:01 am

I’ve ordered a slightly cheaper one but same power spec:


https://www.amazon.com/gp/product/B00TPMEOYM
/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1. Will let you
know how it goes … I’ve used Sabrent peripherals in the past and
been reasonably happy with them.

Reply

Dan Martin says


November 15, 2019 at 2:03 am

One further question though … I see you referenced the mount “fail
on boot.” Are USB drives not hot-mountable on the Pi?

Reply

Dan Martin says


November 20, 2019 at 3:39 am

Hey Richie, SUCCESS!! I’ve just completed a successful install


using your instructions, creating a RAID-5 array on a Pi 4, 4GB using
4 1-TB Seagate drives as noted above, with the Sabrent powered
USB hub to power the drives. I opted for 4-drive RAID5
configuration since this is just backup and a hot spare is probably
overkill (I’m gambling that I don’t lose more than one drive at a time
in the array, obviously). Resulting drive is 2.68 TB. Connecting to a
wired gigabit ethernet LAN, I just transferred a 1GB file from a SSD
on my desktop computer (Windows 10 Pro) to the NAS in about 17
seconds.

Two things I had to do that weren’t exactly the same as your


directions:

1) The command “sudo /etc/init.d/samba restart” did not work


because on this version of Raspian the Samba daemon is named
“smbd.” There is no “samba” in /etc/init.d.

2) I had to manually chown my /mnt folder to pi, as it started out


owned by root. This may be because I used the “sudo bash” cheat
to do all the other commands from root so I didn’t have to type
“sudo” every time, so perhaps it was my fault. But it’s worth your
readers knowing that if you can connect to the drive from Windows
and read, but not write, checking permissions/ownership may fix
the problem.

Other than that though, your instructions worked flawlessly once I


supplied sufficient power to my drives.

One other thought you may consider adding to your instructions: I


like being able to use a GUI for administrative purposes so I
installed webmin following the instructions for the APT repository
at http://webmin.com/deb.html.

Thanks for this excellent reference!

Reply

Dan Martin says


November 20, 2019 at 7:41 am

One more addition … since I care about being able to monitor


my array, I also installed smartmontools which doesn’t come
with Raspian by default. Once installed it’ll also be active in
Webmin. This is to be able to query SMART parameters for the
drives and know if they’re threatening to crash.

Just because I wasn’t having enough fun already though, it


turns out that Seagate drives tend to be unsupported using
smartmontools due to their implementation of UAS. As a
consequence one of several methods for addressing a “quirk”
in the USB driver are necessary in order to enable SMART on
those drives. The documentation for this quirk is at
https://www.smartmontools.org/wiki/SAT-with-UAS-Linux, and
the instructions for inserting the quirk into the Raspberry Pi
configuration are at https://www.raspberrypi.org/forums
/viewtopic.php?t=245931.

What I actually did was to find the vendor and product IDs of
the drives by using lsusb. In my case the Seagate drives were
0bc2:2343. So then I used nano to edit the file
/boot/cmdline.txt to add the string in front of what was
already there, save and reboot. Presto! smartctl can now query
the drives.

Reply

Richie says
November 24, 2019 at 12:29 pm

Hi Dan, awesome work mate and integrating Webmin for


monitoring is a great idea. I think if anyone else is following
this it would be optimal to use SSD’s instead of mechanical
drives as they draw much less power and many times faster:
https://www.storagereview.com/node/2567. You’d still need a
powered hub for best performance though. You could also use
large capacity USB3.0 flash drives without the need for extra
power (512GB are available but $$$). What would be ideal is to
source or build a powered USB3.0 rack for 4x SSD drives, let
the Pi run the RAID array as usual, all inside a compact unit.
eBay or some more obscure websites may have such a rack
(looking for just the USB3 rack and powered hub without any
OS).

Cheers!
Richie

Reply

Dan Martin says


November 29, 2019 at 3:57 am

I agree Richie. The only reason to go with mechanical


spindles is cost for storage. That said, my objective was a
cheap NAS, and at that we have succeeded.

Reply

Dan Martin says


December 4, 2019 at 1:41 am

Hey Richie, just one thought further … to your suggestion


of large-capacity flash drives. I’m thinking theoretically
not experimentally here, but it seems to me possible that
one might prefer to use a USB 3.0 hub (powered or not)
even with those, since the Pi has only 2 USB 3.0 ports and
two USB 2.0. The performance bottleneck of 2.0 would, it
seems to me, reduce RAID performance more than a hub
at 3.0. True?

Reply
Dan Martin says
November 20, 2019 at 7:43 am

Sorry, I typoed up above … the string I added to /boot/cmdline.txt is


“usb-storage.quirks=0bc2:2343: ” (without the quotes)

Reply

John Morgan says


November 30, 2019 at 8:48 am

Hi Ritchie, I also needed to use ‘sudo service smbd restart’ to


restart samba as Lance posted but other than that, all seemed to
be good and went smoothly. However, I cannot for the life of me get
Win 10 to see the pi. It a Pi 4 with 2 drives (ssd & sata both on
powered hub) set as a mirror. I used ‘mdadm –detail /dev/md0’ to
verify the drives are good and they are syncing, so your system is
working fine. Any tips about getting Windows to play would be
most appreciated (other than binning it!)

Regards,
John

Reply

John Morgan says


November 30, 2019 at 8:56 am

I take it all back! If I had only read your”Connect to your NAS”


correctly, it would have worked the first time.
Nice work, Ritchie.
John

Reply

Yuri Volodin says


December 5, 2019 at 4:19 am

1 When suddenly powering off, file system on microsd can be


corrupted.
2 If your system is not readonly, your microsd will die soon.
The question:
If I move writable part of OS to RAID will I be safe from the above
fails?

Reply

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

Comment

Name *
Email *

Website

Save my name, email, and website in this browser for the next time I
comment.

POST COMMENT

Copyright © 2020 · Ricmedia. All Rights Reserved

You might also like