Posted May 12, 2016 The Raspberry Pi is quite a capable little computer. It's not gonna give you mind boggling performance by any means, but for light use, it's ideal for anyone who doesn't want to shell our hundreds of dollars a year for electricity on a purpose built NAS. 0. Table of Contents Backstory (done) Basic Setup and Usage (done) Enter the Raspberry Pi 3 (done) Modifications (done) Upgrading the Network Speed (done) Additional Functionality (WIP) Safeguarding Against Corruption Storage Upgrade 1. Backstory Over the past month or two, I’ve been looking into various solutions for data storage. I was never looking for anything that could store petabytes of data or be used for 8K@240fps video editing over an ultra-high speed 10 terabit network. Instead I was more interested in finding a cheap, fast, and super power efficient solution that will primarily be used as a hard drive available to all the computer and HTPC’s in my house. Here are the solutions that came to mind: - Cloud Storage (i.e. Dropbox, Google Drive, OneDrive) This was naturally the first thought that came to mind as they’re all tried and true methods of storing files to be accessed by multiple users. Pros Child’s play to set up Most provide desktop and phone integration applications for file access Reliable Cons Low amounts of free storage Require network connection at all times Almost unusable when you have 100 GB’s of data to upload with a 1Mbps upload speed - My Personal Computer It’s on for most of the day anyway, why not? Pros Pretty much already set up and ready to go with Samba No additional programs needed Does not require internet connection at all times Cons Consumes a little more power than I’m willing to pay for The computer’s in my room and it kicks off a lot of heat Annoyingly loud when I’m trying to sleep - Custom Built NAS Computer I’ll take any excuse I can get to order computer parts and put them together like a hi-tech puzzle! Pros Completely custom in every aspect Fun Cheaper than a Pre-Built Cons Can get quite expensive with drives Can consume a lot of power depending on the number of drives and users hitting it - Pre-Built NAS Box Don’t know much about these at all… Pros Relatively simple to set up Purpose built, so I’m assuming they’re more stable than most custom solutions Cons Very little customization Too expensive for not including the drives As you can probably tell, I’m very picky with this sort of thing. No one solution has everything I want and I want everything I want in said solution if I’m going to use it. So after spending another week or so doing some research, the Raspberry Pi 3 I ordered ages ago came in and then it hit me, “I have an old RPi 2 that I’m not using for anything atm, so why not use it?!” It's small, cheap, power efficient, quite capable, customizable to hell and back, and fun to work with! 2. Basic Setup and Usage After a quick Google search I came across this tutorial explaining how to turn the RPi into a basic NAS. It literally took me minutes to get everything set up and working. However, after doing some simple benchmarks to gauge the speed of the new NAS, I realized that this might not be the solution I was looking for; namely because of the storage capacity and the network speed. Problem: Storage – Temporarily Fixed I had a 16GB SD card as the storage… That would work for like 3-6 movies at a time and leave room for little else. This was a simple fix as all I had to do was buy a 128 GB USB 3.0 flash drive for $34 to use as the primary storage for the Samba shares. Now I’m considering buying another 3 of those and pooling them using LVM into a single 512 GB volume. I’m well aware that flash drive storage is about as impractical as it gets. It’s not worth the money you’re be paying; at $34 a pop 512 GB’s will run you $136 plus tax whereas a single 4 TB external hard drive will run you about the same if not less. It’s not reliable for high write usage; naturally, as with all flash based storage, the memory chips degrade over time. This is just more of an experiment for the moment and I most likely won’t resort to using flash drives as a permanent solution. Problem: Network Speed – Working on it… For those who don’t know, the RPi only has 100 Mb Ethernet that is actually a part of the USB 2.0 bus. Meaning it only supports a maximum speed of 100 Mbps (12.5 MB/s) which is horrendous when you’re trying to offload 60+ GB’s worth of movies and TV shows. This is only an issue when it comes to transferring files to and from the NAS, streaming isn’t (much) of an issue. To elaborate, on my first run of the NAS, I was able to stream four 1080p 60fps movies concurrently with no issues whatsoever. However, after I loaded a fifth, I began noticing periodical visual artifacts and some stuttering in each of the videos. I don’t exactly expect five people to be hitting this thing at once but this is still unacceptable for my tastes. I racked my brain and searched up to the 13th page of Google and wasn’t able to come up with anything. So finally, after admitting defeat, I decided to use my newly acquired RPi 3 as the NAS in hopes that the higher clocked 64-bit 1.2 GHz processor and on board Wi-Fi would alleviate my stress. 3. Enter the Raspberry Pi 3 Well after setting everything up again, only half of my stress was gone. While connected to the (again 100 Mbps) Ethernet, I was actually able to stream thirteen 1080p 60fps movies at once with absolutely no sign of any visual artifacts whatsoever! Using the iftop utility on the RPi, we can see the network load was nowhere near the 100 Mbps maximum but was instead sitting at about 25% of that at 25-ish Mbps. This leads me to believe that I could potentially put on another 39 movies and watch them with no issues, as far as buffering and the network goes anyway. I’m sure the initial stuttering and visual artifacts were due to the weaker ARMv7 processor of the RPi2 and that I’ll probably only be able to squeeze another 7-9 concurrent streams out of the RPi 3. So the processor and the Ethernet are no longer bottlenecks in streaming, but what about file transfer? Well file transfer speeds are still entirely disappointing at ~11.5 MB/s PC to Pi and ~9 MB/s Pi to PC. The Ethernet was clearly to blame here so I turned my attention to the Wi-Fi but it produced even worse results! I was only ever able to achieve a maximum speed of 3.5 MB/s both ways and only a 5.5 MB/s max speed when I put the Pi directly next to the router. So Wi-Fi is useless. After some digging around, I happened upon this article which detailed how you could achieve gigabit network speeds using a USB 3.0 to Ethernet adapter. Now the title is a little bit misleading as it states gigabit (1000 Mbps/125 MB/s) speeds however that’s impossible over the RPi’s max 480 Mbps (60 MB/s) USB bus. Nonetheless, it still looks like it will provide a boost in performance and I will definitely be trying it out as soon as mine comes in! 4. Modifications In the meantime, I decided to play around with the RPi 3 to make it a little more overkill for my purposes. For starters, I disabled the onboard governor so that it runs at a constant 1.2 GHz and delivers the best performance possible at all times. Considering the minute power requirements of the RPi, I highly doubt this would cost me any more than $10/year to run 24/7 even with the processor constantly at 1.2 GHz. Next, I disabled loading of the X Server (desktop interface of the Raspbian OS) and dropped the GPU RAM down to 64 MB’s as I’m only going to be using this as a headless server. Next, I disabled some of the modules I won’t be using such as SPI, I2C, and camera modules to make sure the processor is only focused on serving data and not on unnecessary things. Next, I overclocked the SD card reader to 100 MHz, a 50 MHz boost over the default 50 MHz. This is supposed to give you better performance on regular I/O operations and general usage however I haven’t noticed much of an improvement myself due to me not even pushing the Pi much. Then, I disabled the Bluetooth and Wi-Fi, again to free up the processor as much as possible as well as to lower the power consumption by a bit. Finally, I lowered the default temp limit from 85°C to 70°C. This was a pretty unnecessary change as it will more than likely never heat up past 50°C whilst using it as a stream box. Moreover, I sort of Frankensteined a massive heat sink so even at 100% utilization of all four cores, it NEVER pushes past 56°C. To do all of this, I had to modify some of the config files which, thanks to the extensive documentation available online, was no hassle at all. /boot/config.txt # Disable onboard governor force_turbo=1 # Disable X Server (Desktop) start_x=0 # Lower GPU RAM to 64 MB's gpu_mem=64 # Disable SPI Module dtparam=spi=off # Disable I2C Module dtparam=i2c_arm=off # Overclock SD card reader to 100 MHz dtoverlay=sdhost,overclock_50=100 # Disable Bluetooth dtoverlay=pi3-disable-bt-overlay # Lower temp limit temp_limit=70 /etc/modprobe.d/raspi-blacklist.conf # Disable Wi-Fi blacklist brcmfmac blacklist brcmutil Massive south bridge heat sink from an old motherboard I had lying around. I actually had to Dremel out one of the corners so it would sit flat on the CPU and not touch the power components. 5. Upgrading the Network Speed Alright, so after getting my USB to Ethernet adapter I was effectively able to more than double my connection speed! In a synthetic benchmark that is... Iperf reports an average of 219 Mbps which is a significant improvement over the 93 Mbps I was getting before. Real world transfers aren't as big of an improvement however. I did see a doubling of file transfer speeds however I should note that the PC to Pi speeds did lower to around 15 MB/s after it hit around 20% of the transfer. While the speed still isn't as fast as I'd like it to be (I would prefer at least 40-50 MB/s), it's a nice improvement and it's a little more bearable over the original 10 MB/s I was getting before. I might look into something like linking the Wi-Fi and USB Ethernet together to get a little speed boost but I have no idea if that's even possible. As far as installation goes, it was simple as all I had to do was add the interface into the configuration file and I was off to the races. /etc/network/interfaces # Add USB to Ethernet adapter interface iface eth1 inet manual iperf Results Real World Test (Left: Pi to PC | Right: PC to Pi) All in all, I'm happy I at least got some boost and didn't just waste my money for absolutely nothing 6. Additional Functionality I'll soon be adding functionality to my NAS for BitTorrent and possibly a remote web based management service! Link to comment https://linustechtips.com/topic/594717-my-raspberry-pi-nas-wip/ Share on other sites More sharing options... Link to post Share on other sites More sharing options...
Posted May 12, 2016 Power consumption of the your computer and drive is minimal .... also is another NAS... I dont see any increase of power bill running a Custom FreeNAS 24/7. The CPU in Pi might not be enough if you gonna run plugin or more drives.... Noise? place the NAS into a cardboard or another room, get A SSD as scratch disk. Magical Pineapples