Data Sheet: Build your own NAS with FreeNAS

Manek Dubash

How veteran IT journalist Manek Dubash rolled his own NAS—and why hardware selection is not always the most important decision.

When it comes to storage, there are those who prefer to roll their own, to try and improve on pre-packaged solutions, and maybe to learn something along the way. Manek freely admits to being among their number.

So this is the story of how he came to choose to build his own FreeNAS server to store his media collection and to act as a backup repository for his variety of home devices.

TESTED TECHNOLOGY HAS CONDUCTED a detailed examination of a number of NAS (network-attached storage) boxes over the years. The breed continues to improve and to gain performance and features but they all essentially consist of a small number of core elements.

What is a NAS?

Commonly, the hardware is a fairly low-powered computer consisting of a motherboard, CPU, memory, and maybe a fan or two to keep the equipment cool.

Connectivity requires Ethernet, usually with USB to attach external drives and perhaps printers. The rest of the box comprises bays and cables for storage devices—typically NAS-specific hard drives.

Every computer needs an operating system of course, and commercial NAS products almost always contain a form of Unix—of which Linux is but one, albeit a major, offshoot. As a buyer of a ready-to-run NAS box, you will—the vendor hopes—never see the underlying operating system because it will be overlaid with a graphical user interface that gives you access to all the functions and features that the vendor believes you will ever need.

And it’s this set of features that often provides the major differentiator between the various proprietary NAS products on the market. In other words, more features command a higher price.

Buy or build?

Old Antec Computer

The old Antec tower computer

But what if you wanted to pick and choose the features? What if you decided you wanted all the best features available—such as file system that is as robust as they come—without having to pay a premium? What if you wanted to add functions to the box?

And what if you already have an old, superseded computer hanging around but can’t bear to chuck it away?

That’s the situation I found myself in—and why I decided to build my own NAS box. The computer in question lived and still lives in a large tower case with room for eight hard disks. Based around an Asus B85M-G motherboard and a 2.7GHz Intel Celeron G1820, it’s fairly low-powered, though a NAS box doesn’t usually need a lot of CPU power, and will accept up to 32GB of RAM.

So I didn’t see the sense of disposing of it for a range of reasons, including financial and environmental ones, and buying what would have been a new computer that replicated much of the functionality I already had at my disposal. And if I instead constructed a NAS to my own specifications, I would learn a whole lot more.

Choosing Your System

With the hardware platform pretty much sorted, the big question was: which operating system? There’s a host of NAS software suites out there, available for free. Some of them sit on top of pre-installed (usually) Linux, while others come integrated with the operating system.

But for me, the real choice was not so much between the various NAS software products, many of which would fit the bill, as between file systems. This is, if you will excuse the expression, where the rubber meets the road.

If the file system is not as robust as it gets, given the limitations of any underlying storage hardware, then you are increasing the risk of losing data. The data I’m storing consists of the usual mix of documents, images, videos and music, and I do not want to lose any of it. So for me, performance is less important than robustness.

File systems are very complex pieces of software and must be tested to destruction with a huge range of potential scenarios before they can be trusted with live data. Natural selection has winnowed out the failures, so, for me, three survivors were worthy of further exploration.

The three that I narrowed it down to were ext4, BTRFS and ZFS—all of which are widely available under free licences.

  • journalling provides resilience to a crash or power outage. The journal is a special file that records the metadata—data about the data to be written. Only when the data has been successfully written is the update tagged as successful. So the file system retains its consistency.
    ext4 is Linux’s default file system. It uses journals to improve reliability, has high reliability and with LVM, includes snapshots as a way of improving reliability by adding rollback. It’s robust but doesn’t offer the cherry on the cake that ZFS does.
  • With copy-on-write (CoW) blocks containing active data are not overwritten, Instead ZFS allocates a new block and writes the modified data to that. So if the system crashes or something else happens during the write operation, the old data is preserved. The additional disk space needed for this operation is one reason why ZFS manuals recommend that a minimum of 20% of disk space is left free.
    BTRFS has been said to offer improvements in scalability, reliability, and ease of management, adding many features such as copy-on-write, pooling and snapshots to increase robustness. However, has not achieved widespread support on many Linux versions and that made me pause.
  • ZFS adds scrubbing to all the features mentioned above, a process that checks that every bit written to the storage medium is the same as when it was first laid down. This avoids what’s called bit rot, data errors which can occur over time due to glitches in the magnetic medium, cosmic rays or other disruptions. ZFS is also used in large enterprises, where data loss can cost millions.
BTRFS disadvantages

This file system was created to add more ZFS-style features to Linux (compression, snapshots and copy-on-write, for example). The main disadvantage of BTRFS seems to be down to a human rather than a technical issue. It’s not as widely used as its two main rivals, ext4 and ZFS: only a few distributions of Linux include BTRFS by default. When technical issues crop up there’s not as much depth of knowledge available.

FreeNAS and ZFS

These file systems all have advantages and disadvantages, but I chose ZFS for its proven robustness.

This narrowed down the choice of NAS software to FreeNAS, which integrates the NAS software, the operating system and the file system and made the choice easy; it sits atop FreeBSD, a version of Unix derived from BSD Unix, developed at the University of California. ZFS technology, now open-sourced as OpenZFS, was originally developed by Sun Microsystems, since acquired by Oracle, a supplier of databases and other products to banks and other large enterprises.

Installing FreeNAS was no more difficult than installing any other operating system, and from there it was a simple matter of switching on the required services—such as SMB (or Samba) for sharing with the Windows machines, NFS for sharing with other Linux machines, Rsync for client backup and AFP which at the time was needed for Apple shares. I then added shared directories for the various computers scattered around the house.

We now have an enterprise-grade operating and file system, all available for free, running on low-cost hardware.

But I’ve missed out a crucial element of the equation: storage. Let’s backtrack.

The “S” in NAS

LSI Logic Disk Controller

At the time of building this FreeNAS server, my media collection occupied around 10TB, with backups from other devices adding around a terabyte.

I calculated I needed eight 3TB NAS drives in a RAID-Z2 configuration; a RAID-Z2 configuration uses two parity drives and allows for two drive failures before data loss occurs. Eight 3TB drives provide real-world storage under ZFS of about 15TB.

A lot of drives means a lot of cables. Which is why a tower computer pays off.

So I needed to connect the drives to the motherboard and, like most of its kind, the Asus board doesn’t provide enough ports for the number of drives I needed to use. So I chose an LSI Logic SAS disk controller, which through its SAS2008 chip offers enterprise-grade reliability and performance. It also provides eight SAS ports, which with the right cables can easily be connected to standard SATA-interfaced disk drives. This controller can be found second-hand for a reasonable price on a well-known auction website.

And that’s the system as it is today.

To conclude, the FreeNAS and ZFS combination has proved its worth and validated the original selection decision. Not only has the software been faultless, identifying very early on two drives that showed signs of failure and giving plenty of time to source and install replacements, it’s easy to use, offers all the functionality I need, and I can install other functions on the PC as required. And FreeNAS continues to be developed.

That’s it for now. I’m planning to pick up the rest of the story—especially about how to expand the system—in a later episode.

Manek Dubash

Comments are closed.