Skip to content

Instantly share code, notes, and snippets.

@Alexey-Tsarev
Last active March 2, 2021 14:00
Show Gist options
  • Save Alexey-Tsarev/d5809e353e756c5ce2d49363ed63df35 to your computer and use it in GitHub Desktop.
Save Alexey-Tsarev/d5809e353e756c5ce2d49363ed63df35 to your computer and use it in GitHub Desktop.
ZFS 0.8 at Raspberry Pi
#!/usr/bin/env sh
set -e
set -x
CUR_PWD="$(pwd)"
cd "$(dirname $0)"
if [ ! -d zfs ]; then
# https://github.com/zfsonlinux/zfs/wiki/Building-ZFS
sudo apt-get install -y build-essential autoconf automake libtool gawk alien fakeroot ksh
sudo apt-get install -y zlib1g-dev uuid-dev libattr1-dev libblkid-dev libselinux-dev libudev-dev
sudo apt-get install -y libacl1-dev libaio-dev libdevmapper-dev libssl-dev libelf-dev
sudo apt-get install -y python3 python3-dev python3-setuptools python3-cffi
#sudo apt-get install -y linux-headers-$(uname -r)
sudo apt-get install raspberrypi-kernel-headers
sudo apt-get install -y git
git clone https://github.com/zfsonlinux/zfs.git
fi
cd zfs
git checkout .
git checkout zfs-0.8-release
git pull
git branch
make clean || true
make distclean || true
./autogen.sh
autoreconf --install --force
./configure
make -s -j$(nproc)
sudo make install
sudo ldconfig
sudo depmod -a
sudo modprobe zfs
sudo zpool import -a
sudo zpool import -a -d /dev
cd "${CUR_DIR}"
@freddieventura
Copy link

My problem can be fixed by doing

sudo umount /boot
sudo mount /dev/mmcblk0p1 /boot
sudo apt install --reinstall raspberrypi-bootloader
sudo reboot

Thanks for the resource !

@roland-orange
Copy link

Hi Alexey, and again, thank you for the script. I have used this successfully many times, and this way have found ZFS to be sufficiently reliable under the regular 32bit RPiOS to be used in production machines across several kernel updates.

However the script errors out under the recently-released kernel 5.10.11 updates, returning the following. Any guidance as to how I might fix this would be appreciated!

Making all in zcp
Making all in module
/home/pi/Downloads/zfs/zfs/module/zfs/vdev_disk.c: In function ‘vdev_blkg_tryget’:
/home/pi/Downloads/zfs/zfs/module/zfs/vdev_disk.c:506:37: error: ‘struct percpu_ref’ has no member named ‘count’
rc = atomic_long_inc_not_zero(&ref->count);
^~
make[5]: *** [scripts/Makefile.build:279: /home/pi/Downloads/zfs/zfs/module/zfs/vdev_disk.o] Error 1
make[5]: *** Waiting for unfinished jobs....
make[4]: *** [scripts/Makefile.build:496: /home/pi/Downloads/zfs/zfs/module/zfs] Error 2
make[3]: *** [Makefile:1808: /home/pi/Downloads/zfs/zfs/module] Error 2
make[2]: *** [Makefile:30: modules] Error 2
make[1]: *** [Makefile:843: all-recursive] Error 1
make: *** [Makefile:712: all] Error 2

@satmandu
Copy link

FYI the 2.0.x zfs-dkms and related packages in the upcoming ubuntu 21.04 support linux 5.10.x

@roland-orange
Copy link

Thank you. So realistically nothing can be done (other than downgrading the kernel) until the updated zfs-dkms also appear in the RPiOS repos? Or could I try building zfs-dkms from source and then retrying the script above?

@jimmont
Copy link

jimmont commented Mar 2, 2021

@satmandu what's the best way currently to install the 2.0.x zfs-dkms (and related) on 5.10.x (raspberrypi os)?

@satmandu
Copy link

satmandu commented Mar 2, 2021

@jimmont Easiest way would be to upgrade to bullseye, as zfs 2.0.x is already there: https://packages.debian.org/bullseye/zfs-dkms

(The only pain in upgrading to bullseye was that IIRC I had to upgrade to gcc-9 and remove some gcc8 library package which I no longer needed which was holding up other package upgrades.)

@satmandu
Copy link

satmandu commented Mar 2, 2021

(This is assuming that you are on the 64 bit Raspi-OS of course.)

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