test case: build current stable zfs divers for pi4.
Record current kernel release:
$ ls -lt /boot/kernel8.img
-rwxr-xr-x 1 root root 8194604 Feb 16 09:40 /boot/kernel8.img
$ uname -r
5.15.84-v8+
Upgrade to the most current packages:
$ sudo apt update
$ sudo apt upgrade
Prep linux for a build:
$ sudo apt install -y build-essential autoconf automake libtool gawk alien fakeroot dkms libblkid-dev uuid-dev libudev-dev libssl-dev zlib1g-dev libaio-dev libattr1-dev libelf-dev python3 python3-dev python3-setuptools python3-cffi libffi-dev python3-packaging git libcurl4-openssl-dev
At this point you already have headers for 5.10.0-21
, but sadly these are of not much use for building modules for the 5.15.84-v8+
kernel! :-( ... eg. ...
# apt list --installed "linux-headers*"
Listing... Done
linux-headers-5.10.0-21-arm64/stable-security,now 5.10.162-1 arm64 [installed,automatic]
linux-headers-5.10.0-21-common/stable-security,stable-security,now 5.10.162-1 all [installed,automatic]
linux-headers-arm64/stable-security,now 5.10.162-1 arm64 [installed]
Instead, you must apt install
the additional raspberrypi-kernel-headers
package required to build on "Raspberry Pi OS" (aka debian11 on pi4/arm/64)
$ sudo apt install raspberrypi-kernel-headers
Download and build the package containing the driver:
$ git clone https://github.com/openzfs/zfs
$ cd zfs
$ git checkout master
$ sh autogen.sh
$ ./configure
$ make -s -j$(nproc)
$ make -s -j$(nproc) deb
Install the required packages and test:
$ sudo apt install -y $PWD/{zfs,zfs-dkms,libzfs5,libnvpair3,libuutil3}_2.1.99-1734_arm64.deb $PWD/kmod-zfs-`uname -r`_2.1.99-1734_arm64.deb
$ sudo zpool import -a
Enable zfs on boot:
$ sudo systemctl enable --now zfs-import-scan.service zfs-mount zfs-import.target zfs-zed zfs.target zfs-import-cache.service
Reboot and check zfs now works OK! (And finds all existing filesystems... if you have any)
$ df -PhT -t zfs
Filesystem Type Size Used Avail Use% Mounted on
zfs_test zfs 136G 107G 29G 80% /zfs_test
zfs_vault zfs 2.9T 2.7T 192G 94% /zfs_vault
Warning: Do not run rpi-update
, as this appears will install beta/unstable
kernel-6.0.xx (and fresh firmware) and you will stuck in beta tester land... ;-)
But if you do... DougieLawson: "If you update the kernel with rpi-update you'd need to run rpi-source to get the matching kernel source tree and headers."
eg. If you run rpi-update
you will get something like:
# modprobe zfs
modprobe: FATAL: Module zfs not found in directory /lib/modules/6.xx.xx-v8+
Note the 6.0.xx
in /lib/modules/6.0.xx
in the above.
See also: