FreeNAS – Setting up ZFS

I always was curious about ZFS but haven’t played with it until very recently. I thought it was too complicated and I was afraid it will use up too much space because of the snapshots capability.

Few days ago I installed the latest beta of FreeNAS 8 on a USB stick (here how it is done) and decided to give a try to ZFS finally.

I use an old laptop and 120GB USB hard-drive. The goal is to create the file system (ZFS) and some Windows (CIFS) shares on top of it that will be available for data storage on my local network.

I will start with creating a group (HomeUsers) and user (john). These will be used later when setting the shares owner. The next two screen-shots show just that:

The newly created group is associated with the user (through the Members button).:

The next step is to create the file system on the USB hard-disk. From the left navigation expand Storage -> Volumes and click on Volume Manager. This will show a pop-up where you type the volume name, select the disk (in this case ada0), the file system type (ZFS) and click Add Volume button:

This will also automatically create a ZFS Scrub for the volume. ZFS has a repair tool called “scrub” which examines and repairs Silent Corruption and other problems. The default interval between consecutive runs is 35 days.

With the new ZFS volume in place you can create either ZFS Volume or ZFS Dataset.

A zvol (ZFS volume) is a feature of ZFS that creates a device block over ZFS. This allows you to use a zvol as an iSCSI device extent for example.

In contrast ZFS datasets allow for more granularity when configuring which users have access to which data. A dataset is similar to a folder in that you can set permissions; it is also similar to a filesystem in that you can set quotas and compression.

NOTE: if your goal is to share an entire ZFS volume, you don’t have to create datasets. If you wish to divide up a ZFS volume’s data into different shares, create a dataset for each share.

The next screen-shot shows creation of a dataset named Backup:

Let’s set the permissions for the new dataset from Storage -> View Volumes -> Change Permissions:

The next thing will be to set up a periodic snapshot for the ZFS volume. The lifetime will be 2 weeks, it will run between 9:00 and 18:00 every hour from Monday to Friday:

Having a periodic snapshots is like having a time machine – you can go back and restore the data to a previous state. This is illustrated in the next article Posted in CodeProject, FreeNAS, Howto | Tagged , | Leave a reply

FreeNAS – Windows (CIFS) Shares on ZFS

In the previous article we talked about Setting up ZFS.

Here we are going to create a Windows (CIFS) share that will be accessible on the local network and will demostrate how to use the ZFS snapshots to restore lost data.

Let’s Add Windows (CIFS) Share from Sharing -> Windows (CIFS) Shares:

Creating a CIFS share will automatically start the service if it is not running already. Alternatively you can manually start or stop the service from Services -> Control Services.

We also have to configure the CIFS service (Services -> CIFS) by providing the NetBIOS name, Workgroup, etc:

Now we can try to access the newly created share by typing \\freenas2\Backup in Windows Explorer:

We have to provide username and password in order access the share. The username is freenas2\john and the password is the one you set up when creating the user:

If you look at the security settings for the share you can see something similar like this:

Now let’s create a simple text file in the share, type some text and save it:

We are going to manually create a snapshot because we do not want to wait an hour for the periodic one to just demonstrate how it works:

We are going to add some more text to the file we created earlier:

Now let’s roll back the snapshot we created – this should bring back the first version of the text file:

Indeed we got the first version of the text file:

This is really a simplistic look at the ZFS snapshots but it at least gives you some idea about how things work. I would personally experiment with bigger files (movies, pictures, etc.) to see how fast snapshots will eat up the disk space.