Build Log

Fig. 1

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 friends 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. As of this writing, the raspberry pi 3 is now available for just under $30 (Microcenter), 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. (Later the raspbery Pi 3B plus came out, and is much better for this - see below.)

From here, all we need is a micro SD card to boot from, and an ethernet cable, a power supply, and the USB external hard drives 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.


Fig. 2

The next step was to plug everything in. With nothing plugged into the GPIO or USB ports, this Pi will require the minimum number of amps of regulated 5 volts, which is much less than a 2.0 amp wall wart plugged into the micro USB port to supply the power. At first I plugged in the fan on GPIO pins 4 and 6 to pick up +5 and GND, respectively, but learned the fan was not necessary, so I didn't include it with my 3D printed cases. 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!


Fig. 3

Next we need to format the SD card and make it bootable. 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.


Fig. 4

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.


Fig. 5

Note: I later switched to using Etcher.io shown above, as my image writer to USB drives and SD cards. Really simple interface.

Also, I switched from using the Jessie/R-Pi NAS software to using OMV - Open Media Vault - which is just a single image you burn onto the SD, boot, and from then on simply use a web browser to configure. Much simpler, nothing else to install, much easier to use. I include the R-Pi NAS stuff below for history's sake, as well as showing how to SSH to a Pi, but if you just want to make a new NAS using OMV, jump down to Figure 11.


Fig. 6

At this point, when I apply power the board should boot up Raspian (a Raspberry Pi flavor of Debian Linux - the version I started with was "Jessie") 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.


Fig. 7

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.


Fig. 8

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".


Fig. 9

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.


Fig. 10

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.

I used R-Pi NAS for quite some time until I switched to using OMV, described below.


Fig. 11

To make this NAS server using OMV, go to the Open Media Vault website and download the latest .ISO image file made specifically for the Raspberry Pi, and burn it onto the SD card with Etcher.io. Insert the SD card into the Pi, plug everything in, and apply power. At this time you need to wait a while, so go get a cup of coffee. When OMV first boots, it does a bit of updating and configuring, so don't wonder what's going on and interrupt power during this process, or you'll have to start all over. Eventually (the amount of time depends mostly on your network speed) it will reboot itself and you should see less activity LEDs blinking on the Pi. Then it is time to talk to the Pi to configure it.

To point your favorite browser to the NAS Pi, you need to know its IP address. You can find this from your router, which assigned the Pi a new IP address when you powered it up, or you can use a freebie program called Advanced IP Scanner to find it. It will be the one that shows the Raspberry Pi Foundation as the manufactuer of the MAC address, and will list its corresponding IP address.

Launch youir browser and when you enter the IP address in the URL (like "http://192.168.0.32") you will be prompted for a username and password. The default username for OMV is " admin " and the default password is " openmediavault " You will then see the control panel screen, shown above. Obviously, you need to change these phrases first thing and record them somewhere!

Next you'll need to mount the disks with the correct file system on them, mount them, and create at least one user and set the user's permissions. After that, its is just a matter of using the Windows "map network drive" tool to make the shared disks look like local disks on any Windows machine on the network.


Fig. XX

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. These numbers are for 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. The Pi 3B came out later, whose faster processor would help some, but now I use a Pi 3B Plus, which not only has a lots faster processor, but also has a gigabit ethernet interface. It's a much better platform for this, well worth the $5 difference in price.

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!