Installing and Configuring ZFS on Debian 9 Stretch

shape
shape
shape
shape
shape
shape
shape
shape

Installing ZFS on Debian 9 Stretch is a simple process that doesn’t require many steps. Let’s go!

First make sure that your “sources.list” repository contains the “contrib” repositories:

deb  http://deb.debian.org/debian stretch main contrib non-free
deb-src  http://deb.debian.org/debian stretch main contrib non-free

deb  http://deb.debian.org/debian stretch-updates main contrib non-free
deb-src  http://deb.debian.org/debian stretch-updates main contrib non-free

Kernel Headers must be installed:

apt-get install linux-headers-$(uname -r)

Then we can start installing ZFS:

apt-get install zfs-dkms zfsutils

A license screen may appear during installation, just ignore it and press “OK”.

In some cases, you will need to use the command below to load the ZFS modules on startup:

systemctl preset zfs-import-cache zfs-import-scan zfs-mount zfs-share zfs-zed zfs.target
systemctl enable zfs-import-scan

That’s it, ZFS is installed. We’ll use the “/dev/sda3” and “/dev/sdb” partitions to create our stripped pool:

zpool create rpool /dev/sda3 /dev/sdb

Let’s visualize our pool:

$ zpool list

NAME    SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
rpool   426G   468K   426G         -     0%     0%  1.00x  ONLINE  -

If you are interested in enabling ZFS compression:

zfs set compress=on rpool

When you want to check the compression ratio:

$ zfs get compressratio

NAME   PROPERTY       VALUE  SOURCE
rpool  compressratio  1.00x  -

Configuring ZFS ARC

ZFS ARC is the mechanism for caching data and storing it in RAM, thus making access much faster. But this feature, if not configured properly, can take up a lot of RAM.

To limit the use of RAM by ZFS ARC, we will create a file in “/etc/modprobe.d/zfs.conf”, and add the following directives below, which will define the minimum and maximum amount (in bytes) of RAM that can be used by ZFS ARC:

options zfs zfs_arc_min=536870912
options zfs zfs_arc_max=1073741824

For our example, we have set a minimum of 512 MB and a maximum of 1024 MB. The values are defined in bytes.

Simply save the file and run the command below to update the kernel image, which will load the ZFS ARC settings applied above on the next boot:

update-initramfs -u

That’s it! Simply restart the server and the ZFS ARC settings will be applied.

Leave a Reply

Your email address will not be published. Required fields are marked *

Latest news

Latest news directly from our blog.