ZFS on Manjaro

Log of Steps

Kernel Module Installation

Make sure to match module with version of kernel. In my case it was

linux55-zfs
zfs-dkms
zfs-utils

Until zfs-dkms was installed modrpobe zfs command failed to find module. After zfs-dkms modprobe loaded zfs module.

Load ZFS module:

modprob zfs

Check zfs is functional:

zfs list

Automatic ZFS module loading on boot

Make sure zfs module loads manually 1st.

Original instructions: https://wiki.archlinux.org/index.php/Kernel_module#Manual_module_handling.

sudo vi /etc/modules-load.d/virtio-net.conf

and append

zfs

line to the file.

Reboot.

Create ZFS Pool

Follow instructions: https://wiki.archlinux.org/index.php/ZFS#Creating_ZFS_pools

zpool create -f -m /data data /dev/sdb

zpool list output:

NAME   SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
data   464G   135K   464G        -         -     0%     0%  1.00x    ONLINE  -

Create Filesystems

zfs create data/lxd
zfs create data/docker

zfs list output:

NAME          USED  AVAIL     REFER  MOUNTPOINT
data          166K   449G       24K  /data
data/docker    24K   449G       24K  /data/docker
data/lxd       24K   449G       24K  /data/lxd

List

zpool list -H -o size
zpool list

PostgreSQL

sudo zfs create data/psql
zfs list

List access time, compression, primary cache and record size:

zfs get atime,compression,primarycache,recordsize data/psql

Outputs:

NAME       PROPERTY      VALUE         SOURCE
data/psql  atime         on            default
data/psql  compression   off           default
data/psql  primarycache  all           default
data/psql  recordsize    128K          default

Make changes (block size is 16K for FreeBSD, because PostgreSQL on FreeBSD uses block size 16K; 8K is default for Linux):

sudo zfs set atime=off data/psql
sudo zfs set recordsize=8k data/psql
sudo zfs set compression=lz4 data/psql
sudo zfs set primarycache=metadata data/psql

Mount file system to location expected by PostgreSQL on Manjaro Linux:

sudo zfs set mountpoint=/var/lib/postgres/data data/psql

References

  1. Creating ZFS Pools and File Systems provides basic usage instructions.
  2. ZFS from ArchWiki includes DB turning and lots of other detail.
  3. ZFS Dedup Basics
  4. ZFS Features Description
  5. ZFS Raid Levels
  6. Mounting ZFS File Systems