Using FreeNAS to build a DIY home server
We havenât checked in with FreeNAS, the FreeBSD-based DIY NAS OS, in quite some time. The OS has been completely overhauled, plugin support has been added, and it now works with even more hardware.
Since the last time we built a FreeNAS box, back in January 2010, the OS has been through some changes. It switched developers, nearly switched platforms, removed media streaming, added it back in via plugins, added better ZFS management, and more. FreeNAS promises near-endless customization and hardware support, enabling nearly anyone to build a highly moddable NAS from off-the-shelf parts. Iâve been promising an updated FreeNAS build for quite a while, and nowâs the time to deliver. I assembled a cream-of-the-crop batch of hardware, got the latest version of FreeNAS, and got cracking.
Choosing the Hardware
The beauty of FreeNAS is that itâll work with just about any old hardware you have lying aroundâ"you donât need to build a special box for it. This âbuildâ is more about exploring the new version of FreeNAS than it is about the hardware itself. I took the opportunity to build a pretty powerful system, but you donât have to take my hardware choices as your minimum recommended specs or anything like that. I just wanted to see what would happen if I gave it beefy hardware to play with.
I chose a Fractal Array R2 chassis, which has six drive bays and an integrated PSU. I had a Mini-ITX FM1 board and an AMD A8 APU lying around and decided to use those, because a more capable CPU in your NAS means better transcoding and streaming. You could just as easily use any Mini-ITX board with a PCIe slot, maybe one with an integrated Atom or Brazos chip, if you want to save some money.
Four Western Digital Caviar Red NAS drives at 3TB each give me a theoretical 12TB of capacity if I were just going to make a RAID 0, which Iâm not. Because Iâll be using a filesystem called ZFS, which does all its volume management in software, I want a good host-bus adapter that doesnât insist on imposing its own hardware RAID over itâ"just something to pass the commands from the OS to the drives. I picked LSIâs SAS-9207-8i, which can control up to eight 6Gb/s drives and runs on a x8 PCIe 3.0 bus. Because I want to use the caseâs SATA power connectors, I also bought a HighPoint Mini-SAS-to-SATA breakout cable rather than use the included connectors, which run on Molex power.
Because ZFS loves RAM and wants as much as you can throw at it (the specs recommend at least 1GB per TB of storage), I used two 8GB DDR3 DIMMs from G.Skill.
FreeNAS wonât mount any storage on the boot drive, and only takes up about 2GB total (with another 2GB swap), so thereâs no point wasting a hard drive on it. Itâs perfectly happy booting from a flash drive. I just used an 8GB drive left over from a CES press kit.
Set it Up
Since this is a very straightforward build but a complicated software install, Iâll skip the step-by-step build entirely, and start with the software configuration. Itâs a bit of a doozy. Thankfully, I have the excellent instructions on Freenas.org and the FreeNas Quick Start Guide to help. Hereâs how to set up FreeNAS; create volumes; set up users, groups, and sharing; and install a few streaming plugins.
1. Install the OS
To create the bootable OS image (from a Windows machine), youâll need the aforementioned USB drive, the programs 7-Zip and Win32 Disk Imager, and the img.xz file for your install. Weâre using FreeNAS 8.2.0 Release 1. Download the FreeNAS-8.2.0-RELEASE-p1-x64.img.xz file from SourceForge. Extract the img.xz file using 7-Zip to turn it into an .img file, then burn that file onto your USB key with Win32 Disk Imager. This might take a few minutes. Once itâs ready, plug the USB key into one of the FreeNAS boxâs rear USB ports and turn on the machine. Youâll need a keyboard and a monitor for this, but only for a few minutes. Make sure the FreeNAS box is connected to your network via Ethernet. Make sure the system is set to boot from USB. The system will spend a few minutes doing a self-test and then dump you at a screen called Console Setup. At this point, under a list of 11 options, you should see the phrase âYou may try the following URLs to access the web user interface,â followed by an IP address. Go to another computer on your network and enter that address into the web browser; you should be able to get right into the web console, which will make this whole process a lot easier (image A).
| PART | URL | Price | |
|---|---|---|---|
| Case/PSU | Fractal Array R2 w/300W SFX PSU | www.fractal-design.com | $200 |
| Mobo | Asus F1A75-I Deluxe | www.asus.com | $175 |
| CPU | AMD A8-3850 2.9GHz APU | www.amd.com | $100 |
| Cooler | Stock AMD | www.amd.com | $0 |
| RAM | G.Skill RipjawsX | www.gskill.com | $105 |
| Boot Drive | 8GB Flash Drive | various | $8 |
| Hard Drives | 3TB WD Red NAS drive (x4) | www.wdc.com | $880 |
| Drive Controller | LSI SAS 9207-8i | www.lsi.com | $305 |
| SAS-to-SATA cable | HighPoint Int-MS-1M4S | www.highpoint-tech.com | $10 |
| OS | FreeNAS 8.2 Release | www.freenas.org | $0 |
| Total | $1,783 |
Youâll notice a blinking Alert light on the upper right. Click it and youâll see that you need to change the admin password. Hit the Account button to the left of the Alert button, then select Change Password. Changing the admin username from âadminâ can help with security too. You should also set up an email address for the root account, so FreeNAS can email you with admin alerts. Go to Account, then Users, then View Users, and click Change Email on the root account. You should also set up console logging by going to System > Settings > Advanced and selecting Show Console messages in footer.
2. Set Up Storage
Now for the fun part: volume management. Thousands of words can be and have been written about the relative merits of the various traditional RAID levels, as well as ZFS-specific types like RAIDZ1 and RAIDZ2. Any choice will be a trade-off between performance, capacity, and robustness. Iâm going with RAID-Z2, which will allow me to tolerate up to two disk failures without data loss.
Go to Storage > Volumes > Volume Manager. Create a volume name (I used âmpcstoreâ), then hold Ctrl and select the drives to useâ"I used all four drives. For filesystem type, select ZFS, then RAIDZ2. Select Add Volume. My four 3TB drives created a volume of 6TB; Iâm sacrificing space for redundancy.
Inside the volume, Iâll create individual ZFS datasets so I can set granular permissions on each of them. Because Iâm the first user, Iâll create a dataset within mpcstore for myself. In the left navigation pane Iâll go to Storage > Volumes >
/mnt/mpcstore and select Create ZFS Dataset. Iâll call it ânedstoreâ and give it an unlimited quota (image B).
3. Add Users and Groups
FreeNAS can be configured to inherit users from an Active Directory or LDAP, but Iâm assuming that this device will be used in an unmanaged home network, so weâll assign users with the same names as the Windows login names they use, per FreeNASâs instructions.
Iâve created a user named Nathan (for myself), and selected âCreate a new primary group for the user,â which will let me fine-tune permissions. I set my home directory to the dataset I created earlier, i.e., /mnt/mpcstore/nedstore.
4. Configure Permissions
Go back into Volumes and find the dataset you created earlierâ"in my case, thatâs nedstore. Click Change Permissions and select the user you just created. Here you can control which users and groups have read/write access to the dataset (image C). Repeat the dataset, user, and permission steps for any users you create.
5. Set Up a Media Share
Iâm going to set up a media dataset so I can share my music and movies with the rest of the Windows computers in my network. Follow the procedure above for setting up a new dataset (I called it Media), then browse in the navigation pane to Sharing > Windows (CIFS) > Add Windows (CIFS) Share. Create a new share and point it to the dataset youâve just created (image D).
You can either restrict it to specific users or groups, or enable an anonymous Guest Mode. If you have Apple computers on your network, you should also turn on AFP; if you have Linux, enable NFS. You can also enable SSH, rsync (for replication), iSCSI, and more, all from the Services panel.
6. Map the Drive
Now you can map the Windows share youâve just created. Go to My Computer, right-click, and select Add Network Location. Plug in the IP (the same one in your web console) and share name, as shown in the image (image E). Give it a fancy name. Note that youâll have to configure permissions so that users have write access if you want to be able to add files and folders via Explorer.
7. Set Up the Plugins Jail
Earlier versions of FreeNAS contained robust streaming options, such as iTunes, uPnP, and BitTorrent clients. FreeNAS version 8.2 restored that functionality via the use of plugins. The word âplugin,â however, dramatically overstates the ease of using these. To install and set up these plugins, first go to your storage volume and create two ZFS datasets, one of at least 2GB called Jail and another called Software (image F). The plugin system basically creates a virtualized FreeBSD system inside your FreeNAS system, and by this point if youâre tearing your hair out, youâre not alone.
Next, go back to SourceForge and find the plugins_Jail.pbi file for the release youâre running. In our case, thatâs at http://sourceforge.net/projects/freenas/files/FreeNAS-8.2.0/RELEASE/x64/plugins/. Download the PBI file to your computer. Now click the little wrench icon next to Plugins in the Services menu. Thatâll put you through a three-part setup screen. The first one will give you a temporary place to store the PBI youâre about to upload. I just used the root of my mpcstore. The second lets you set up the paths to your jail and software datasets. Point the plugins jail path to the jail dataset and the archive path to the software dataset (image G). The third step is to upload the plugins jail PBI file from your desktop.
Youâll also need to create a separate pingable IP address for the software jail, distinct from your FreeNAS IP address (image H).
8. Install Plugins
Now you should be able to slide the Plugins slider to On and click the Plugins menu at the top. Go back to SourceForge and download the PBI files for the plugins you want to install. Right now the ones available are Transmission (a BitTorrent client), MiniDLNA (a, yes, DLNA client), and Firefly, a no-longer-maintained iTunes-library service. Once youâve downloaded them, hit the Install Plugin button and browse to the PBI file and upload it. Youâll see it appear in the Plugins list, with service status set to Off. Create a mount point within the jail pointing to a folder outside the jail (image I). I directed it to the same dataset Iâm using for my Windows share, so I can drag-and-drop media that can then be broadcast over MiniDLNA and Firefly. Easy, right?
Now go to the left-side navigation tree and go to Services > Plugins, and select the plugin you just installed. Iâll use MiniDLNA as an example. Give it a friendly name and a media directory. Note that your media directory should use a relative path within your software jail, so itâs best to just type it in manually. I used /media again (image J). Save your changes and turn the plugin on. Make sure the IP address you picked for your software jail is working and you should see the DLNA server show up in your list of UPnP devices (I used VLC to check).
Paddling in the Shallow End
So now you know how to set up users, groups, datasets, and sharing, and youâve got your plugins ready to go. Weâve only scratched the surface of what FreeNAS has to offer. Fortunately, thereâs a robust community that loves documentation and has its own forum with discussions and FAQs for every part of the FreeNAS experience, from hardware to software to plugins to fine-tuning, and more (bit.ly/OosjiB).
One note: Be sure to back up your NAS data to an external drive. Even with two-disk loss tolerance, you never know when disaster will strike. You can use FreeNASâs builtâ'in rsync to make sure you have all your data synched to an external drive.
As for the specific hardware I used, itâs probably overkill for most home users. It did enable large-file read and write speeds of over 90MB/s, which is quite nice.
FreeNASâs greatest strength is also its greatest weakness: Itâs incredibly complex and granular, with myriad configuration options, plugins, services, and so forth. The average home user may be better off buying an off-the-shelf NAS from Qnap or Synology, which are easier to configure and often include mobile access apps. But if you have the patience and the inclination, thereâs nothing like building your own.
NOTE: This article was taken from the Novembe issue of the magazine.











Comment