Saturday, July 2, 2011

Build Your Own Open Source NAS Device Using FreeNAS


NAS stands for Network Attached Storage, and is basically a box full of hard disk space that attaches to a data network. Its sole job is to be a file server to as many protocols as you want to configure. If you’re anything like me, you have multiple computers in your house of all types and ages running a variety of applications and OS’s. This doesn’t even take into account the rest of my family, of which even my 6 year old has her own desktop AND laptop.
One of the things I really wanted to do was consolidate my storage space so that a variety of devices can access them. Also I wanted to start using ISCSI in a few demos so it made sense to look at getting a NAS into the family.
Now the cost of these devices really depends on configuration and manufacturer, but there are other options that not only give you more control but can give you a lot more bang for your buck.
In this demo I am going to walk you through setting up one of those alternatives, called FreeNAS.FreeNAS, as you might have been able to garner from its name, is free open source NAS software that is pretty robust.
It supports CIFS/SB, FTP, NFS, RSYNC SSH, AFP, Unison, UPnP, ISCSI, local and Microsoft Active Directory authentication, SoftRAID, disk encryption, and has a WebGUI interface. FreeNAS can also be configured to run off a USB Key to keep all that hard drive space for storage. It is built on the FreeBSD platform but you won’t need to know any Linux to get it up and running.
For this demo I am going to setup a RAID 1 drive and make it so I can access it from Windows Vista. I am actually going to use a virtual machine so I can capture screenshots easily and I am using the following configuration:
  • 512MB RAM (96MB RAM is the min necessary to run base FreeNAS functions)
  • 3 Virtual Drives, 1 for FreeNAS installation, and 2 for data (not formatted at this time)

Download FreeNAS

You can get the current version FreeNAS from: http://www.freenas.org/index.php?option=com_versions&Itemid=51
For this demo I am going to use the LiveCD ISO option with the current build which is 0.69RC1.

Install FreeNAS

Ok to get started you will need to burn the ISO file to a CD/DVD, or in the case of a virtual machine, mount the ISO. Once that is done go ahead and boot the machine from the CD/DVD that you are going to use for FreeNAS.
1. When it boots up you will see the FreeBSD kernel loading up and after seeing a lot of text flying by you will get to the Console setup menu.
Build Your Own Open Source NAS Device Using FreeNAS - 1
2. From the console menu I am going to select 9) Install/Upgrade to hard drive/flash device, etc. so we won’t have to boot from CD/DVD anymore.
The first screen that comes up asks what type of install you want to do. From this menu I am going to choose 1 Install ‘embedded OS on HDD/Flash/USB, then select Ok.
Build Your Own Open Source NAS Device Using FreeNAS - 2
3. You will get a quick overview of the limitations of what this type of install does. Go ahead and read through this then select Ok.
Build Your Own Open Source NAS Device Using FreeNAS - 3
4. In this screen you will choose your installation drive, if you only have one CD/DVD drive it will be highlighted for you. If you have more than one choose the one that has the installation media and then select Ok to move on.
Build Your Own Open Source NAS Device Using FreeNAS - 4
5. Next we are going to choose the target HDD. As you can see I have 3 drives attached to this machine, I am going to choose the one I dedicated specifically for this task which is ad0. Choose the disk you want to install to and then select Ok.
Build Your Own Open Source NAS Device Using FreeNAS - 5
6. You will now see the system image copy over to the HDD from the CD/DVD drive. Once it is finished it will tell you to remove the installation media and press Enter. Go ahead and do both of these steps.
Build Your Own Open Source NAS Device Using FreeNAS - 6
7. This takes you back to the Install menu, choose Exit.
Build Your Own Open Source NAS Device Using FreeNAS - 7
8. Now from the Console setup menu select 7 Reboot System.
Build Your Own Open Source NAS Device Using FreeNAS - 8
9. Confirm that you want to reboot the system by selecting Yes.
Build Your Own Open Source NAS Device Using FreeNAS - 9
10. After the reboot you will go back to Console Setup and see the current networking configuration. I only have one NIC setup for this computer, but note that you can configure different adapters by going into the Assign Interfaces menu.
Build Your Own Open Source NAS Device Using FreeNAS - 10
11. As you can see it grabbed an IP address by DHCP, so the first thing I am going to do is assign it a static IP address by selecting 2 and hitting Enter. The first screen you will see will ask you if you want to use DHCP for this interface. Select NO and hit Enter.
Build Your Own Open Source NAS Device Using FreeNAS - 11
12. Type in the static IP address you want to use and then select OK.
Build Your Own Open Source NAS Device Using FreeNAS - 12
13. Next you will enter your subnet mask in CIDR notation or bit counts. For 90% of you this will be 24 which is equivalent to 255.255.255.0, if you have a different subnet make there are some hints on the screen or you can convert it using a subnet calculator. After entering your notation select OK.
Build Your Own Open Source NAS Device Using FreeNAS - 13
14. Enter your default gateway and then select OK.
Build Your Own Open Source NAS Device Using FreeNAS - 14
15. You now will enter the DNS server you want the FreeNAS installation to use. After entering the IP choose OK.
Build Your Own Open Source NAS Device Using FreeNAS - 15
16. Now it will ask if you want to configure IPv6 for this interface, but in this instance I do not, so I will choose No.
Build Your Own Open Source NAS Device Using FreeNAS - 16
17. After a few seconds it will configure itself and you will see a screen showing the IP address you configured and how to access the WebGUI interface. After noting down the URL go ahead and hitENTER.
Build Your Own Open Source NAS Device Using FreeNAS - 17
18. This now sets us up for getting into the WebGUI, go ahead and open your browser and enter the URL you got in step 8. You will be prompted for a user name and password. The defaults are:
username: admin
password: freenas
Build Your Own Open Source NAS Device Using FreeNAS - 18
19. Once you authenticate you will be brought to the main status screen of FreeNAS where you can get some quick status info, which as you can tell is that no disks are configured. Seeing that this is a NAS, this is something we should remedy!
Build Your Own Open Source NAS Device Using FreeNAS - 19
20. First let’s go in and do some general setup tasks to get us started on the right foot. SelectSystem, then General from the top menus.
Build Your Own Open Source NAS Device Using FreeNAS - 20
21. On the General Setup page you can set some standard things for the server such as:
Hostname – Hostname and Domain
DNS – For both IPv4 and IPv6
WebGUI – Username, Protocol (http/https), Port, Language
Time – Timezone, Current Time, NTP Options
After setting your choice of options click on Save.
Note: You can also change the default password by choosing the Password tab.
Build Your Own Open Source NAS Device Using FreeNAS - 21

Stay Tuned!

In Part 2 of Build Your Own Open Source NAS Device Using FreeNAS we’ll get the disks setup so our NAS can fulfill its big role. We’ll also test the FreeNAS installation to make sure that everything is working correctly.
As we learned last week, NAS provides hard disk space that attaches to a data network and works as a file server
We took a closer look at FreeNAS — a free open source NAS software that supports CIFS/SB, FTP, NFS, RSYNC SSH, AFP, Unison, UPnP, ISCSI, local and Microsoft Active Directory authentication, SoftRAID, disk encryption, and has a WebGUI interface.
Now let’s get to the good stuff!

Setup Disks in FreeNAS

Now that the installation is complete and we have the general server settings done, we need to get disks setup so our NAS can fulfill its primary purpose in life.
1. Select Disks and then Management from the top menu.
Build Your Own Open Source NAS Device Using FreeNAS - 1

2. From the Management tab you can see all the disks that are currently configured and add a new one by click on the plus sign in the lower right corner
Build Your Own Open Source NAS Device Using FreeNAS - 2
3. In the dropdown next to Disk you can choose the hard drive you want to work with. I am going to setup both of the disks I have.
I am going to leave the rest of the options at default, but I want to mention the last one which is thePreformatted File System. If you have disks that are already formatted you can choose that format here. If they are unformatted just leave the default as you can format them later.
When done with your setting click Add. I am going to repeat this for the other hard drive I have on this virtual machine also.
Build Your Own Open Source NAS Device Using FreeNAS - 3
4. Now select Disks and then Format from the top menu.
Build Your Own Open Source NAS Device Using FreeNAS - 4
5. I am going to create a Mirror 1 Raid pairing with these drives, so I am going to choose the first disk in the Disk dropdown, and then in the File System dropdown I am going to chooseSoftwareRaid.
Click on Format Disk to start the setup. After clicking Format you will get a warning that all data will be lost. If you are good with that click Ok. I am going to repeat this same process for the second drive.
Build Your Own Open Source NAS Device Using FreeNAS - 5
6. From the top menu choose Disks, and then choose SoftwareRaid.
Build Your Own Open Source NAS Device Using FreeNAS - 6
7. The RAID 1 tab should be selected, click on the plus sign in the lower right corner.
Build Your Own Open Source NAS Device Using FreeNAS - 7
8. Put a name for your new RAID 1 drive next to Raid name, choose the Balance algorithm you want to use, and select the disks you want to add to the array. Then place a check in the box that says Create and initialize RAID and click on Add.
Build Your Own Open Source NAS Device Using FreeNAS - 8
9. You will be taken back to the main RAID 1 tab now and have to click on Apply changes.
Build Your Own Open Source NAS Device Using FreeNAS - 9
10. On the top menu choose Disks, and then Format.
Build Your Own Open Source NAS Device Using FreeNAS - 10
11. In the Disk dropdown select the RAID drive we just created and depending on what you are going to use this for you might want to change the File System, but in our case where we are just using this for extra storage leave the default UFS in place.
If you want, give your volume a name and then click on Format disk. After clicking you will get a warning about erasing all data, click Ok to start the format.
Build Your Own Open Source NAS Device Using FreeNAS - 11
12. From the top menu now select Disks, then Mount Point.
Build Your Own Open Source NAS Device Using FreeNAS - 12
13. Click on the Plus sign to mount the RAID disk.
Build Your Own Open Source NAS Device Using FreeNAS - 13
14. For the Disk dropdown choose the RAID drive you created, in the Partition dropdown we will leave the default; enter a name next to Share name. I will leave the rest of the settings as is and click Add.
Build Your Own Open Source NAS Device Using FreeNAS - 14
15. You will be taken back to the Mount Point page where you are asked to Apply changes to confirm mounting of the disk. Click on Apply changes.
Build Your Own Open Source NAS Device Using FreeNAS - 15
16. Now that we have the drive setup and mounted, let’s turn on the CIFS/SMB service so our Windows clients can access the drive. In the top menu click on Services, and then CIFS/SMB.
Build Your Own Open Source NAS Device Using FreeNAS - 16
17. On the Settings tab click the box that says Enable then click Save and Restart at the bottom. I am going to leave all the other settings at their default. You can always come back at a later time and tweak for performance.
Build Your Own Open Source NAS Device Using FreeNAS - 17
18. Click on the Shares tab and then click on the Plus sign.
Build Your Own Open Source NAS Device Using FreeNAS - 18
19. To setup the share you need to enter a Name, Comment, and Path. The path is easily set by hitting the  button and choosing the top level path.
I am going to leave the other settings default, but there are some options there that might be of use so make sure you look through them. When you are done click Add.
Build Your Own Open Source NAS Device Using FreeNAS - 19
20. You are then taken back to the Shares tab to confirm your selection. Click on Apply changes.
Build Your Own Open Source NAS Device Using FreeNAS - 20
You have now successfully setup the drives as a RAID 1 drive and also setup a service/share to allow Windows clients to access the drive. Let’s test it out.

Testing Your FreeNAS Installation

We can quickly and easily test this from a Windows Vista machine. I am going to go to Start and then Network. As you can see, the FreeNAS server is in my network browsing.
Build Your Own Open Source NAS Device Using FreeNAS - 21
If I click on the FreeNAS server I can see the Data share that was setup.
Build Your Own Open Source NAS Device Using FreeNAS - 22
From here I could map a drive or just setup a shortcut to access this drive.

Summary

This demo walked you through creating a RAID 1 shared NAS using the open source FreeNAS software.
FreeNAS is a very powerful software package and I only scratched the surface of what it can do with it. I will be using this server in some upcoming tutorials focusing on ISCSI and open source backup solutions.
I strongly encourage you to download and take a look at the feature set to see where you could use this low cost NAS solution.