You may wonder why you have to install external kernel modules to use ZFS when most other filesystems are integrated into the kernel. The reason is due to licencing. When Sun released the ZFS source code, it did so under the CDDL licence. This is an accepted open source licence, but it’s incompatible with the GPL that’s used to licence the kernel. This means that distributing binaries linked to both sets of source code could break the licence terms. Note the use of the word ‘may’ here: there are differing opinions on the legal ramifications of this, but the only way to truly test it is to go ahead and get sued, then fight the battle in court. As a result, the general approach is to play safe and not include ZFS kernel modules with distros.
Jumping in and converting a whole system to use a different filesystem and volume manager is a big step. It may make more sense to experiment with the possibilities of ZFS before committing to it, and you can do that by using files as the backing store for a pool. Cd into a partition with a decent amount of space and create some sparse files to use as virtual disks. Sparse files appear to be a fixed size, but only occupy the disk space they need for their contents.
Credit: www.freenas.org/zfs
OUR EXPERT
However, Ubuntu has made ZFS available in its main software repositories for a few years and nothing bad has happened, so it’s easy to install ZFS on Ubuntu and friends. However, other distros may require you to compile the modules from source.
$ truncate -s 25G temp0
Neil Bothwick has been using and writing about Linux since before the first “This is the year of Linux on the Desktop”. His life is so full of excitement that he finds filesystems fascinating!.
$ losetup --show --find temp0
QUICK TIP
This will create a 25GB sparse file and set it up as a loop device, printing the device name (/dev/loop0 if you don’t currently have any loop devices). Repeat this for as many virtual disks as you want to create, then use those to create a pool, for example
While we haven’t shown it here, most of the commands should be run as root or prefixed with sudo. The only exceptions are commands that only retrieve information, such as zpool status or zfs list.
$ zpool create testpool mirror /dev/loop{0,1}
L
ife used to be so much simpler. A typical desktop computer had one small – and expensive – hard drive with no more than four partitions using standard filesystems like ext2/3. Okay, so half the hardware out there wasn’t supported by Linux, but that just simplified things even further.
This will set up a mirrored array (effectively RAID1) using two virtual devices. You can now create datasets within the pool. When you’ve finished and want your disk space back, destroy the pool and datasets, then remove the loop devices with
Now we have huge hard disks, often more than one of them, and lots of data strewn across them. Simple partition schemes have been replaced with RAID arrays, volume management and multiple filesystem types. Then we start worrying about privacy and start throwing encryption into the mix, and that’s without considering backups. Thanks to the way in which Linux uses block devices, these multiple technologies can be layered on top of one another fairly easily, so we have filesystems on top of LVM volumes on top of LUKS-encrypted devices on top of a RAID array of several hard disks… and it all works well. It can be a bit of a management headache though, with each layer using a different set of software to manage it.
$ zpool destroy -f testpool