HOWTO: Installing ZFS and setting up a Raid-Z array on Ubuntu

Readers should note that this applies to Ubuntu 8.10 Intrepid Ibex only!

ZFS is a relatively new filesystem created by Sun. It is released under the CDDL License which is incompatible with Linux’s GPL License, meaning that it can not be installed natively in the kernel. Therefore, for not it is relegated to addon packages and is brought to Ubuntu via the Fuse framework.

For more information on this see the Ubuntu Wiki article on ZFS.

The wiki article also explains this, but getting ZFS installed on Ubuntu is actually pretty straightforward by issuing these commands:

$ sudo echo "deb intrepid main" >> /etc/apt/sources.list.d/zfs-fuse.list
$ sudo echo "deb-src intrepid main" >> /etc/apt/sources.list.d/zfs-fuse.list
$ sudo apt-get update
$ sudo apt-get install zfs-fuse

This installs zfs onto your system. Now to create your raid-z array! Its dead simple.

$ sudo zpool create media -m /storage raidz /dev/sda /dev/sdb /dev/sdc

In the above command:

  • media is the name of the pool,
  • /storage is the mount point (make sure it already exists),
  • raidz is the type of mirroring/striping we are going to run (see more below), and
  • the rest of the options are the devices you are adding into the pool.

Make sure the mount directory already exists.

The type of array you are creating can be the following:

  • mirror will mirror the data across disks
  • raidz will mirror and stripe data across all disks, allowing 1 drive to fail without losing data
  • raidz2 will mirror and stripe data across all disks, allowing 2 drives to fail without losing data (but creating more overhead)

That really is it! You’ll then have a raid array, mounted to your indicated mount point. You can do all kinds of cool stuff with your pool, such as add disks, export the array to a file, import an exported file to the disk, create hot spares, and more.

After far as speed goes, I tested the pool performance with bonnie and also via real world estimates, and I’m only receiving about 20Mb/sec. Its not stellar and I plan to do some more testing as I haven’t tweaked my disks at all and I think I may be able to push it further. This slowness is caused by the checksumming that zfs does — it makes your data extremely safe but it does cause a lot of CPU overhead.

Hopefully ZFS will get more and more stable with time (although I haven’t had any problems with it so far!) and will be included in the Linux kernel, because it really is a great performing, easy to use file system. The uses for it could be tremendous, such as creating a desktop system as a zfs pool and creating instant disk backups from it with minimal overhead. Think: Time Machine for Linux!

Dave Drager

Dave Drager


Sign in or become a free systemBash member to read and leave comments.
Just enter your email below to get an easy log in link.