Google Summer of Code on 2006 have sponsored the ZFS-FUSE project which aims to bring Sun’s ZFS on Linux. Because of the incompatibility between Sun’s CDDL license, which ZFS is distributed under, and Linux’s kernel GPL license, ZFS can’t be ported on Kernel level. The workaround to this is to run the filesystem on userspace level with FUSE. A month ago has been released the 0.5.0 version zfs-fuse.
So, how can you get zfs-fuse running on your Linux? In order to compile and use zfs-fuse, you need the following:
– Linux kernel 2.6.x
– FUSE 2.5.x or greater
– libaio and libaio-devel
– zlib and zlib-deve
– glibc version 2.3.3 or newer with NPTL enabled.
For compiling the code:
cd zfs-fuse-0.5.0 cd src scons
If all goes fine, then proceed with the installation:
scons install install_dir=/installation/target
If you don’t define a specific directory to be installed in, then the binaries will be placed in /usr/local/sbin. If you install the binaries in a different directory don’t forget to add the directory path into your $PATH:
Once the installation is finished you can start the zfs-fuse daemon. However, before starting the daemon you’ll need to create the /etc/zfs directory:
That directory used to be automatically created in previous releases but not on 0.5.0 (?). The directory is used to store the zpool.cache file which contains the information of your pools. Having created the directory, what is left is to start the zfs-fuse daemon by simply running the command ‘zfs-fuse’.
You can now create your first pool by issuing the command:
zpool create zfsRoot /dev/sdb
You can replace “zfsRoot” with the name you like for your pool. That will then be created under /. The device at the last part of the command is the disk you want to start using as your ZFS pool. If you want to add /dev/sdc as another one disk to the pool run:
zpool add zfsRoot /dev/sdc
Having the pool set, the new filesystems can start to be created. Creating a filesystem with ZFS is as easy as that:
zfs create zfsRoot/filesystem1
Data can now start being written to the new ZFS filesystem. You’ve probably have mentioned that there hasn’t been defined any capacity for the filesystem. Leaving the filesystem as it is, it will use as much space as it needs and as much as the pool offers. If you want to avoid that, you can set a quota:
zfs set quota=10G zfsRoot/filesystem1
This will set the maximum capacity of the filesystem to 10 GB.
So far so good. What happens if the machine will get rebooted? You’ll need to do some manual work. Having created the /etc/zfs directory everything should be alright. The process should be the following:
– Start zfs-fuse daemon
– import the existing pools:
– Mount the existing filesystems
zfs mount zfsRoot/filesystem1
Then everything should be back in place. The problem is that doing this manually every time can cause problems and definitely doesn’t save any time.
I have written a script which starts and stops the zfs-fuse daemon and mounts any existing filesystems. In order to mount the filesystems, the scripts reads the filesystems from /etc/zfstab which specifies the filesystems in the normal ZFS format ‘zfsRoot/filesystem1’.
Depending on the host operating system, the script could be configured to be a startup script so you’ll not have to run the script manually at all.
The script is setZFS