Cheat sheet: Install ZFS file system on Ubuntu 14.04

This file system is perfect to be used in a NAS.
You can check Why ZFS over EXT4 or other FS at the bottom of this article.

Install ZFS

Before we can start using ZFS, we need to install it. Simply add the repository to apt-get with the following command:

You should get something like this:

Reboot.

Now, let’s see if it has been correctly compiled and loaded by the kernel

You get an output like this:

Creation of a RAID-Z2 disk array using 4 disks

We will use the zpool create command passing in the disks to use for the array as arguments. By specifying the argument -f it removes the need to create partitions on the disks prior to creating the array.

We check if the zpool is created and ok with issuing this command:

Create ZFS dataset

Creating a dataset is not mandatory. You may use the pool directly. A dataset is like a folder on the volume, but it acts like a filesystem in that it supports snapshots, quotas, compression, NFS or SMB sharing. It’s great to have different mounting points for different usages.

The command to use to create a dataset is:

Here I do:

Let’s see what we have up to now

Add compression

You can add compression on dataset or an entire pool. Adding it to the pool will make all the datasets of the pool to get compression by default. You can decide to not set compression for a specific dataset of the pool though.
As you can see here, compression of the pool datastore1 is not set:

Let’s add it:

After that we should get:

If you want to add compression to the dataset movies:

Delete a dataset

Delete a pool

Why ZFS ?

1. Checksums in Metadata for Data Integrity
This can detect phantom writes, misdirected reads and writes, DMA parity errors, driver bugs and accidental overwrites as well as traditional “bit rot.”

2. Copy on Write
When data is changed it is not overwritten. It is always written to a new block and checksummed before pointers to the data are changed. The old data may be retained, creating snapshots of the file system through time as changes are made.

3. Data Snapshots
ZFS can be configured to take a snapshot of the file system (or a section of it, such as just a user’s home folder) on a regular basis — every 15 minutes, or every hour, and so on. These snapshots are very small and efficient, as only the deltas from the previous snapshot are stored. Snapshots can also be made writable to create clones of existing file systems.

4. Pooled Data Storage
ZFS takes available storage drives and pools them together as a single resource, called a zpool. This can be optimised for capacity, or I/O performance, or redundancy, using striping, mirroring or some form of RAID. If more storage is needed, then more drives can simply be added to the zpool.

5. RAIDZ and RAIDZ2
RAIDZ (equivalent to RAID5) and RAIDZ2 (equivalent to RAID6).
RAID 5 has a well-known flaw called the RAID 5 write hole. This causes a problem when a data block is written to a stripe but a power failure occurs before the corresponding parity block can be written. As a result, the data and parity for the stripe will be inconsistent. If a disk then fails, the RAID reconstruction process will result in incorrect data. The only way out of this is if an entire stripe happens to be overwritten, thus generating a correct parity block.

RAIDZ gets around this problem by using a variable width stripe, so every write is effectively a full stripe write. This, together with ZFS’s copy on write characteristic, eliminates the RAID 5 write hole completely. RAIDZ2 works in a similar way, but can tolerate the loss of two disks in the array using double parity.

6. SSD Hybrid Storage Pools
High performance SSDs can be added to a storage pool to create a hybrid storage pool.

7. Capacity
ZFS is a 128-bit file system, which means that in theory it could store 256 quadrillion ZB (a ZB is a billion TB.)

8. Data Scrubbing
ZFS can be made to scrub all the data in a storage pool, checking each piece of data with its corresponding checksum to verify its integrity, detect any silent data corruption, and to correct any errors in encounters where possible.

9. Simple, Efficient Administration
Using ZFS commands, you can administer a system with short, efficient commands.

Leave A Comment