Howto build ZOL (ZFS On Linux) 0.7 from source in Devuan

(For ZOL version 0.8 see here)

Getting ZFS for Devuan was more difficult than I had expected, because

  • ZFS-fuse works, but is totally outdated and thus deprecated.
  • Installing package zfs-dkms 0.7.3 in Devuan 1 from backports contrib fails to configure
    (because it needs dkms version > 2.2.1.0, but Debian has 2.2.0.3-2).
  • Installing zfs-dkms from contrib in Devuan 2 works like described here, but it is old version 6.5.9.

Thus I tried to compile from source, and succeeded with the following commands.
This goes the detour of creating deb packages, because installing directly somehow did not work. Maybe I made a mistake, maybe deb packets are really required, whatever, I document the method that worked.

This was tested in

  • Devuan 1.0 "Jessie" with ZOL 0.7.3, 0.7.5, and 0.7.6.
  • Devuan 2.0 "ASCII" with ZOL 0.7.6, 0.7.7, 0.7.9, and 0.7.13 (avoid version 0.7.7, it has a bug).
  • Devuan 2.0 "ASCII" with ZOL 0.8: see here

Prepare

# install prerequisites
# (from https://github.com/zfsonlinux/zfs/wiki/Building-ZFS)
aptitude install build-essential autoconf libtool gawk alien fakeroot
aptitude install zlib1g-dev uuid-dev libattr1-dev libblkid-dev libselinux-dev libudev-dev
aptitude install parted lsscsi ksh libssl-dev
aptitude install linux-headers-$(uname -r)

Note: linux-headers-$(uname -r) must be re-installed after kernel updates.

# import gpg-key
# (info from https://github.com/zfsonlinux/zfs/wiki/Signing-Keys)
cd /usr/src
wget "http://pool.sks-keyservers.net/pks/lookup?op=get&search=0x6AD860EED4598027" -O D4598027.key
gpg --import D4598027.key

Download and Verify

version=0.7.13
cd /usr/local/src

# download source
# (URLs from https://zfsonlinux.org)
wget https://github.com/zfsonlinux/zfs/releases/download/zfs-$version/spl-$version.tar.gz
wget https://github.com/zfsonlinux/zfs/releases/download/zfs-$version/zfs-$version.tar.gz
wget https://github.com/zfsonlinux/zfs/releases/download/zfs-$version/zfs-$version.sha256.asc

# verify (must say "good signature")
gpg --verify zfs-$version.sha256.asc
# extract
gpg zfs-$version.sha256.asc
# compare (must say "OK" twice)
sha256sum -c zfs-$version.sha256

Compile

version=0.7.13
cd /usr/local/src

# extract
zcat spl-$version.tar.gz | tar xf -
zcat zfs-$version.tar.gz | tar xf -

# make sure that the latest header files are installed (required after kernel-updates)
aptitude install linux-headers-$(uname -r)

# build spl
cd /usr/local/src/spl-$version
sh autogen.sh
./configure
make -j $(nproc)
make -j1 deb

# build zfs
cd /usr/local/src/zfs-$version
sh autogen.sh
./configure --with-spl=/usr/local/src/spl-$version
make -j $(nproc)
make -j1 deb

Install

version=0.7.13
cd /usr/local/src

# install spl
dpkg -i spl-$version/spl_$version-1_amd64.deb
dpkg -i spl-$version/kmod-spl-$(uname -r)_$version-1_amd64.deb

# install zfs
dpkg -i zfs-$version/libzfs2_$version-1_amd64.deb
dpkg -i zfs-$version/zfs_$version-1_amd64.deb
dpkg -i zfs-$version/kmod-zfs-$(uname -r)_$version-1_amd64.deb
dpkg -i zfs-$version/libnvpair1_$version-1_amd64.deb
dpkg -i zfs-$version/libuutil1_$version-1_amd64.deb
dpkg -i zfs-$version/libzpool2_$version-1_amd64.deb

# load modules once
# cd /usr/local/src/zfs-$version/scripts
# bash zfs.sh  # does not work any more
modprobe zfs   # better alternative

# automate loading of modules on each reboot
# (from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=826994#30)
update-rc.d zfs-import defaults
update-rc.d zfs-mount defaults
update-rc.d zfs-zed defaults   # optional
update-rc.d zfs-share defaults # optional

Test

mkdir /scratch
for i in {1..3}; do truncate -s 2G /scratch/$i.img; done
zpool create zpool raidz1 /scratch/{1..3}.img
zpool list
zpool status
zfs list

Looks good so far. Even /etc/zfs/vdev_id.conf works (after udevadm trigger, albeit not with the /scratch/images).

Update to later version

First unmount the zfs-filesystems

zfs umount zpool

Then uninstall the old version:

dpkg -r spl kmod-spl-$(uname -r)
dpkg -r zfs libzfs2 kmod-zfs-$(uname -r)
dpkg -r libnvpair1 libuutil1 libzpool2

If you installed a new kernel: reinstall the headers package

aptitude install linux-headers-$(uname -r)

Finally recompile and reinstall both spl and zfs like above.
Note: if you keep using the same version of spl and zfs: run "make clean" before "./configure".


Updates:
2019-07-02
libzfs2 must all of a sudden be installed before zfs
2019-05-28
tested version 0.7.13 in Devuan 2.0
2018-06-20
tested version 0.7.9 in Devuan 2.0
added gpg check
2018-06-13
re-inserted commands "make -j $(nproc)" because "Missing spl symbols", "RPM build errors"
2018-04-04
tested in Devuan 2.0 beta
2018-03-19
tested version 0.7.6.
2017-12-29
version 0.7.3 hardcoded → $version 0.7.5 variable
added dpkg -i kmod-spl & kmod-zfs
added update-rc.d commands
2017-11-29
started

Impressum