How to build your own NAS box

You’ll need this:

  • OpenMediaVaultwww.openmediavault.org
  • Spare PC – pre-fab or home-built mini
  • Hard drives – at least two!
  • USB key – any size will do

While there’s a wide range of NAS products available to help you quickly and easily add a NAS to your network there is another way. For a start while turnkey solutions these products can be expensive for what you get. Moreover depending on the product you may be locked in with that vendor when it comes to accessing the data on your NAS should the hardware fail – APC staff have experienced first hand the problem of plugging in hard drives from a NAS into a PC in order to recover data only to find them unreadable.

For these reasons and more you can build your own NAS box, with a big plus being the added bonus of giving you full control over the configuration and features of the machine. It’s also a great project if you feel that itch to create something and expand your skill set along the way – some people have even ventured to make one using a Raspberry Pi!

So first up what hardware makes a good NAS?

The hardware

As it happens a NAS box isn’t defined so much by the hardware and it doesn’t have to be powerful – you can use anything from a low-power fanless mini PC to a full-tower server if you wish just as long as it can run your choice of operating system. For this reason you can go the route of building a box from scratch (using a mini PC chassis and micro-ATX-based motherboard for example) or to save time buy premade machines that have (and use) less power than a standard desktop PC but are well-suited to NAS duties. These can include products like Shuttle’s range of compact PCs or mini servers like those from HP going cheap online. Or you can recycle an older PC that’s lying around just waiting to be put to good use again.

Indeed your average NAS doesn’t need a lot of CPU grunt or memory which is why many commercial NAS products are outfitted with Atom CPUs and 2GB or less of RAM. The only real requirements are space for at least two hard drives and that the CPU is x86-based. There’s nothing stopping you using an ARM-based solution (as with a Raspberry Pi) but for this guide we’re going use a flexible x86-based Linux distribution called OpenMediaVault (OMV).

The software

Interestingly enough commercial NAS products almost always use Linux themselves bundled with their own web-based front end to configure and manage the device. Some of them are very good but you pay a premium for the whole hardware/software package and you can get all the same functionality out of OMV and similar free products (see ‘Alternatives to OMV’ towards the bottom of this article).

Because a NAS operating system is inherently lean – it doesn’t need a GUI weighing it down for starters – there are two different options when it comes to installing OMV.

  • Install to a hard drive. This is the simplest but it has a drawback. Whatever drive you use for OMV must be dedicated solely to OMV which means it can’t be used as device to store data for your NAS. And since OMV is quite small (about 750M after installation) dedicating a large hard drive to OMV would be a waste of space. You can use an SSD as the OS drive which may be useful for compact PC cases as SSDs are physically small as well but even a cheap 64GB drive is technically overkill (at least it should last forever with so much space for wear-levelling routines). Incidentally even popular alternatives like FreeNAS (again see ‘Alternatives to OMV’) have the same limitation.
  • Install to a USB device. Installing to a USB key or drive is therefore not only viable but probably preferred… with a few caveats. OMV can install to and run from a USB device just fine even though booting from USB is slower. Doing this has another advantage too: it won’t occupy a hard drive slot. If your enclosure only has space for four hard drives for example dedicating one to the OS would prevent you from using it for storage. However the main caveat is that if you use a USB key – small efficient can plug unseen into the back – you’ll need to replace it semi-regularly as USB keys are notoriously unreliable over long periods especially when used as OS drives due to the volume of writes. A powered external USB hard drive even a small one is more reliable yet also larger and may cramp your style if you want a self-contained compact box as a server.

Plan on your choice before you begin. If you only intend to use two drives for storage and mirror them in RAID 1 for redundancy for instance but there’s space for three hard drives in the box the first option is probably best. If you want to use four drives and these fill the spare slots in the chassis buy a quality USB key or external USB drive to use for the OS.

Installing OMV

Start by heading to www.openmediavault.org to download the latest ISO image of OMV. If you don’t have an optical drive in your NAS box you’ll need to image the ISO to a USB key for booting and installing. Any size will do – the install image is only around 250MB. To create a bootable USB drive you can use UNetbootin in either Linux or Windows: for Windows head to unetbootin.sourceforge.net; for Linux it can usually be found in your distribution’s repositories (search for UNetbootin in Ubuntu’s ‘Software Center’).

OpenMediaVault booted up and running – no GUI all managed via a web browser.

Once this is done plug it into your NAS box plug in a monitor (you can remove this later once it’s installed) make sure the BIOS is set to boot USB devices ahead of any hard drives (see the manual for your box or motherboard for how to enter the BIOS) and turn it on. It’s also important to make sure the network cable is plugged in before you begin.

OMV will load to a console screen and request a login although you don’t need to. From here on in all configuration and management can be done via the web-based interface – note at the console what address has been acquired via DHCP over your network (for example 10.1.1.18). To load the OMV interface simply type that address into a browser on another computer. You can simply log in using ‘admin’ for the username and ‘openmediavault’ for the password.

First steps

Start by clicking ‘General Settings’ under ‘System’ from the left-hand menu followed by the ‘Web Administrator Password’ tab on the right. Change the password from the default ‘openmediavault’. This password is different from the system root password you set during install which you generally shouldn’t need to use.

Next make sure OMV is updated by clicking on ‘Update Manager’ under ‘System’. There may already be updates pending; simply click the box at the top to select all and install them. Reboot OMV by clicking on the gear icon drop-down at the top-right.

Log in again and it’s time to set up your drives.

Drive setup

Under ‘Physical Disks’ in the ‘Storage’ are you’ll see the detected drives in your system. If you have more than one drive you can RAID them using Linux’s own built-in software RAID. Here we have a number of recommendations.

  • If you have two drives we recommend using RAID 1 aka mirroring. Your total capacity will be limited to the size of one drive but should one drive fail you’ll have a complete backup on the other.
  • If you have four drives you can opt for RAID 10 or RAID 5. Even though RAID 5 is a viable option we recommend using RAID 10 – RAID 5 is more demanding for system resources and slower for writing it’s less resilient than RAID 10 and there’s more work involved to recover data if the drives are moved to another system (they require the array to be rebuilt first). However RAID 5 is more space-efficient. Four 1TB drives will net you 2TB of space under RAID 10 or 3TB under RAID 5.
  • If you have more than four drives then you have a rather nice NAS for a start! As RAID 10 requires pairs RAID 5 may prove better especially for odd numbers (ie. five drives) although the more drives you have the more demand is placed on system resources.

 

RAID 1 built from two 1TB drives. Great for redundancy.

There are some other options OMV offers: RAID 6 which is RAID 5 with extra parity for better data redundancy although this requires an extra drive without increasing the maximum capacity and RAID 0 which is also known as striping. While RAID 0 can be attractive for desktop systems given its raw performance this is completely wasted in a NAS. Aside from the fact that if one drive should die you’ll lose all your data – and presumably you’re building a NAS for reliable storage – any speed benefit RAID 0 provides is lost as even Gigabit Ethernet is saturated by the speed of a single drive. However in a two-drive NAS it will give you the full capacity of both drives.

To create the RAID tap ‘Create’ under ‘RAID Management’ give it a name select the RAID level and tick the drives. After the array syncs head to ‘Filesystems’ on the left click ‘Create’ again select your RAID and choose the file system to use – Ext4 is the standard although XFS and JFS are options if you’re familiar with them. All three are readable by your average modern Linux machine so if the worst should happen and your system carks it plugging the drives into another PC will still allow you to access your data.

Finally before moving on select the new file system and then click the ‘Mount’ button.

Setting up a share

Select ‘Shared Folders’ under ‘Access Rights Management’. Click ‘Add’ to add a new shared folder give it a name and a path (a directory will be made for you) select your mounted file system on the RAID and click ‘OK’. The default access permissions from the drop-down box are that the administrator and user logins you create have write access but everyone else can only read. Set this to ‘Everyone:Read/Write’ initially to make sure that the share works properly over the network or if you don’t care to have access controls and just want a simple easily accessible share.

Next to share this folder over the network click on ‘SMB’ (Server Message Block aka Windows networking) under the ‘Services’ section and then tick ‘Enable’ to start sharing. If you want the NAS to join your current Windows network Workgroup change the workgroup name; for basic sharing you don’t need to do anything else here and the defaults are good. Click ‘OK’ at the bottom.

We’re almost done. With the Windows network sharing service having started you then need to share the folder itself. At the top you’ll see a tab called ‘Shares’ – click on this followed by ‘Add’ to add a new share. Give it a name (this is what you’ll see when browsing the network) and select your shared folder. Finally tick the ‘Public’ box so you don’t need to enter a password whenever you connect and click ‘OK’.

And that’s all there is to it – your NAS is ready to rock. If you browse the local network from your Windows or Linux boxes you should see the share show up. Of course there’s plenty more to play with so lets explore some of the options.

Native Linux sharing

Linux boxes have no problem working with Windows shares so enabling SMB is all you really need to do. However Linux does have its own network sharing protocol called NFS (Network File System). NFS is easier to set up than SMB and often faster too; in fact in recent kernels you can set up an NFS share as swap for your local operating system.

To set up an NFS share click on the NFS service tick ‘Enable’ to start it and then under ‘Shares’ click ‘Add’ as with setting up an SMB share. You’ll notice that it’s simpler to configure and the only option that needs explanation is the ‘allowed clients’ field: for this you can use a subnet mask with CIDR (Classless Inter-Domain Routing) notation to cover all the machines in your local network. For example if your network and the NAS is on 192.168.1.0 using 192.168.1.0/24 will allow any machine on this subnet to connect.

Note that you need to make sure the ‘nfs’ module is loaded locally on any client machines to access the share which not all Linux distributions will do by default. If you can’t immediately see the share over the network open up a terminal and run sudo modprobe nfs .

Restricted shares

To create restricted shares – that is have users require a login to access – there are a few extra steps.

Click ‘User’ under ‘Access Rights Management’ hit ‘Add’ and add your users. Next go to your shared folder and click ‘Privileges’. Give users ‘Read’ or ‘Read/Write’ access as you see fit. Then click ‘ACL’ and do the same. Finally head back to your SMB share click the ‘Shares’ tab edit the share and deselect ‘Public’. Alternatively you can leave the share publicly accessible set ‘Others’ to ‘Read-only’ under the ACL for the share and create a username that matches your own and then give yourself ‘Read/Write’ access thereby allowing only you to write while others can only read.

 

Setting up a Windows network share for public access.

Plug-ins

NAS operating systems often come with extensible functionality enabled through plug-ins and in this way OMV is no different. These plug-ins can include simple features like enabling iTunes streaming or Apple file sharing to more advanced services like BitTorrent and media encoding – after all the NAS is still a computer. There’s a even a guide for setting up a Minecraft server for OMV (visit the tutorial at forums.openmediavault.org if you’re interested!).

Optional plug-ins range from antivirus to BitTorrent and more.

OMV has some of these already available under the ‘Plugins’ section although there are also some great third-party plug-ins provided by users. A good place to start is the ‘Unofficial Plugin’ list. This includes Transmission for BitTorrent and an auto-shutdown function for when the NAS is idle. These plug-ins can also be installed through OMV by installing the OMV-Plugins plug-in itself which you can find at packages.omv-plugins.org. Just download the DEB file and upload it in OMV via the ‘Plugins’ page to enable it.

The popular Plex media server although it’s technically just installed alongside OMV can also be added with the help of a short guide.

Finally while it hasn’t been made into a plug-in yet you can also add ownCloud cloud support by following these instructions .

Setting up permanent links

It can be helpful to set up permanent links to your shares on the NAS to save browsing the network every time. To do this with Windows find the share on the network right-click the share and select ‘Map network drive’. Easy.

Linux is similar. Under Ubuntu open up Nautilus and click on ‘Browse Network’ under the ‘Network’ heading. Find the share click on it to mount it first then right-click on the mounted share and select ‘Add Bookmark’. The process is similar for KDE though like Windows you can select ‘Add to Places’ from the share itself without the need to mount it.

Things to see

There’s plenty more to explore in OMV. Check out ‘System Information’ under ‘Diagnostics’ for general system statistics including the current CPU and memory load as well as a summary of enabled services and some excellent performance graphs for system resource and disk usage. Use the ‘System Logs’ section to keep track of any issues or keep an eye on user logins.

Monitor the performance of your NAS with pretty graphs.

There’s excellent SMART support under ‘Storage’ where you can view SMART data for your drives or set up regular SMART checks. Meanwhile in ‘Physical Disks’ you can click ‘Edit’ on your drives to set advanced power management and acoustic options along with a spindown time to power down drives while idle.

Of course then there are other services such as SSH for secure logins FTP and TFTP and Rsync for backups. With a little setting up you can configure Rsync to regularly backup data from clients on your network to the NAS for automated system backups.

Finally although OMV is free if you like using it send some feedback via the support pages or donate to help continued development. And have fun with your NAS!

Alternatives to OMV

OMV isn’t the only free NAS option available. Another popular choice is FreeNAS and its fork NAS4Free. Unlike OMV FreeNAS and NAS4Free are BSD-based which is similar but still quite different to Linux – if you’re a command line junkie you’ll find some concepts and commands the same while others will be foreign.

We actually tested FreeNAS for our guide first but ran into various hardware compatibility problems with one of the two hardware test benches on hand. However it may work fine for your needs. One advantage is that the download image is a preinstalled system and extracting it to a USB drive gives you a bootable OS ready to go.

CryptoNAS as the name implies makes it easy to set up a NAS-like file server with encrypted volumes. It’s not as fully-featured as OMV or FreeNAS but it’s simple to get running.

Finally Ubuntu Server or any server version of a Linux distribution will work just as well as any packaged NAS product. Additionally OMV can be installed on top of it which means you can create your own Ubuntu Server and OMV installation. We haven’t tried this but technically all you need to do is add the OMV repository and install:

sudo -s

echo “deb http://packages.openmediavault.org/public fedaykin main”> /etc/apt/sources.list.d/openmediavault.list

apt-get update && apt-get install openmediavault-keyring postfix

apt-get update && apt-get install openmediavault

omv-initsystem

 

One advantage of doing this is that as the OMV distribution is based on Debian Squeeze which is getting a little long in the tooth using a newer Linux distribution as a base will allow for more recent hardware support as well as performance improvements from newer kernels.

Step-by-step: Set up Open Media Vault

Get the program up and running on your NAS.

Step 1:

You should see the OMV boot menu appear – hit Enter to select ‘Install’.

 

Step 2:

Choose your language location and keymap (‘American English’ is fine).

Step 3:

Choose a hostname and domain name (the defaults are OK) and set a root password. Write this down!

Step 4:

After setting a timezone you’ll be prompted where to install OMV. If you’re installing to a USB key or drive check that your choice matches the name of the device. Note that any data already on the drive will be lost.

Step 5:

Choose the closest archive mirror next – if you’re with Optus or iiNet you can save data from updates counting towards your bandwidth cap.

Step 6:

Packages will be updated and then you’ll be asked to remove the install media and reboot. OMV is now installed!

 

  • Edward

    Do I need a normal operating system to start with?

    • Ben Weaver

      You need an os to create a flashdrive with the linux flash but you do not need one on the nas machine

  • TobyConfirmd

    can i access the nas remotely and map to it? (is it just pointing port forwarding on the broadban router to the nas box?)