2020-05-26: This guide is now updated to reflect some bug fixes and changes in mdadm and Samba.
Contents
Introduction
Today I’ll show you how to build a Raspberry Pi 3/4 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 (not for noobs) 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+, RPi 3/4 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/4
- Search Amazon for “Raspberry Pi 4 Starter Kit”
- Search Amazon for “Raspberry Pi 4”
- 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 Amazon 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 Drives | RAID Level Availability |
---|---|
2 |
|
3 |
|
4 |
|
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).
- Download the latest version of Raspbian Lite from raspberrypi.org
- Click on and extract the .img file and take note of it’s location
- If not already installed, download and install Etcher for Windows, Linux or MAC
- Insert your MicroSD card into a card reader, close any automatic windows, prompts or alerts
- 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)
- Click on the Select Image button, navigate to your Raspbian .img file, select it and/or click Open
- Once you’re sure you have everything right by double checking, click on the Flash! button
- Etcher will now start the flashing process, click Yes to the Windows prompt, and close any automatic alerts/windows that appear shortly afterwards
- Flashing should take about 5 minutes, then you’ll be presented with the “Flash Complete!” dialog
- Close Etcher, remove the card reader and MicroSD card
- 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 will automatically expand the file system to fit your MicroSD card size, then it will reboot. Once rebooted, login with username: pi password: raspberry
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:
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:
Update & Install MDADM
Now we just need to update Raspbian and install the mdadm RAID package:
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install mdadm -y
Setup Drives and RAID Volume
Just to make things easier for identifying our USB drives, we need to format and label each one sequentially:
- Windows
- Insert one of your USB drives (close any automatic windows)
- (Win7,XP,Vista) Go to Start > Computer (Win8,10) search “File Explorer” and open top result
- Right-click on the USB drive icon, then select Format
- In the Format window, change the following options: File system: NTFS, Volume label: USB01
- Now click the Start button, then Yes to alert box
- Repeat this process for each USB drive you want to use, increment Volume label: to USB02, USB03 etc
- MAC OS X
- Insert one of your USB drives (close any automatic windows)
- Go to Finder > Applications > Utilities > Disk Utility
- Locate the USB drive from the left hand-side and select it
- Click on the Erase tab and choose the following options: Format: ExFAT, Name: USB01
- Now click on Erase button, then confirm the Erase on the alert box
- Repeat this process for each USB drive you want to use, increment Name: to USB02, USB03 etc
- Linux (Ubuntu/Debian)
- Insert one of your USB drives (close any automatic windows)
- Open “All applications” icon bottom-left of your screen, then choose Utilities > Disks
- Select the USB drive from left side panel, then click the Gears icon, select Format partition
- Choose the following options: Erase: Don’t overwrite existing data (quick), Type: NTFS, Name: USB01
- Now click Format… button, then confirm by clicking Format button on alert window
- 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:
sudo blkid
Which should produce something like the following:
pi@RASPINAS:~ $ sudo blkid
/dev/mmcblk0p1: LABEL="boot" UUID="CDD4-B453" TYPE="vfat" PARTUUID="498dcd43-01"
/dev/mmcblk0p2: LABEL="rootfs" UUID="72bfc10d-73ec-4d9e-a54a-1cc507ee7ed2" TYPE="ext4" PARTUUID="498dcd43-02"
/dev/sda1: LABEL="USB01" UUID="8A44B0F244B0E1DD" TYPE="ntfs" PARTUUID="01411281-01"
/dev/sdb1: LABEL="USB02" UUID="2CF48901F488CE90" TYPE="ntfs" PARTUUID="bd5d9029-01"
/dev/sdc1: LABEL="USB03" UUID="A8CE3E46CE3E0D56" TYPE="ntfs" PARTUUID="0fb30d0e-01"
/dev/sdd1: LABEL="USB04" UUID="3AC2CC7DC2CC3F3F" TYPE="ntfs" PARTUUID="0fb30d2b-01"
/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
/dev/sda1: LABEL="USB01"
/dev/sdb1: LABEL="USB02"
/dev/sdc1: LABEL="USB03"
/dev/sdd1: LABEL="USB04"
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:
(Note for RAID-0 arrays: If you get error: “mdadm: RUN_ARRAY failed: Unknown error 524” this is a bug due to drives not being exactly the same size for RAID-0 which has been fixed but Raspbian hasn’t updated yet).
sudo mdadm --create --verbose /dev/md/vol1 --level=0 --raid-devices=2 /dev/sda1 /dev/sdb1
If I were using 4 drives in my RAID-0 array the code would be as follows:
sudo mdadm --create --verbose /dev/md/vol1 --level=0 --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
Setup a RAID-1 Volume
To setup a redundant RAID-1 array using two drives, enter the following code:
sudo mdadm --create --verbose /dev/md/vol1 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
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:
sudo mdadm --create --verbose /dev/md/vol1 --level=4 --raid-devices=3 /dev/sda1 /dev/sdb1 /dev/sdc1
If I wanted a RAID-5 array using three drives and a hot spare, I would use the following code:
sudo mdadm --create --verbose /dev/md/vol1 --level=5 --raid-devices=3 /dev/sda1 /dev/sdb1 /dev/sdc1 --spare-devices=1 /dev/sdd1
Setup RAID-10 Volume
To setup a fast, redundant RAID-10 (aka Nested RAID-1+0) use the following code:
sudo mdadm --create --verbose /dev/md/vol1 --level=10 --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
For more info on complex RAID arrays, see the mdadm Wiki.
Confirm your RAID Array
Now let’s confirm all went well creating your RAID array with the following command:
sudo mdadm --detail /dev/md/vol1
Which should produce something like this:
pi@raspberrypi:~ $ sudo mdadm --detail /dev/md/vol1 /dev/md/vol1: Version : 1.2 Creation Time : Mon May 25 06:19:08 2020 Raid Level : raid1 Array Size : 7808000 (7.45 GiB 8.00 GB) Used Dev Size : 7808000 (7.45 GiB 8.00 GB) Raid Devices : 2 Total Devices : 2 Persistence : Superblock is persistent Update Time : Mon May 25 06:23:01 2020 State : clean, resyncing Active Devices : 2 Working Devices : 2 Failed Devices : 0 Spare Devices : 0 Consistency Policy : resync Resync Status : 14% complete Name : raspberrypi:vol1 (local to host raspberrypi) UUID : 9ca39f48:7c165518:5b186d64:c1ca774e Events : 2 Number Major Minor RaidDevice State 0 8 1 0 active sync /dev/sda1 1 8 17 1 active sync /dev/sdb1
Save your RAID array
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:
sudo -i
Now we can save our RAID array by entering the following code:
mdadm --detail --scan >> /etc/mdadm/mdadm.conf
It’s also good to confirm it was saved by viewing the config file nano /etc/mdadm/mdadm.conf
and look for something like this at the bottom of the file:
# This configuration was auto-generated on Fri, 19 Jan 2018 08:14:18 +0000 by mkconf
ARRAY /dev/md/vol1 metadata=1.2 name=RASPINAS:0 UUID=0d7c55bd:ae5f8fbc:0e048a15:79de5064
Then exit from root user:
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 (replace /dev/md/vol1
with your RAID array name):
sudo mkfs.ext4 -v -m .1 -b 4096 -E stride=32,stripe-width=64 /dev/md/vol1
If successful, you should see the following output (accounting information can take a minute or two):
pi@RASPINAS:~ $ sudo mkfs.ext4 -v -m .1 -b 4096 -E stride=32,stripe-width=64 /dev/md/vol1
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, 3829760 blocks 3829 blocks (0.10%) reserved for the super user
First data block=0 Maximum filesystem blocks=2151677952 117 block groups 32768 blocks per group,
32768 fragments per group 8192 inodes per group Filesystem UUID: 394fd8f2-7b2a-474f-8e58-48b81a6ca8fb
Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
pi@RASPINAS:~ $
Now mount the file system so we can access it using the following command:
sudo mount /dev/md/vol1 /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:
sudo blkid
Which should produce something like the following:
pi@RASPINAS:~ $ sudo blkid
/dev/mmcblk0p1: LABEL="boot" UUID="CDD4-B453" TYPE="vfat" PARTUUID="498dcd43-01"
/dev/mmcblk0p2: LABEL="rootfs" UUID="72bfc10d-73ec-4d9e-a54a-1cc507ee7ed2" TYPE="ext4" PARTUUID="498dcd43-02"
/dev/mmcblk0: PTUUID="498dcd43" PTTYPE="dos"
/dev/sda1: UUID="0d7c55bd-ae5f-8fbc-0e04-8a1579de5064" UUID_SUB="f954ff33-87db-4e26-8be9-e978aa0ef815" LABEL="RASPINAS:0" TYPE="linux_raid_member" PARTUUID="bd5d9029-01"
/dev/sdb1: UUID="0d7c55bd-ae5f-8fbc-0e04-8a1579de5064" UUID_SUB="eea15556-4e0a-1985-163a-064670df9db2" LABEL="RASPINAS:0" TYPE="linux_raid_member" PARTUUID="01411281-01"
/dev/md/vol1: UUID="394fd8f2-7b2a-474f-8e58-48b81a6ca8fb" TYPE="ext4"
/dev/sdc1: UUID="0d7c55bd-ae5f-8fbc-0e04-8a1579de5064" UUID_SUB="2a8456d7-6fea-eba2-7728-ebd20aa238e5" LABEL="RASPINAS:0" TYPE="linux_raid_member" PARTUUID="0fb30d2b-01"
/dev/sdd1: UUID="0d7c55bd-ae5f-8fbc-0e04-8a1579de5064" UUID_SUB="51019b58-995f-cf35-f6c3-33d61a104d76" LABEL="RASPINAS:0" TYPE="linux_raid_member" PARTUUID="0fb30d0e-01"
The item we’re after is the UUID of /dev/md/vol1:
(if your volume name doesn’t show, it’ll be called “md127” or similar, this is a bug in mdadm, but continue the guide using the name you gave your array) which in my case is 394fd8f2-7b2a-474f-8e58-48b81a6ca8fb
but yours will be different. Highlight and copy the UUID and paste into a text editor, then add it to fstab and backup the original fstab just in case:
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):
UUID=your_uuid /mnt ext4 defaults 0 0
So, my fstab entry would look like this:
UUID=394fd8f2-7b2a-474f-8e58-48b81a6ca8fb /mnt ext4 defaults 0 0
Now save Ctrl+O and exit Ctrl+X.
By default, root user owns the /mnt
file system with no read or write permissions, so we need to change that as follows:
sudo chown -R pi:pi /mnt
sudo chmod -R 0777 /mnt
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 (choose Yes to window prompt during installation):
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):
sudo smbpasswd -a pi
Which should produce the following result if successful:
pi@RASPINAS:~ $ sudo smbpasswd -a pi
New SMB password: [ENTER PASSWORD]
Retype new SMB password: [CONFIRM PASSWORD]
Added user pi.
pi@RASPINAS:~ $
Before we start altering the SAMBA config file, let’s make a backup:
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
Now we edit the smb.conf file:
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:
# NAS Share
[NAS]
path = /mnt
comment = RasPi NAS Share
valid users = pi
writable = yes
browsable = yes
create mask = 0777
directory mask = 0777
The save Ctrl+O and exit Ctrl+X. Now let’s make sure our changes work, enter the following:
testparm
Which should product the following (if you want a full output, press Enter at the prompt):
pi@RASPINAS:~ $ testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
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:
sudo systemctl restart smbd
Connect to your NAS
(Please Note: Windows is a p.i.t.a when it comes to accessing your NAS if you get it wrong the first time, so please make sure you get it right first time. If you get any errors like “…Disconnect all previous connections to the server or shared resource and try again.” see this guide.)
Now let’s connect to your NAS share and make it automatically show up in your Network drive. Open File Explorer 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 host-name during Debian setup, if you’re unsure enter the hostname
command) and hit Enter
Map Network Drive
You can make your NAS a permanent drive if you like. Open File Manager and go to Computer/This PC, click the Computer tab, then Map Network Drive. Enter the host-name of your NAS followed by the shared folder name: \\RASPINAS\NAS
and choose a drive letter. If successful you should be redirected to the NAS shared folder. You can now go to My Computer/This PC and see your network drive there permanently.
Summary
ETA (8th Sept. 2020) โ I have had some comments regarding file systems not mounting after reboot and other extraneous errors. I have gone through the guide 3 times to make sure everything works, and it does 100%, so if you’re having troubles:
- Make sure you download the latest version of Raspberry Pi OS
- Please make sure you have followed each step carefully
- Take note of my comments in red
- Confirm the installation mdadm/samba
- Make sure you enter the correct info on fstab
- Again, follow each step carefully
Well I hope this guide has shown you some cool RPi 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.
Noob Sailboat says
Is there a good tutorial on how to use madm to troubleshoot RAID, rebuild, etc?
Richie says
Howdy, yes there are a few good tutorials on troubleshooting RAID arrays with mdadm:
Is there are particular issue you’re having?
cheers!
Richie
Nick says
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
Richie says
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
Pocoil says
Hello Richie,
Thank you for this well written tutorial !
I seem to have the same Issue as Nick. I am not able to write nor read anything inside the “NAS” folder.
Here is my NAS config inside smb.conf:
# NAS Share
[NAS]
path = /mnt
comment = RasPi NAS Share
valid users = pi
browseable = yes
read only = no
writeable = yes
create mask = 0777
directory mask = 0777
While browsing I have seen both syntaxes for browsable/browseable and writable/writeable so guess the issue doesn’t lie there.
Thanks for your help,
Pocoil
Janik says
I had the same problem. My solution was:
sudo chmod 777 /mnt
i know 777 is a bit over kill and unsecure but it’s okay for my need’s.
btw is thre a way to first connect this to usb drives to an “normal pc” copy the data onto them and then connect them to a pi so the first time setup is faster because i wan’t to use them as a offside backup
Thomas Lynn Skean says
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!
Richie says
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
Kelly Murphy says
How is the response time with USB 2.0? Are there any performance bottlenecks?
Richie says
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
Lance says
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!
djkelly99 says
correct, this needs to change. samba doesn’t exist under init.d directory
Nathan says
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?
Richie says
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
Andy says
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?
Andy says
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.
Richie says
no worries Andy, yes this guide is the best for rebuilding RAID but also take a look at the Linux guide too.
cheers!
Richie
Dan says
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?
Richie says
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
Dan Martin says
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.
Richie says
Looks good Dan and should work well. I have a similar or identical case (aluminum) and it’s fantastic.
cheers!
Richie
Dan Martin says
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
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
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.
Dan Martin says
One further question though … I see you referenced the mount “fail on boot.” Are USB drives not hot-mountable on the Pi?
Dan Martin says
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!
Dan Martin says
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.
Richie says
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
Dan Martin says
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.
Dan Martin says
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?
Dan Martin says
Sorry, I typoed up above … the string I added to /boot/cmdline.txt is “usb-storage.quirks=0bc2:2343: ” (without the quotes)
John Morgan says
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
John Morgan says
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
Yuri Volodin says
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?
Benoit says
Hi,
Just a noob question…
Is it possible to follow this tutorial using 2x 1To of SSD drives with external energy supplied ?
Thanks
Ed Johnson says
Hi. On RaspPi4b with 4 Gb RAM, the command to restart Samba is just:
“sudo samba restart”
I was also able to use “sudo /etc/init.d/smbd restart”, but I don’t think that restarted the nmbd daemon.
Same thing with “sudo service smbd restart”. It worked but didn’t restart nmbd.
Bill says
Hi, great guide – thanks. Going to try it. Is there an option to use JBOD rather than RAID 0? Thank you.
Evan says
Ive completed the guide, it is very good.
If anyone can find the drive at the end look at the pictures.
Dont have “Network\\hostname” only type \\hostname in the address bar.
Ive set up a RAID 5 with 10 500GB HDDs.
Only problem that i am having now is saving data to the NAS.
From windows 10, i am inside the mounted network drive “NAS (//sparkserver)” and press RMB to quickly add a .txt file.
I recieve a message that reads:
“You need permission to preform this action”
“NAS(\\sparkserver)”
“Space free: 3.57 TB”
“Total size: 3.57 TB”
Buttons: “Try Again” and “Cancel”
Try Again refreshes the message and cancel closes it.
testparm results read:
[NAS]
comment = RasPi NAS Share
path = /mnt
read only = no
valid users = pi
Any thoughts?
LT says
I run into this error message when trying to setup a raid 1 volume, using (2) Seagate Expansion 1TB Portable Drive – 1TB, External Hard Drive, USB 3.0 – STEA1000400
pi@raspberrypi:~ $ sudo blkid
/dev/mmcblk0: PTUUID=”d4b0c6d3″ PTTYPE=”dos”
/dev/mmcblk0p1: SEC_TYPE=”msdos” LABEL_FATBOOT=”RECOVERY” LABEL=”RECOVERY” UUID=”A070-7205″ TYPE=”vfat” PARTUUID=”d4b0c6d3-01″
/dev/mmcblk0p5: LABEL=”SETTINGS” UUID=”2b530f44-2442-4fc7-97f7-9057e8b352d1″ TYPE=”ext4″ PARTUUID=”d4b0c6d3-05″
/dev/mmcblk0p6: LABEL_FATBOOT=”boot” LABEL=”boot” UUID=”0B95-3D60″ TYPE=”vfat” PARTUUID=”d4b0c6d3-06″
/dev/mmcblk0p7: LABEL=”root” UUID=”7b049bce-b185-4b25-bc0c-0f9c72a3870d” TYPE=”ext4″ PARTUUID=”d4b0c6d3-07″
/dev/mmcblk0p8: SEC_TYPE=”msdos” LABEL_FATBOOT=”System” LABEL=”System” UUID=”3379-1328″ TYPE=”vfat” PARTUUID=”d4b0c6d3-08″
/dev/mmcblk0p9: LABEL=”Storage” UUID=”8c20ddb3-5c93-4ccd-84ea-e5e580798dc2″ TYPE=”ext4″ PARTUUID=”d4b0c6d3-09″
/dev/sda1: LABEL=”Seagate Expansion Drive” UUID=”F4E05762E0572A5E” TYPE=”ntfs” PTTYPE=”atari” PARTUUID=”10205715-01″
/dev/sdb1: LABEL=”Seagate Expansion Drive” UUID=”C6AE8284AE826D2D” TYPE=”ntfs” PTTYPE=”atari” PARTUUID=”e5c552c6-01″
pi@raspberrypi:~ $ sudo mdadm –create –verbose /dev/md0 –level=mirror –raid-devices=2 /dev/sda1 /dev/sdb1
mdadm: super1.x cannot open /dev/sda1: Device or resource busy
mdadm: ddf: Cannot use /dev/sda1: Device or resource busy
mdadm: Cannot use /dev/sda1: It is busy
mdadm: cannot open /dev/sda1: Device or resource busy
Raphael says
Thanks a lot for your guidance!
I belive though, that the Create File System Part misses a sudo:
mkfs.ext4 -v -m .1 -b 4096 -E stride=32,stripe-width=64 /dev/md0
should be
sudo mkfs.ext4 -v -m .1 -b 4096 -E stride=32,stripe-width=64 /dev/md0
Further i had some issues with creating the raid array:
sudo mdadm –create –verbose /dev/md0 –level=mirror –raid-devices=2 /dev/sda1 /dev/sdb1
resulted in:
mdadm: super1.x cannot open /dev/sda1: Device or resource busy
mdadm: ddf: Cannot use /dev/sda1: Device or resource busy
mdadm: Cannot use /dev/sda1: It is busy
mdadm: cannot open /dev/sda1: Device or resource busy
I could resolve this by un-mounting the volume in the File Explorer. Hope this helps other people ๐
Cheers
Steven Lundahl says
Excellent, step-by-step article! Thanks! I did run into a couple issues along the way including the SAMBA restart issue mentioned by a previous writer. The biggest problem I had ultimately was an ownership permissions issue because I could see the NAS volume from Windows but not write to it. The volume was owned by root and I could not write to it so I used chown to change ownership to the pi user.
Donald W Lively says
Excellent instructions.
I was wondering what type of transfer speeds I should expect using a Pi 4 with 4 Gig Ram and a USB 3.0 drive enclosure for 4 3.5 drives. My drives are 7500 RPM SATA drives of 3TB each and when I configure them for a RAID 10 I end up with a little over 5TB of storage.
When I try to copy over data off of my DROBO 5N connected via ethernet to the new NAS I set up, I am only getting speeds of around 2.7 to 3 MB per second which is taking forever. Is that normal or should I see better transfer rates or is there something I can tweak with SAMBA or on the Pi to make it faster?
Thanks!
Don
Richie says
Hi Don, what sort of transfer rate do you get from your PC to the Pi NAS? You should be getting faster transfer speeds but it could be a raft of reasons why you’re not. Here are some resouces to read mate:
cheers
Richie
Kev says
Excellent tutorial. I’ve got it running on a Pi 4 with 4x64GB USB sticks. It runs perfectly.
I haven’t tried hot swapping one of the disks yet, need to learn how mdadm works before I start messing about. Have you tried it?
Richie says
Thanks Kev. I haven’t tried hot-swapping but I’m sure it’ll work fine, mdadm is a very robust RAID system.
cheers
Richie
Anthony Donaldson says
What a great find this tutorial was and project for a PI.
I have run into a issue while trying to build the RAID. I’m using a pi 4 and 2 x WD 4TB powered my books. Everything look great until I run “sudo mdadm –create –verbose /dev/md0 –level=stripe –raid-devices=2 /dev/sda1 /dev/sdb1”
I get the following error:
mdadm: super1.x cannot open /dev/sda1: Device or resource busy
mdadm: ddf: Cannot use /dev/sda1: Device or resource busy
mdadm: Cannot use /dev/sda1: It is busy
mdadm: cannot open /dev/sda1: Device or resource busy
Any ideas on what can be causing this? All assistance appreciated.
Richie says
Hi Anthony, so it may be related to your SATA drives and hidden partitions that WD put there. Can you try again except this time format the drives as follows:
diskpart
to run the DiskPart programlist disk
and identify your 2 USB drives (be careful here! Make sure you know the DISK numbers!)select disk #
replacing # with your disk numberclean
to fully clean the diskLet me know how you go mate.
cheers
Richie
Anthony Donaldson says
Hi Richie,
Thanks for the reply and I solved it simply by using gparted to unmount the drives. Once this was done I could then create the RAID.
I think that as they were mounted MDADM was showing them as busy.
It is now working fine and I’m just struggling with SAMBA. I created a folder\share called “Backup” and can map to the NAS and see created folders but cannot open the folders. It’s permission related according to Windows. I want to use the NAS for windows backups so still a work in progress.
Thanks again for a great doc
Richie says
Hi Anthony, ok I have been through the guide and fixing some issues that have arised due to bugs and updates to mdadm and Samba, should be ready later today. One of the issues if file permissions which is why you’re getting that Windows error. It can be fixed by the following commands
chown -R pi:pi /mnt
chmod -R 0777 /mnt
Hopefully that’ll fix it mate.
cheers
Richie
Alessandro says
Many thanks for this article. I have 2 questions:
– I already have 2 drives, same size and model, and I want to use them for a RAID 1. In particular, the first drive already has lots of precious data on it, the second is empty. Can I configure RAID 1 without format the first drive?
What if I first copy all the files from Drive 1 into the second, before the setup? Should I then start working in RAID 1 in this condition?
Or is it mandatory to start the RAID configuration with both the drives empty?
– Let’s say I’ve set up my Raspberry with RAID 1 successfully. Then one day I unplug one drive and I use it on another PC. Say that I create/delete some files.
Then I re-attach the drive into the Raspberry. Will the changes be replicated automatically on the second drive?
Many thanks for the support
Richie says
Hi Alessandro, no problems glad you liked it. Unfortunately you can’t restore or save your data and make a RAID array, you’ll need to buy another drive big enough to hold the data and transfer to it, or just buy another drive and use that on the RAID array instead of your drive with the data.
cheers
Richie
Alessandro says
Ok thanks, and what about the second question?
Richie says
Hi Alessandro, ok second question, nope you can’t do that either. RAID arrays can’t used like that. You would need to use a USB drive and transfer that way. cheers.
Anthony Donaldson says
Hi Richie,
Just wanted to let you know that I ran thru the whole build again with the updated build guide and it has worked flawlessly.
Thanks for the great guide and your kind assistance.
I rate it 11 out of 10 mate ๐
Cheers
Ant
Richie says
Thanks Anthony ๐ cheers, Richie
Stephen Schmidt says
I just received my first Raspberry Pi. I successfully set up mirrored drives. Decided that I want to add a drive and go raid 5. Can you tell me what I need to do? There is no data on the array yet. I am a Linux noobie. Thanks
Stephen
Richie says
Hi Stephen, great stuff and congrats. You would need to delete the mirror, add the new drive, then create the RAID-5 array:
sudo umount /mnt
sudo mdadm --stop /dev/md/vol1
mdadm --remove /dev/md/vol1
Then create you RAID-5 array. I recommend starting fresh and start the guide from beginning including formatting the USB drives in Windows.
cheers
Rich
Wara says
I tried Raid 0 and there is an ” Unknown error 524 “as it was mentioned in the steps it was a bug on raspberry pi so what i am looking for is there any exeptional method to use Raid 0 for 2 different sizes of usb drives without getting that error.
Also, this tutorial is really helpful and thanks for producing such a creative tutorial.
Thanks .
Richie says
Hi Wara, the only way I can see would be to force Raspbian to upgrade to the latest version of mdadm. but I was unable to find how to do this. I suggest posting on ServerFault as those guys are spot on with advice of this kind.
Cheers
Rich
Jim Harris says
Great tutorial, but as usual I need a bit of help. When creating the file system it says “….(replace /dev/md/vol1 with your RAID array name):
sudo mkfs.ext4 -v -m .1 -b 4096 -E stride=32,stripe-width=64 /dev/md/vol1…..” That is a bit confusing to me at least. I cannot find previously where the RAID array has been named. If not named already is the “/dev/md/vol1” the default name? Or, do I make a new name at this point? Thank you for the help.
Richie says
Hi Jim, ok so in the previous step you created the RAID volume, which is 2 or more disks acting as one. The volume name will be vol1 or the name you used when you created the array. The next step is to create the file system on vol1, so
sudo mkfs.ext4 -v -m .1 -b 4096 -E stride=32,stripe-width=64 /dev/md/vol1
. So they are two different steps.cheers
Rich
Martin says
Hi Rich,
You’re a star for producing this guide. Thanks
I’m a pi newbe as well …
I’ve completed all of the steps successfully! 3rd attempt ๐
Now over to the windows 7. I get asked for the passwd and it bombs out on me saying;
“\\NAS\nas is not accessible. you might not have permission to use this network resource…etc”
i tried another users reply of “sudo chmod 777 /mnt” and your reply of checking the passwd remember box.
neither worked …
i’d be so grateful for this last bit of help ๐
Thanks again
I’m at a loss.
Richie says
Hi Martin, mmm considering you’ve already done
sudo chmod 777 /mnt
this may be an issue with file and printer sharing settings on your PC/Win7. See this article and do solutions 1 and 2 to see if that fixes the issue: https://appuals.com/fix-you-might-not-have-permission-to-use-this-network-resource/let me know how you go.
cheers
Rich
Michael says
Hi Richie,
Awesome guide. Thank you so much for putting this together. I was able to get it up and running first try and happy so far.
One issue I have run into and I’m not sure how to proceed. When I restart my pi I am getting an error: “Cannot open access to console. The root account is locked see sulogin(8) man page for more details.”
It looks like prior to that when running through the startup there is a timeout waiting for the device after the “Started MD array monitor” and then failed dependency for /mnt and Local File Systems. I was able to get around this by editing the fstab file and commenting out the UUID (editing the file on my laptop). Then when I restart the pi with the updated file it will post fine without the NAS mounted. I undo the #, and re mount… but I’m wondering if there is a solution so I don’t have to do this every time? It seems like I’m missing something obvious here!
Michael
Richie says
Hi Michael, thanks mate. I think this is due to user root not having a default password in Raspberry Pi OS. Try the following:
sudo passwd root
and enter a new password for root, then reboot and see if that fixes the issuesudo reboot
let me know how you go.
cheers
Rich
Michael says
Hi Rich,
I just tried this and unfortunately it is the same result. It is still fixable by # UUID on Fstab and remounting though so its actually not a bad workaround in the low chance it has to reboot. If you have any other ideas or think I may have incorrectly configured something though let me know and I’ll try again!
Michael
Jason says
Great work, I got my Pi Nas up! But I’m getting some mediocre speeds on my USB 3.0 external HDDs going to my Pi 4 (approx. 20MBps on file transfer). Any idea on what the issue might be? I checked out some of the resources you linked above, but it seemed more pertinent to Pi3 issues. Not sure if I’m overlooking something…
Richie says
Hi Jason, what sort of drives are you using? and what RAID level?
Willian says
Hi really good tutorial.
Just have one question, and if instead of a disk failure my raspberry pi fails. Is it possible to recover the data in a new raspiberry?
Regards,
Richie says
Hi there, would certainly be a big job, but possible, see this article: https://www.thomas-krenn.com/en/wiki/Mdadm_recovery_and_resync.
cheers
Rich
Craig says
Richie, great tutorial!
I was wanting to set up a NAS with RAID on my home system, and was looking at buying one. A friend of mine suggested building one using a Raspberry Pi, which would be cheaper in the long run. I’ve wanted to play with the Rasp Pi since I first heard about them, and decided to give it a try.
It’s been 20+ years since I did anything in a *nix environment, but I found your tutorial/walk through, and it was perfect!
Not only was I successful, but I had a blast doing it. Brought me back to the haydays of computing before GUI.
Thanks for such a well written tutorial!
Richie says
Hi Craig, thanks for the feedback ๐ It’s my most popular guide and my personal favourite too. With your home NAS system, I would recommend an off the shelf unit, or if you want to build something yourself, use a Mini-ITX motherboard with a dedicated RAID card (LSI MegaRAID 9260-8i is what I use, with a 40mm fan to cool the heatsink). You’d need to make sure the motherboard has a PCIe x16 slot for the RAID card. You would then buy a Mini SAS to SATA breakout cable.
Hope this helps.
cheers
Rich
Gonzalo says
Hi,
Thanks for this guide. It is very useful. I bought a Raspberry Pi 4 Model B Rev 1.1 and it has:
pi@raspberrypi:/ $ cat /etc/os-release
PRETTY_NAME=”Raspbian GNU/Linux 10 (buster)”
NAME=”Raspbian GNU/Linux”
VERSION_ID=”10″
VERSION=”10 (buster)”
I have followed it, and I left the “Setup RAID” part for the end (I wanted to check SAMBA server from others computers).
Finally, when I am going to create a basic mirror raid with 2 USB disk, previously formatted with NTFS, I got an unexpected error:
pi@raspberrypi:/ $ sudo mdadm –create –verbose /dev/md/vol1 –level=1 –raid-devices=2 /dev/sda1 /dev/sdc1
mdadm: partition table exists on /dev/sda1
mdadm: partition table exists on /dev/sda1 but will be lost or
meaningless after creating array
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store ‘/boot’ on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
–metadata=0.90
mdadm: partition table exists on /dev/sdc1
mdadm: partition table exists on /dev/sdc1 but will be lost or
meaningless after creating array
mdadm: size set to 982016K
Continue creating array? y
mdadm: unexpected failure opening /dev/md127
I have been investigating a little about RAID, and I can say this:
pi@raspberrypi:/ $ cat /proc/mdstat
cat: /proc/mdstat: No such file or directory
It seems that it should show information about RAID.
Could you please tell me what do I need to do? This step is not included in your guide.
Thanks for your comment.
Richie says
Hi Gonzalo, I think you may have missed a step in my guide. Perhaps go through each step again and see how that goes.
cheers
Rich
Dave says
I got the above error and Richie is right, you missed a step. I missed setting the HOSTNAME in the raspi_config app, and it stopped mine from working. Fixed that and now it works.
Nolan L says
Great guide, thank you for writing it! One small thing I ran into on my Raspberry Pi 4 is that it would fail to reboot because of the fstab line. It failed to mount the /mnt folder, and so refused to start entirely. (This is a bit scary, but it turns out you can modify fstab by inserting the SD card into another computer; some details here: https://raspberrypi.stackexchange.com/a/95887 )
In any case, the only way I could get my fstab to work properly was to use this line instead:
/dev/md127 /mnt ext4 defaults 0 0
Bizarrely, after a reboot, mdadm no longer accepts /dev/md/vol1 and only understands /dev/md127. Also the UUID technique didn’t work for me. But this new fstab survives a reboot and mounts the /mnt folder correctly.
Hopefully this is helpful for anyone else running into the same issue. (A Pi that won’t even start up can be a bit unnerving!)
Richie says
Hi Nolan, thanks. Yes the red comments in the guide explain that. When you enter the
sudo blkid
command after creating the RAID array it may or may not showvol1
, it may also showmd127
or another number.cheers.
Rich
Kenneth says
I have the same problem..
except the line you provided does not fix it for me.
UUID=devices_uuid /mnt ext4 defaults 0 0 –> not working
/dev/md127 /mnt ext4 defaults 0 0 –> not working
/dev/md/vol1 /mnt ext4 defaults 0 0 –> not working
i have followed all the steps in the guide.
yes, it can be unnerving… hopefully there is a fix to this
Richie says
Hi Kenneth, when you say it ‘doesn’t work’ what error messages are you getting if any? The line you’re referring to should be
UUID=your_uuid /mnt ext4 defaults 0 0
replacingyour_uuid
with the uuid of your device, for exampleUUID=394fd8f2-7b2a-474f-8e58-48b81a6ca8fb /mnt ext4 defaults 0 0
. Are you opening fstab as root using sudo? Make sure your fstab file is saving the info, after you enter data and exit, open up again and confirm the data was saved in the file.I’ve been through this guide many times and works 100% so you must be entering something wrong or missing a step mate.
cheers.
Kenneth says
thanks for the reply!
yes, i am using the uuid of /dev/md127 instead of devices_uuid..
and also editing as sudo.
i get locked out just as Nolan L described. removing the line from the fstab file on another computer allows me to boot again.
once booted up i can mount the raid volume without problems… only using fstab it will lock me out
Kenneth says
I forgot to note that i am not using usb thumbdrives.
this (https://wiki.radxa.com/Dual_Quad_SATA_HAT#Quad_version) is holding the two drives i am using for RAID1.
all of the steps of your guide worked out. apart from the fstab automount.
i am thinking of adding a mount command in a startup script.. but the fstab solution would be cleaner.
Richie says
Hi Kenneth, it must be something to do with the SATA HAT as I just went through the guide again and works fine (including auto mount via fstab). Perhaps take a look at the documentation for the SATA HAT and RAID auto-mount. cheers.
Kenneth says
I found a fix on the manufacturers forum. thanks for your time and for the tutorial, Richie!
TYPHOON345( i don't really wanna give my real name) says
Great guide, all the coding for my pi went perfectly well! But for my case, I’m trying to access my NAS from my mac, is there any way for me to connect to my NAS from a macbook?
Richie says
Hi there and glad the tutorial went well. You can connect your Mac to the Samba share following these instructions: http://agriculture.montana.edu/it/support/smb-macs.html. Let me know how you go ๐
cheers
Rich
Juan Aguilera says
Hi Richie,
Great tutorial, already ordered the hardware to play with it. However I mostly use MAC OS, would you see any reason why I wouldn’t be able ta access the NAS from my MAC
Cheers
Juan
Richie says
Hi Juan, great glad you liked the tutorial. Yes you can connect to the SAMBA share via MacOS, see this guide: https://www.techrepublic.com/article/how-to-connect-your-macos-device-to-an-smb-share/.
cheers
Rich
Steve says
Thanks for this excellent step-by-step guide!
I did have a couple difficulties getting the Samba volume writable and ended up with the following settings in the smb.conf file that have worked for me, for better or for worse, in case it helps anyone else that has this issue.
[NAS]
path = /mnt
force user = pi
guest ok = yes
writeable = yes
browsable = yes
It should be noted that this pi is in my own home, not an enterprise setting, and it’s heaviest use is as a backup server for several laptops so security is less of an issue.
Thanks again!
Tasos says
Hi! Thank you for the comprehensive article and all the info provided in it and in comments section.
I would like to ask if there might be a problem if in a RAID1 configuration, the 2 disks are connected on a single docking station and the station is connected to the Raspberry via a single USB 3.0 cable. Is there any need to have them connected separately or not?
Richie says
Hi Tasos, no problems. There shouldn’t be any issue using the dock but please remember, this setup/guide is really for learning purposes and not for a rugged RAID storage solution. For that I would suggest my new article on building a NAS server. cheers, Rich
Wesley says
Has anyone had a challenge with an error message “error splicing file: input/output error”? All the steps seem to have worked but now I’m faced with this error and not a lot to go on.
Richie says
Hi Wesley, that’s a new one for me and I couldn’t find much info on it either. Were you copying from an optical disk by any chance?
cheers
Rich
Scott says
Excellent tut! I had my raid 1 made already but was having issues filling in the gaps with the partitions and the Sabma share part. Found your page and 15 minutes later….done and done. Thank you!
Richie says
Glad it helped Scott. cheers.
Virag Padalkar says
Works like a charm. Just one thing to add. If you want to give multiple users access you have to create samba user profiles, add them to the smb.conf file and then change permissions for the /mnt folder to ensure all users have access. Thanks for sharing this. Was a fun experiment.
Richie says
That’s some great info Virag, thanks for adding. cheers.
Michael says
Thank you so much for this guide! ๐ I was able to successfully do this with 4 USB flash drives. Planning to replicate this with a better server!
Richie says
No worries Michael.
Peter says
Hi,
I went through your guide and everything went as expected however I am unable to write to the drive I get “You need permission to perform this action” when I try to create a folder. I also get on properties everyone allow full control “Error… \\Raspberrypi\nas access is denied” PS I have windows 7 and have just started Piing around
Pete
Dorian says
Hi Pete,
When you map the network drive you need to enter the username pi and whatever password you chose. If it doesn’t ask for a username + password at the start of mapping the drive, choose “use alternative credentials”.
Hope this helps, I’m on W10 and fairly new to Pi’s too!
Dorian
Dorian says
Hi! I just wanted to say a big thanks for this well written guide.
It was very helpful for me making a Pi 4 RAID NAS.
I had issues with the “mdadm: RUN_ARRAY failed: Unknown error 524” when setting Raid 0, even though I was using 4 identical drives. The solution was to format the drives in the Pi, deleting the windows partition so that I only had SDA1, SDB1 etc. I could then make the RAID array.
Anyway thanks a lot for a great guide.