Skip to content

Instantly share code, notes, and snippets.

@mohakshah
Last active July 15, 2023 04:58
Show Gist options
  • Save mohakshah/b203d33a235307c40065bdc43e287547 to your computer and use it in GitHub Desktop.
Save mohakshah/b203d33a235307c40065bdc43e287547 to your computer and use it in GitHub Desktop.
Building ZFS on Raspberry Pi 3 running Rasbpian

Introduction

This is a tutorial for building and installing the latest release version (0.7.3 as of writing) of "ZFS on Linux" on a Raspberry Pi 3 running Raspbian Stretch. Specifically, we'll be building the dkms version of ZoL, which saves you the hassle of re-compiling the kernel modules after every kernel update. Even though ZoL added support for building dkms packages for debian in version 0.7.3, the build process on a Raspberry Pi 3 is not quite straight-forward. Hopefully, these instructions will make it easier.

Steps

  1. Install the build dependencies.
$ sudo apt-get update
$ sudo apt-get install build-essential autoconf libtool gawk alien fakeroot
$ sudo apt-get install dkms zlib1g-dev uuid-dev libattr1-dev libblkid-dev libselinux-dev libudev-dev libssl-dev parted lsscsi wget ksh

You'll also need the kernel headers. Running apt-get upgrade will take care of both installation and upgradation.

$ sudo apt-get upgrade raspberrypi-kernel raspberrypi-kernel-headers
  1. Download the source.

Download the latest release tarballs for zfs and spl from this page and extract them.

$ wget https://github.com/zfsonlinux/zfs/releases/download/zfs-0.7.3/spl-0.7.3.tar.gz && tar -xzf spl-0.7.3.tar.gz
$ wget https://github.com/zfsonlinux/zfs/releases/download/zfs-0.7.3/zfs-0.7.3.tar.gz && tar -xzf zfs-0.7.3.tar.gz
  1. Compile and install spl.
$ cd spl-0.7.3/
$ autoreconf --install --force
$ ./configure

You need to make a small edit to the Makefile generated by configure before you proceed.

$ sed -E 's/(^RPMBUILD = rpmbuild.*)/\1 --target=armhf/' -i Makefile
$ make pkg-utils deb-dkms
$ for deb in *.deb; do sudo dpkg -i "$deb"; done

The final step will take some time as dkms builds spl modules for each kernel version installed in your system.

  1. Compile and install zfs.

The build process for zfs is the same as spl, albeit with an extra option --with-config=srpm in ./configure

$ cd ../zfs-0.7.3/
$ autoreconf --install --force
$ ./configure --with-config=srpm
$ sed -E 's/(^RPMBUILD = rpmbuild.*)/\1 --target=armhf/' -i Makefile
$ make pkg-utils deb-dkms
$ for deb in *.deb; do sudo dpkg -i "$deb"; done

The zfs source is much bigger than spl's and hence the build time will also be much longer.

  1. Reboot and Enjoy. :)

Sources

@eudocimus
Copy link

eudocimus commented Nov 8, 2019

@MAFLO321
Copy link

MAFLO321 commented Dec 15, 2019

@stefanhinker @colettace
The problem can be fixed with the following to build zfs 0.8.3 on a Raspberry Pi 4:

./autogen.sh
./configure --disable-pyzfs
# https://github.com/zfsonlinux/zfs/issues/9504
sed -E 's/(^RPMBUILD = rpmbuild.*)/\1 --target=armv7hnl-linux-gnueabihf/' -i Makefile

make deb-dkms deb-utils

see openzfs/zfs#9504 for more information

@peterska
Copy link

There is no need to use sed to modify the Makefile. rpmbuild errrors are caused by the rpmbuild package on raspbian not storing the architecture files in an appropriately named directory. You can fix this permanently by running the following:

cd /usr/lib/rpm/platform; sudo ln -s armv7hnl-linux-gnueabihf armv7hnl-linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment