site  contact  subhomenews

Zfs sanity test

November 16, 2016 — BarryK
I posted about an out-of-memory problem with btrfs:

I decided to try zfs. Followed these instructions to compile the 4.8.7 kernel with zfs built-in. The utilities, such as 'zpool' and 'zfs' are also compiled and installed:

I am running Quirky 8.x x86_64, zfs requires a 64-bit system.

As I know virtually nothing about how to use zfs, some hand-holding is needed. Followed these instructions to setup zfs on a USB flash stick:

In my case, the second partition of the flash stick is /dev/sdd2 and is about 29GB, the same one used for earlier btrfs test. From the above link, this is what I did:

# zpool create -f quirkypool /dev/sdd2
# zfs create quirkypool/bk
# zfs set compression=off quirkypool/bk
# zfs set copies=2 quirkypool/bk

After which I discovered a top-level folder '/quirkypool', mounted as a zfs filesystem.

Then the big moment, copied all of Quirky into it:

# cp -a /path/to/quirky/files/* /quirkypool/bk/

...and it copied, no problem at all.

Due to the "copies=2" it is expected the used space to be about twice the size of the files, and that is the case.

# du -m /path/to/quirky/files
# df -m
quirkypool/bk 27776 3182 24594 12% /quirkypool/bk
# du -m /quirkypool/bk

Yay, now I should try with compression!


I tried with lz4 compression:

# du -m /quirkypool/bk
# df -m
qpool/bk 27776 1433 26344 6% /qpool/bk

Very good!

The setup that I have already done is stored in /etc/zfs/zpool.cache

To access the zfs partition after a reboot, seems need to do this (now have name 'qpool' instead of 'quirkypool'):

# umount /qpool/bk
# umount /qpool
# zpool export qpool

The after a reboot:

# zpool import qpool
# zpool list
qpool 28G 1.40G 26.6G - 1% 4% 1.00x ONLINE -

Of course, my original use of /dev/sdd2 is not good for a removable drive. There are alternatives for specifying an unchanging partition name.

Even with an initramfs, my brief reading indicates it is messy. Apparently it needs a copy of the exact same /etc/zfs/zpool.cache in the initramfs as in the main f.s.

Btrfs shows its superior integration with the kernel here, with easy kernel boot parameters to boot directly without needing an initramfs.

So, have decided to put zfs on the back burner.

Tags: linux