This is a build log of a Raspberry Pi 2 B based Network Attached Storage (NAS) device. In other words, it's a Linux based single board computer configured as a dedicated adapter to connect external USB hard drives to a local area network whose files can then be accessed by other computers. It's not really a build log, perhaps more like a user report, but several have asked me to post this and I said I would.
I have to face it - I have had Windows machines in my home since version 3, usually several at a time, and I am sick and tired of Microsoft fumbling the ball where local file sharing is concerned. It seems that every time they come out with a new version of Windows, they break something that makes file sharing across the various other versions of Windows either a royal pain, or just flat out doesn't work. Their QC in this area, given their huge resources, has been so consistantly poor that it makes me wonder if it's planned. Don't get me wrong, I'm not a Mac zombie or a Unix zealot - nothing wrong with those systems either - and I don't hesitate to call something good when I see it on a Microsoft product, but this gripe is important because it's prompted a gateway experience for another OS.
As a result, I began to stare longingly at dedicated NAS servers provided by companies more focused on making this work, but they were pretty expensive. So, when a very small Linux based machine came around for $30 that could do all that, right about the time that Windows 10 came out with its fresh hell of getting it to share files with all the other children, the time seemed right. I have only a dim, passing familiarity with BSD Unix from way back in the day of minicomputers, so Linux is pretty much a black box to me at this point.
Let's see if it does as advertised. To start off with, I bought the kit shown in Figure 1 online for $52. It includes a Pi version 2 B with an acrylic case, a fan for the CPU, and copper heatsink for the CPU. Don't know yet if it gets that hot, but this should deal with it if it does. (In Figure 1 I hadn't hooked up the fan yet.) This particular case fit very well, but the design has very thin areas that can easily break, so be very careful when assembling it. It is one more reason why I don't care for acrylic as a structural material, but the case was very inexpensive and just snaps together. Eventually I found the case to not hold up well, and the fan is really unnecessary, so I don't recommend buying the $52 package at all. The raspberry pi 3 is now available for less than $30, and the stick-on heatsinks are a good idea and should be very inexpensive - I got the set of three for one Raspi for $1.25 on ebay.
From here, all we need is a micro SD card to boot from, and an ethernet cable, a power supply, and a USB external hard drive to plug into it to be shared on the network. FYI, I am using a MicroCenter SD 16 gig micro SD card, class 10 for $5.50, and it works just fine. They also carry a power supply for $8 with the connector to fit the RasPi that works well, but I see there is now available one with a inline switch that might be useful. So, the total out of pocket for the project, not counting the discarded case and fan, is $30.00+8.00+5.50+1.25 = $44.75. I eventually 3D printed a case, so you might want to add the cost of a case if you don't know someone who can print one for you.
I have learned to mistrust the formatting done at the factory on SD cards or especially the formatter that comes with Windows, so the first thing I did was format the micro SD card with the recommended free formatter from the SD Association. The minimum SD card size recommended is 8 GB, but 16 or 32 will also work. I also had a 32GB micro SD card that came with a full size SD card adapter, and I plugged them into a SD card-to-USB adapter that plugged into my computer, and fired up the SDFormatter V4.0 shown above. Make sure you turn on the Format Size Adjustment feature so that the resulting boot partition uses the whole card, and select overwrite to erase the entire card. Also, this program does not tolerate being interrupted well, so even though it takes a few minutes to run, lay off doing anything else cpu or I/O intensive while running it.
I downloaded the Win32DiskImager freeware that copies bootable disk images to an SD card, and installed it. Next I downloaded the Linux distribution specifically configured for the RasPi called Raspian, whose current flavor was "Jessie." I then ran Win32 Disk Imager and pointed it to the image file, called "2016-02-09-raspbian-jessie.img", and also pointed to the SD card drive, shown as H: in Figure 3. I clicked Write, and it purred away for a bit, and was done. I then removed the SD card adapter from my computer and slid the micro SD card into the slot on the Pi2B board. The Pi was now ready to boot Raspian.
The next step was to plug everything in. The Pi2B wants 1.8 amps of regulated 5 volts, which is usually supplied with a 2.0 amp wall wart plugged into the micro USB port to supply the power. I also plugged in the fan on GPIO pins 4 and 6 to pick up +5 and GND, respectively. (I later learned the fan was not really necessary, and didn't include it with my 3D printed cases later.) I then plugged in the ethernet cable and plugged the other end of the cable into my ethernet network switch, plugged the USB hard drive in, and the hardware for this project was complete!
At this point, when I apply power the board should boot up Raspian (a Raspberry Pi flavor of Debian Linux) and when I do, I can see the on-board LEDs blinking away a bit, doing the boot up. Once up, I should be able to make a serial connection over ethernet using the SSH protocol to issue the commands I need to set up the file server.
To do that, I need a terminal emulator that knows the SSH protocol. I already had Putty installed, which would have worked to just do a command line session, but I would like to be able to explore the Pi's GUI desktop a bit as well. Unix figured out how to remote GUI sessions a long time ago with X11 type terminal session support. I went looking and learned about the the freebie program MobaXterm, shown above, which should do just that.
With power applied to the Pi and MobaXterm running on my Windows 10 machine, I needed to know the IP address assigned to the Pi by my router. You can get this either by looking at the router pages for the assigned addresses, or by using a freebie program called Advanced IP Scanner. The default username/password for a virgin Pi is pi/raspberry. Knowing these three things I should be able to start up a terminal session to the Pi. So, in MobaXterm I started a session with that IP address, and logged in to get the start screen shown above, ready to take commands.
The first thing I did was type "sudo raspi-config" and got the menu shown above. This is just a terminal based menu to change values in some basic configuration files without using an editor. I selected "expand filesystem" to allow access to the whole space of the SD card by the system, and I changed the user password and then the hostname of the Pi from raspberrypi to NASPi.
BTW, "sudo" is a command prefix allowing you to operate in "super user" mode, which means you can issue commands that might affect other users on the system. This does not make you smarter, it just enables you you to do a lot of damage in the blink of an eye. Think twice and check your commands thrice when using this prefix.
Nex thing was to make sure the system knows about the latest and greatest versions we type "sudo apt-get update" and after a few scripts are done, all is good. Note this only informs us about the latest versions, it doesn't actually install the latest versions. That is done with "sudo apt-get upgrade".
Since I will be using the USB hard disks as Windows file repositories (the USB HDDs have been formatted as NTFS disks), I will also install NTFS support on the raspi by typing "sudo apt-get ntfs-3g".
From the command line, you can now type "lxsession" and that will remote the Pi's desktop to your screen (shown above) and you can now use your mouse and keyboard to explore this flavor of Linux, use GUI editors, run the included apps, etc. However, in this case, we just want to configure SMB and get those attached drives to share their files, so command line support is all that is needed.
Ok, I would of liked to use NFS v4 as the file server protocol, but Windows only supports that in their more expensive versions of the OS, yet another gripe. However, even though the throughput is supposed to be lower, using the SMB protocol of Samba is a well trod path, so I'll first see how that works out. Perhaps there is an add-on NFS client for the various versions of Windows that might be worth the money if SMB doesn't do well.
At this point, you need to 1) add users, 2) mount partitions of the USB HDD drives, 3) install samba by typing "sudo apt-get samba samba-common-bin" 4) edit samba.conf to add the new drive support when samba starts up, and 5) enable samba. These steps involve decisions on your part that are unique to what you want to use the NAS for and how you want to name things. If you go to the Linux.org site here, and as shown above - it has specific walk through instructions for doing this.
Rather than trying to provide explict instructions here, I recommend going there because it should be kept in sync with the latest distros as time marches on. There are lots of youtube videos and pages out there on how to configure samba, but they get dated and show older versions that work differently and it can quickly get confusing. If you need a video to show you how, make sure you check the date and versions to see if it demonstrating the current software.
Once the config files are set and you have your samba server set up and running, you need to make sure it is working for each Windows machine. The easiest way to do this is with the "map network drive" tool on the "Network and Sharing Center" window of the windows control panel.
Above shows the completed project. There are two 2TB USB drives plugged in, as well as the beige ethernet cable. I went to a 3D printed case I found on Thingiverse (thanks 0110 M-P!) and printed off several other cases for future projects. I used some M3 by 20mm cap head screws that really look nice on this case, but I think you could probably use some 6-32s of the right length as well.
Performance of the NAS seems good - the write transfer speed was measured at 41 megabits/sec and the read transfer rate was 93 megabits/sec on a 100 megabit ethernet link. This is plenty of performance for me. This is a Pi 2 - I have read where the NAS/Samba performance of the original Pi is not so accommodating, but I have no experience with one. I don't think a Pi 3 is needed.
The three heatsinks seem to keep the board quite cool, just slightly warm to the touch, and no fan is needed at least for this application.All in all, this was a nice, simple $50 project that got me familar with RasPis and finally eliminates my dependence on Microsoft's amateur-hour networking software. One of these days, given the advent of these $50 headless PC's with smooth installation procedures, I am tempted eliminate more Windows based functions as well!
Comments may be directed to gary at liming daught org.
Thanks for viewing this build log!