This tutorial shows how you can set up a network-attached storage server with FreeNAS. FreeNAS is based on the FreeBSD operating system and supports CIFS (samba), FTP, NFS, RSYNC, SSH, local user authentication, and software RAID (0, 1, 5). It comes with a powerful web interface and uses very little space on the hard drive – about 32MB.
I do not issue any guarantee that this will work for you!
1 Preliminary Note
In this article I will set up a NAS system with three 30GB hard disks, where the first one is split up in a small partition for the FreeNAS system itself and a large data partition. I will combine the other two hard drives in a RAID1 array. I will use the IP address 192.168.0.100 for my FreeNAS system with the gateway address 192.168.0.1.
2 Installing FreeNAS
Download the latest FreeNAS iso image (0.68 at the time of this writing) from http://www.freenas.org/index.php?option=com_content&task=view&id=20&Itemid=32 and burn it onto a CD. Then boot from that CD.
The following screen will come up. Select 7 to install FreeNAS on the hard drive:
We want to have two partitions on our first hard drive (one for FreeNAS, one for data storage), so we select 2:
Enter the name of your CD-ROM drive. In my case it was acd0:
Then enter the name of the hard drive where you want to install FreeNAS and create the data partition. In my case I select the first hard drive, ad0:
FreeNAS is now being installed. Afterwards press <ENTER>, then 3 and 5 to reboot the system:
Confirm that you want to reboot by typing y:
The system will now reboot. Make sure you remove the FreeNAS CD from the CD-ROM.
After the reboot we want to configure the network of our FreeNAS system. First we have to declare which network interface we want to use in FreeNAS, therefore we type 1:
Enter the name of the LAN interface. FreeNAS shows you a list of valid interfaces, so pick one of these. In my case I use lnc0:
We don’t want to configure another LAN interface, so we simply hit <ENTER>:
FreeNAS needs to reboot again. Confirm this by pressing y:
After the reboot type 2 to set the IP address of the FreeNAS system:
We want a static IP address, so we answer Do you want to use DHCP? with n:
Then enter the IP address you want to assign to the FreeNAS system. I use 192.168.0.100:
Next enter the subnet mask. I use 24:
The network is now configured, and FreeNAS tells us that we can now access the FreeNAS web interface under the address http://192.168.0.100/ in a browser (but we don’t do this yet). Press <ENTER>:
Now let’s test if our network connection is working. Therefore we type in 6:
Next we type in an existing IP address from our local network (e.g. our gateway address, 192.168.0.1 in this example) to see if we can ping it:
If everything goes well, the ping should succeed, and we can press <ENTER>:
3 Further Network Configuration
Now we log in to the FreeNAS web interface by typing http://192.168.0.100/ (or whatever IP address you assigned to FreeNAS) in our browser.
The welcome page looks like this:
We didn’t specify a gateway yet for our FreeNAS system, so we go to Interfaces -> LAN and enter our gateway IP address (192.168.0.1) under Gateway, then we hit Save.
The system must be rebooted for the changes to take effect, so we go to the FreeNAS terminal again and hit 5 and then y:
After the reboot we can connect to the web interface again. Go to System -> General setup and fill in two DNS servers (e.g. 126.96.36.199 and 188.8.131.52). If you don’t specify DNS servers, the system cannot connect to NTP servers if you use an FQDN (like pool.ntp.org – which is the default value) for the NTP server. On the same page, you can also change the admin password from freenas to a different value:
That’s it for the network configuration, no reboot is needed.
4 Configuring Our First Hard Drive For Network-Attached Storage
The caption is a little bit misleading. In fact we want to configure the second partition (the data partition) for NAS, not the whole disk. Please note: You cannot configure the partition for NAS where FreeNAS is installed on! So from the first hard drive we cannot use the first partition because FreeNAS is installed on it.
Go to Disks -> Management and click on the + sign on the right:
On the next page select the ad0 disk (that’s where the data partition is on) and select UFS under Preformated FS (during the FreeNAS installation the installer formatted both partitions on the first hard drive with UFS, whereas the second and third hard drive are still unformated):
On the next screen hit Apply changes:
The data partition has now been added to FreeNAS:
To use it, we must mount it. Therefore we go to Disks -> Mount Point and click on the + sign on the right:
Select the ad0 disk, the partition no. 2 (that’s the data partition), the file system UFS, and under Share Name and Description you specify a name for the share (only characters a-z, 0-9, and the underscore _ are allowed) and a short description that allows you to identify the share. Then click on Add:
Then apply the changes:
The data partition is now mounted and ready for use:
5 Enabling Services
In order to be able to access our NAS shares, we must enable some services on the FreeNAS server first over which we can connect to the shares. In this example I will enable CIFS (samba) so that the shares can be accessed with the Windows Explorer plus FTP and SSH.
To enable CIFS, go to Services -> CIFS and check the Enable checkbox on the right. You can leave all other values unchanged for now (thus allowing anonymous logins – if you need authenticated logins change the value for Authentication and create users under Access -> Users and Groups later on). Then hit Save:
To enable FTP, go to Services -> FTP and check the Enable checkbox on the right. You can leave all other values unchanged, thus allowing anonymous and authenticated logins over FTP (for authenticated logins you must create users under Access -> Users and Groups later on):
To enable SSH, go to Services -> SSHD and check the checkbox on the right side. That way, users can log in using SCP (e.g. WinSCP on Windows systems). The users must be created under Access -> Users and Groups later on.
6 Our First Test
Now that we have allowed anonymous CIFS and FTP logins, we can make our first test. On a windows system in the same local network as the FreeNAS server, go to Start -> Run and type in \\192.168.0.100:
A Windows Explorer window should pop up with the data share from the first FreeNAS hard drive, and you should be able to write to and read from that share:
Now open an FTP client and log in anonymously to the FreeNAS server:
Again, you should see the data share of the first FreeNAS hard drive, which should be readable and writable:
7 Configuring RAID1
Next we want to build a RAID1 array from our second and third hard drive and then use the RAID1 array as a NAS share. Please note that only full hard drives can be used for RAID, not single partitions!
First we must add both hard drives. Go to Disks -> Management and click on the + sign:
Select ad1 and choose Unformated under Preformated FS (ad1 wasn’t formated during FreeNAS installation):
Do the same for ad3:
On the Disks -> Management page, click on Apply changes:
Next we must format ad1 and ad3. Click on the Format tab (still under Disks -> Management), select ad1 and Software RAID: gmirror, then click on Format disk:
The next screen should be similar to this one:
Now do the same for ad3:
ad1 and ad3 should now be listed on the Disks -> Management page with the file system gmirror:
Afterwards we must combine ad1 and ad3 to one RAID1 array. To do this, we go to Disks -> Software RAID and click on the + sign on the right side:
Give the RAID array a name and select ad1 and ad3 as members of the new volume, then hit Add:
Then apply the changes:
Now we must format our new RAID1 array with the UFS file system, so we go to the Format RAID tab (still under Disks -> Software RAID), select our RAID array and hit the Format UFS disk! button:
The next screen should be similar to this one:
All that is left to do is mount the RAID array. Therefore we go to Disks -> Mount Point and click on the + sign:
Select your RAID array. Under Partition you select Software RAID – gmirror, and under File system you choose UFS. Also specify a share name and a description:
After you’ve applied the changes the RAID array should be available as a NAS share:
To check the status of your RAID array, you can go to Disks -> Software RAID and click on the Information tab:
We have already enabled services such as CIFS, FTP, and SSH in chapter 5, so we don’t have to do this again. Our RAID array should immediately be available under these services.
8 Our Second Test
If you check again in your Windows Explorer or your FTP client, you should now also see the RAID share:
9 Adding Local Users
Services such as SSH don’t allow anonymous logins. Also, if you have configured FTP and CIFS to not allow anonymous logins, you must create local users now on the FreeNAS system that can log in to each service.
To create users, we must first create group to which we can add the users. Go to Access -> Users and Groups and then to the Groups tab and click on +:
Enter a name and description for the group and click on Add:
Next go to the Users tab and click on +:
Enter a user name and password and select the group that you’ve previously created. If you enable Full Shell, the user cannot only use SCP (like WinSCP), but also log in on the shell. If you don’t enable Full Shell, the user is restricted to using SCP:
Apply the changes:
10 Using SCP
Now that SSH is enabled on the FreeNAS server and you’ve created a local user, that user can also use SCP (e.g. with WinSCP) to access the NAS shares.
Fill in the host name, user name, and password, and make sure to select SCP:
After the successful login, you can see both NAS shares:
- FreeNAS: http://www.freenas.org
- WinSCP: http://winscp.net