boomer46
Posts: 2
Joined: Mon Dec 16, 2019 4:00 pm

Pi4 as a NAS

Mon Dec 16, 2019 7:34 pm

Hi all. I have see many post about setting up a NAS using a Pi and am a bit confused by the number of results. I want to try and get it right from the start, as I am pretty new at the use of Pis. I am thinking of using a Pi4 with 2gb of ram(with it's own ext power supply) and 2 6TB ext HDs connected to a ext powered USB3 6 port hub (which will leave me 4 open ports for more drives) plugged into the Pi. Does this sound like a reasonable way to go? What suggestions would you suggest for the operating software. I don't think I want to set up ant kind of RAID arrays, just have a separate 8TB hd on the other USB3 port to run a B/U on the systems on a scheduled time each week..
Thanks for your time and help

epoch1970
Posts: 5132
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Pi4 as a NAS

Tue Dec 17, 2019 5:21 pm

Sounds fine.
I would use Raspbian, it has the best support and about all the packages you can imagine.
RAID over USB is not an idea, steer clear of that.

I think there is something going on with powered hubs that (incorrectly) "backpower" Pi4 through the USB port. Check the forums if you need to buy a hub.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

User avatar
pi-anazazi
Posts: 716
Joined: Fri Feb 13, 2015 9:22 pm
Location: EU

Re: Pi4 as a NAS

Tue Dec 17, 2019 5:59 pm

...using NAS with mdadm software RAID on Raspi 2 for years and see no reason why this should not be viable option. Using two native USB ports for thetwo HDDs though.
Kind regards

anazazi

ejolson
Posts: 5380
Joined: Tue Mar 18, 2014 11:47 am

Re: Pi4 as a NAS

Tue Dec 17, 2019 6:36 pm

epoch1970 wrote:
Tue Dec 17, 2019 5:21 pm
Sounds fine.
I would use Raspbian, it has the best support and about all the packages you can imagine.
RAID over USB is not an idea, steer clear of that.

I think there is something going on with powered hubs that (incorrectly) "backpower" Pi4 through the USB port. Check the forums if you need to buy a hub.
With a RAID having a reliable UPS is more important, in my opinion, than the trade-off between USB3, SATA or SAS. Although it is popular to use notebook drives with the Pi, unless portability is a primary concern, I see no reason to prefer them over desktop drives.

I've been pretty happy with self-powered multiple-bay USB enclosures when setting up NAS and online backup systems and can confirm this Syba 4-bay model works with the Raspberry Pi 4B.

I'm currently using BTRFS in mirror mode on four 8TB drives. As long as one does not make too many snapshots of one subvolume the performance is adequate. Being able to consistently snapshot an active filesystem and back it up important is something I find important. The system further rotates one week and one month old snapshots as a convenient way to recover accidentally deleted files without having to restore from backup.

epoch1970
Posts: 5132
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Pi4 as a NAS

Tue Dec 17, 2019 7:01 pm

Let's see:
- Mechanically unstable because USB connectors do not lock.
- Zero performance gain (best case) due to the single shared data link.
- Fused device design: sensitive to model, make, firmware versions of the array members.
- Consumer drives firmwares not designed to run in RAID arrays.
- Increased power requirements.
- More or less inflexible setup.
- Salvaging data from a broken array is sometimes possible, always painful.

If one needs a big volume on something like a Pi, filesystem-level fusion works just as well, esp. in read access, and shows none of these drawbacks.


Addendum. Hooking a multi-drive enclosure to a Pi is not a problem. Having a RAID array hang off bits of USB cables is.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

User avatar
pi-anazazi
Posts: 716
Joined: Fri Feb 13, 2015 9:22 pm
Location: EU

Re: Pi4 as a NAS

Tue Dec 17, 2019 7:24 pm

I use WD red HDDs only.

If I compare the one NAS with only a single HDD to the ones with 2 RAID 1 HDDs there is no difference in performance (on samba max about 5-8 MB/s). But that's on Raspi 2. If I need more performance I use Odroid XU4 with USB 3, that's considerably better throughput.

What do you mean by:

"Having a RAID array hang off bits of USB cables is."

I usually have these NAS devices in older Desktop enclosures (3 NAS with 6 HDDs) or in mini ITX case (2x 2.5" HDD)
Kind regards

anazazi

tpyo kingg
Posts: 809
Joined: Mon Apr 09, 2018 5:26 pm
Location: N. Finland

Re: Pi4 as a NAS

Tue Dec 17, 2019 7:41 pm

There are apparently some SATA HATs available,

http://linuxgizmos.com/sata-hats-suppor ... rock-pi-4/

epoch1970
Posts: 5132
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Pi4 as a NAS

Tue Dec 17, 2019 8:20 pm

pi-anazazi wrote:
Tue Dec 17, 2019 7:24 pm
What do you mean by: "Having a RAID array hang off bits of USB cables is."
The fact that the USB connector was designed (with relative success) for easy connect/disconnect becomes a huge problem if the array is not physically protected in an enclosure, as you do.
Disconnecting a drive inadvertently can cause serious mishap, disconnecting half of it (or whatever share of the array that drive represents) is disastrous.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

User avatar
pi-anazazi
Posts: 716
Joined: Fri Feb 13, 2015 9:22 pm
Location: EU

Re: Pi4 as a NAS

Tue Dec 17, 2019 8:47 pm

I always use RAID 1, disconnecting 1 HDD not a problem, except that a rebuilt of some TB takes some time after adding the HDD to the RAID again :-D

Over the years I had only one cheap USB 2 to SATA adapter failing. No big issue thanks to RAID 1. I think it was December 2015 that I built my first Raspi NAS in the enclosure of an old DVD player, reusing the power supply, which provides stable 5V and 12 V, i.e. everything you need for 3.5" HDDs and the Raspi...
Kind regards

anazazi

LTolledo
Posts: 3438
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Pi4 as a NAS

Tue Dec 17, 2019 9:38 pm

My RPi4B-2G NAS build.

https://www.raspberrypi.org/forums/view ... S#p1541272

am not (as in will not ever!) implementing RAID..... as I see its troublesome and don't see any benefits on employing such.
am using timed mirroring instead. it works..... based on my requirements
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

epoch1970
Posts: 5132
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Pi4 as a NAS

Tue Dec 17, 2019 10:46 pm

My own recipe, then:

My first Pi 2 has been for a few years a (media) server at my parent's. It is a Raspbian machine, its most prominent service is Plex. I got 2 Toshiba laptop USB drives, 2TB each, and a powered USB3 hub.
The drives were formatted as hfsplus (ouch!) since we use Macs at home. Filling the drives over the network would have been just too slow (Pi 2, USB2...), but on occasion directly connected to a Mac over USB3, it is bearable.
Plex sees the global data capacity because it indexes a read-only mhddfs (superseded since by mergerfs) FUSE mount spanning over the devices 'real' r/w mounts.

If a drive dies or gets disconnected, roughly half of the data goes, and my phone would probably ring. Besides that, service can continue over the reduced dataset. Failures are not critical and urgent maintenance never required. I like that in a domestic system, especially a remote one...

No drive has died yet. In fact I had to increase storage once, and added a 1TB drive: plug in, mount, update the mhddfs mount, rescan, done.
(Hfsplus did not take a dive either, surprisingly ... The system has a quiet life, this probably explains that.)
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

iamme
Posts: 9
Joined: Wed Dec 18, 2019 5:03 am

Re: Pi4 as a NAS

Wed Dec 18, 2019 5:25 am

I like the “keep it simple” and “use what you got” if possible mode of operation. I wanted a NAS-style setup with access/backup of data from two RPis (Raspian Buster and OSMC/KODI and 2 PCs (running Windows 7P).

I put together a “raid” [not really] system using mostly what I had:

(1) RPi4/4
(2) WD 8TB USB3 Ext. Drives - NTFS
(1) USB-powered Fan (medium-sized)
(1) UPS
(1) USB HUB, powered (4-ports)

Essentially: take the two ext. USB drives and Velcro them together side-to-side. The USB-powered fan sits atop (spanning) both drives (to keep them cool). Velcro the USB Hub on one disk and (if you want) the RPi (in a case) to the other drive case. Make sure you can access the memory card and I use a power supply with a on/off switch in it. Short cables are nice, but in any case, the USB HUB and RPi power supplies are attached to the UPS. The HUB USB goes into an RPi USB 3. Socket (and one USB 3 socket is still available). The two USB drives are plugged into the USB HUB, along with the USB fan’s USB and, optionally, a USB-to-UPS status cable (and appropriate Linux UPS status daemon). The 8TP USB drives were NTFS and I kept them that way. I added Samba to allow NAS access from the PCs. Putty, ssh and/or sftp can also be used to copy files interactively or by scripts as well. Raspian auto mounts the two USB drives (A/B). Anything I want to save/backup is placed on usb-A and a cron job rsync’s from usb-A to usb-B on a regular basis. I periodically back up the RPi via script and place the image on the usb-A drive and try to always keep at least 2 memory-cards ready with current "running OK" backups on hand.

Two things that I want to do but have not as yet done include running a SMART disk daemon to get real-time-ish disk status’ and actually implementing the UPS auto-shutdown on power-fail daemon. "Hardening" the RPi would be a good step as sell since it is on 24/7 and connected to the net.

One thing that I would like to do, but is appearing to be harder than I would like, is keeping the redundant drive (“usb-b”) unmounted until just before the rsync operation (and then unmount it again). The reasoning here is that in case of an encryption-malware attack, the unmounted redundant drive would be (most likely) safe from being encrypted (assuming you found out before the next rsync).

This is KISS. I am not messing around with RAID and which OS can or cannot read it or rebuild/recover it. RAID doesn’t protect against encryption-malware. Any Linux (with NTFS drivers) or Windows OS can read/write to the drives and at any time I can yank or replace a drive and move it to another system. Also I do not need a “RAID” or “NAS” OS, just Raspian, and can enjoy all that Raspian has to offer.

ejolson
Posts: 5380
Joined: Tue Mar 18, 2014 11:47 am

Re: Pi4 as a NAS

Wed Dec 18, 2019 5:29 am

LTolledo wrote:
Tue Dec 17, 2019 9:38 pm
My RPi4B-2G NAS build.

https://www.raspberrypi.org/forums/view ... S#p1541272

am not (as in will not ever!) implementing RAID..... as I see its troublesome and don't see any benefits on employing such.
am using timed mirroring instead. it works..... based on my requirements
We've probably had this discussion before, but for those who missed it, the following can and has happened to some people who were not careful with their automatic mirroring solution:
  • The source drive fails and goes offline.
  • The automatic mirror sees an empty mount point and deletes all files in the backup to match.
Alternatively,
  • The source drive fails but stays online.
  • The automatic mirror writes corrupt data all over the backup.
While it is possible for a drive to fail without the above happening (especially if the drive which falls is the backup rather than the source), it is worth noting that mirroring one drive to another provides neither a backup nor does it increase reliability through redundancy. As long as one understands the benefits and drawbacks, of course, there is nothing wrong with that.

User avatar
pi-anazazi
Posts: 716
Joined: Fri Feb 13, 2015 9:22 pm
Location: EU

Re: Pi4 as a NAS

Wed Dec 18, 2019 7:48 am

I'm using hard- and software RAID 1 on Win and Linux for about 15 years without trouble. If one HDD dies away I quickly replace it, as the other one normally will go out of service within the next 3 to 8 months (both drives same age and make).

Otherwise no problems here...

I use raspbian (mdadm, samba) as the OS and tried NTFS as it has no user read/write troubles, but normally I take EXT4 and mess arroud for an hour or so with chmod etc. until the read/write permission fit... :-D
Kind regards

anazazi

LTolledo
Posts: 3438
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Pi4 as a NAS

Wed Dec 18, 2019 10:20 am

ejolson wrote:
Wed Dec 18, 2019 5:29 am

We've probably had this discussion before, but for those who missed it, the following can and has happened to some people who were not careful with their automatic mirroring solution:
  • The source drive fails and goes offline.
  • The automatic mirror sees an empty mount point and deletes all files in the backup to match.
Yes I remember this "discussion" before

This has been mitigated in my mirroring script, checking if the mount is empty or not ( I think you helped me with this ;) )
also I did some actual test (on another SBC setup, source and target), while rsync in progress, pulled the plug (literally) on the source network share unit, rsync immediately stopped with errors.
after restoring the power to the other SBC source, and running the mirroring script manually, the mirroring proceeded properly (checking if there files/folders exist in the mounted volume, then proceed to update the target drive.)
on the file where the mirroring was interrupted, checking and running (actually playing the video file), there were no errors.

same test was done on the target unit (yup, I also yanked the power to the target SBC). then re-run the mirroring script manually upon power restoration... seemed OK.

tried some other "scenarios" that I can think of, but it held out OK...
(well except for some really nasty scenarios like immersing in muddy water [flood], flame thrower attack [house fire], etc, anyway power will be cut off immediately before those "nasty" scenarios has its run)

but that's on my setup.... I can't vouch for other's setup..... as I have no hand on those..... ;)

Oh... forgot to mention.... there is another RPi NAS unit used for manual weekly mirroring.... just in case... :mrgreen:
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

castletonroad
Posts: 135
Joined: Sat Jul 25, 2015 11:23 pm

Re: Pi4 as a NAS

Sat Dec 21, 2019 6:50 am

I use a Pi4 2GB runing raspbian buster on a 16GB Sandisk Ultra microSD card.

I use a Toshiba U3 Dynadock as my powered external USB hub (I connect the Cat5 cable direct to the Pi4 eth0, not via the Dynadock - I didn't want the network traffic running over the Pi4's USB 3.0).

I use two 1GB Toshiba external USB drives, 'A' for the NAS, 'B' as a backup (daily of 'A', via a rsync cron job); I have a separate Pi3 with a 3rd 1GB Toshiba external USB drive, 'C' as a further back-up (weekly of 'B', via a rsync cron job).

I use Nextcloud 16.

So, nothing fancy, but it runs rock-solid. I no longer use Google Drive, OneDrive, or Dropbox. :D
Raspberry Pi 4 Model B | Raspberry Pi 3 Model B | Raspberry Pi 2 Model B

Return to “Networking and servers”