Cheap VPS & Xen Server


Residential Proxy Network - Hourly & Monthly Packages

Network-Attached Storage With FreeNAS


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:

1

We want to have two partitions on our first hard drive (one for FreeNAS, one for data storage), so we select 2:

2

Enter the name of your CD-ROM drive. In my case it was acd0:

3

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:

4

FreeNAS is now being installed. Afterwards press <ENTER>, then 3 and 5 to reboot the system:

5

6

7

Confirm that you want to reboot by typing y:

8

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:

9

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:

10

We don’t want to configure another LAN interface, so we simply hit <ENTER>:

11

FreeNAS needs to reboot again. Confirm this by pressing y:

12

After the reboot type 2 to set the IP address of the FreeNAS system:

13

We want a static IP address, so we answer Do you want to use DHCP? with n:

14

Then enter the IP address you want to assign to the FreeNAS system. I use 192.168.0.100:

15

Next enter the subnet mask. I use 24:

16

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>:

17

Now let’s test if our network connection is working. Therefore we type in 6:

18

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:

19

If everything goes well, the ping should succeed, and we can press <ENTER>:

20

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.

21

The welcome page looks like this:

22

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.

20a

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:

20b

20c

After the reboot we can connect to the web interface again. Go to System -> General setup and fill in two DNS servers (e.g. 145.253.2.75 and 193.174.32.18). 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:

20d

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:

23

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):

24

On the next screen hit Apply changes:

25

The data partition has now been added to FreeNAS:

26

To use it, we must mount it. Therefore we go to Disks -> Mount Point and click on the + sign on the right:

27

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:

28

Then apply the changes:

29

The data partition is now mounted and ready for use:

30

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:

31

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):

32

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.

33

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:

34

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:

35

Now open an FTP client and log in anonymously to the FreeNAS server:

36

Again, you should see the data share of the first FreeNAS hard drive, which should be readable and writable:

37

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:

38

Select ad1 and choose Unformated under Preformated FS (ad1 wasn’t formated during FreeNAS installation):

39

Do the same for ad3:

40

On the Disks -> Management page, click on Apply changes:

41

42

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:

43

The next screen should be similar to this one:

44

Now do the same for ad3:

45

ad1 and ad3 should now be listed on the Disks -> Management page with the file system gmirror:

46

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:

47

Give the RAID array a name and select ad1 and ad3 as members of the new volume, then hit Add:

48

Then apply the changes:

49

50

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:

51

The next screen should be similar to this one:

52

All that is left to do is mount the RAID array. Therefore we go to Disks -> Mount Point and click on the + sign:

53

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:

54

After you’ve applied the changes the RAID array should be available as a NAS share:

55

56

To check the status of your RAID array, you can go to Disks -> Software RAID and click on the Information tab:

57

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:

58

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 +:

59

Enter a name and description for the group and click on Add:

60

61

62

Next go to the Users tab and click on +:

63

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:

64

Apply the changes:

65

66

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:

67

After the successful login, you can see both NAS shares:

  • FreeNAS: http://www.freenas.org
  • WinSCP: http://winscp.net

 

Comments

comments