Some time ago, I inherited my in-laws old PC when they upgraded. It wasn't all that old, a Gateway mid-tower with a 2 GHz Pentium 4 and 768MB of RAM, and a couple of servicable hard drives. For those that don't know, despite being someone who does computers and networking for a living, I really don't have a huge amount of gear at home, mainly because I don't have a great deal of time or space for hobby computer projects. Beyond the standard-issue wireless routers, we have one desktop, one laptop, plus a Cisco router that is serving as my IPv6 gateway until VZ offers it natively on FiOS.
Either way, I've been wanting to have some sort of backup/file server for a while, both because I was running out of disk space on my current external drive for media, and because I needed something better than the "when I feel guilty about it and burn a few key files to DVD" backup method, and so I decided to use this box and build my own NAS (Network Attached Storage), basically a headless file and media server with multiple disks in a RAID. Why build instead of buy any of the hundreds of available pre-made NAS boxes? Well, flexibility for one. Most NAS boxes either run some very specialized UNIX variant that is little more than the kernel, and you can't really do anything on them except what the manufacturer intended, or they use Windows home server, which is limited in a whole different set of ways. Either way, most are just glorified hard drive enclosures with a network port unless you pay a lot for fancy features. They also typically have the absolute bare minimum hardware required to support their intended purpose, and so performance sometimes suffers. I've had bad experiences with trying to use the built-in server in my Linksys WRT350N and a USB hard drive - it just didn't have enough horsepower. Also, most of the consumer-grade NAS boxes don't have particularly robust RAID support, and the ones that do what I wanted (a RAID10 using 4 drives) started getting expensive, which brings us to my other reason for building it myself - price. Since the basic computer was free, I was able to build this for just the costs of the disks, the SATA card, and the Gigabit Ethernet card, which was about $350.
My parts list:
- 4 1 TB SATA-II hard drives ($70 ea) - I bought 2 different manufacturers/models in order to try to insulate against the problem where disks in the same manufacturing batch fail from the same problem in rapid succession.
- 1 Syba Sil3124 4 port SATA "RAID" card - RAID in quotes because it's one of those fakeRAID cards that doesn't actually have dedicated RAID hardware support, it just does the underlying disk build and uses the computer's CPU for the work. It's mainly a Windows thing, but other folks I had talked to and research I did indicated that the chipset that my card had would work on UNIX.
- 1 cheap Gigabit Ethernet card
- The PC doesn't support PCI-X, so these are all PCI cards. I figured I'd go cheap to start with, and if I couldn't deal with the performance hit, I could always swap the motherboard later to upgrade.
My first try on the software/OS side was FreeNAS. It's a pre-packaged OS, based on FreeBSD, and includes a very straightforward web-based GUI, support for windows file sharing, UPnP/DLNA media server, iTunes server (which I don't care about, but some people do), Web server, FTP, etc. Pretty much everything I'd need for a home file/media server and more. It also supports running the OS from a USB stick or directly from the CD. Including downloading and burning the CD, I had the system up inside of an hour, and the managment of the system was via a very intuitive web GUI.
Setting up the RAID did not go nearly so well, and ended up being the reason that I ultimately abandoned FreeNAS. The first time around, I tried to use the RAID setup built into the SATA card, but FreeNAS didn't recognize the drive, and the documentation I found said that this rarely works unless you're using a true RAID card that is explicitly listed as supported by your OS (mine is neither). Ok, no problem, same document says that you can do it using the card just as a SATA controller, so I made the appropriate changes and started again. The FreeNAS website had a great document on how to set up a software RAID, and after 30 min or so, I had my RAID 1 pairs built, set up as a RAID 0, and formatting away. I mounted the drive, set up the windows shares, and copied over some files. Then, I needed to move the server a little, and I accidentally unplugged it. When it booted back up, my RAID was gone. I thought that perhaps it was because I didn't shut it down properly, cursed my carelessness, made a mental note to buy a UPS, and rebuilt the RAID. After rebuild, it worked again, but when I needed to reboot for another reason, the same thing happened again. I found some more documentation on the FreeNAS site that indicated that I might have missed a couple of options in the RAID setup, so I rebuilt the RAID for the third time using the recommended magic incantation. RAID mounted up just fine...until I rebooted. Same problem each time- RAIDs all show up as fine and happy, but won't mount. This time, I was able to just reformat and it mounted, but that's sort of useless as a fix considering it destroys all of the data on the drive. After several hours of fairly fruitless research (other than people saying "don't use the Sil3124/sofware RAID on BSD", which I wish I had found BEFORE I chose this particular card), I more or less decided I had to find another alternative. Specifically, I was reading more and more about how BSD really hasn't kept up with Linux when it comes to a robust software RAID implementation, and if I wanted to do software RAID and not use Windows, I needed to use something with a Linux kernel. So, back to research.
I looked at Openfiler but it has no media server support (it's really marketed as a file server for small businesses), and is based on some relatively unknown variant of Linux (rpath), meaning that it may not be easy to get add-on packages without having to compile them myself (um, no), and there is virtually no online support - it looks like most of their support is for-pay.
I also looked at MythTV which has several pre-built OSes with the software built in (Mythdora, Mythbuntu), but it's really more of a DVR solution, and from what I read didn't really have great support for the PS3 media streaming that I wanted to do since I'd have all of my media in one place.
In the end, I decided on using Ubuntu, specifically Ubuntu Server 10.04. Server is the same as the desktop version except that in the name of resource conservation, it doesn't install a lot (well, any) of the slick GUIware that makes Ubuntu so popular. It also adds some additional server features that I'm not going to use and don't really care about, but it's a better choice for something like this with a lower-end CPU and less than 1G of memory.The lack of a GUI worried me a bit, because I'm not a UNIX geek really. I have managed my own Solaris box at work for a number of years, and I know my way around the OS as a user, but managing a modern UNIX desktop primarily involves interacting with pretty useful GUIs, so I'm pretty much a n00b when it comes to setting up a complete system via command line only.
Fortunately, the install is pretty straightforward and menu-driven. It allows you to choose what you want to install, so I was able to add the stuff I needed like openssh for remote management (this box is going to be headless and in my utility room), samba (windows file sharing), etc. It even gave me an opportunity to define my software RAID during the install, and it set it up as a part of the install. It was up and running within about an hour, but I should note that "up and running" means something a good bit different here than it did on FreeNAS. On FreeNAS it meant I was ready to use the box for its intended purpose. Here, it meant I had a command prompt blinking at me. Mounting the RAID took almost another hour, not because I didn't know how to mount a drive, but because the instructions on how to set up a software RAID during install assumed that I was installing the software to the RAID (I wasn't) and said that the installer would format the drive for me. I chased down a lot of error messages dealing with mounts and RAIDs before I figured out that the damn drive wasn't formatted. Why there couldn't have been an "you can't mount an unformatted drive, moron" error message instead of the cryptic ones I kept getting is beyond me. But after that, it mounted up like a charm.
With that sorted, it was on to setting up samba to share my newly built disk, which I was able to do with the help of a good tutorial I found on setting up a basic NAS using Ubuntu. Long story short, I was able to copy files, and the RAID persisted after a reboot, so I'm already ahead of where I was with FreeNAS. As a bonus, I'm getting significantly better throughput on Ubuntu for disk access over the network too.
While I was waiting for the format to complete (and as a diversion when I got stuck), I also worked on:
Enabling IPv6 on the box using a static address
Downloading and installing the Linux version of the power management software that came with my UPS
Using the built in package management stuff (aptitude) to install SMART disk monitoring and apply some updates to my existing system
Downloading and installing PS3 Media Server using this tutorial. There are other alternatives such as Fuppes (which is what FreeNAS uses, I think), Geekbox, Mediatomb that are all UPnP/DLNA media servers, so if for some reason I don't like this one, it's good to know I have options.
And I'm still not totally done. I still have to go through and shut down some unnecessary services and generally lock the box down from a security perspective, finish setting up PS3 MS, and upload all of my data, but at least I have a functional server after less than a full weekend's work.
Overall, so far I'd recommend FreeNAS if you're not doing RAID, and Ubuntu if you are. Maybe someday BSD will fix their crap software RAID support, or FreeNAS will get ported to Linux, but until then, I guess I'm going to be rolling my own.