Last active
October 29, 2023 18:40
-
-
Save mcheshkov/69dfc70fd1ec5bdb875105979c20b75b to your computer and use it in GitHub Desktop.
Building OpenZFS for Fedora CoreOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
FEDORA_MAJOR="38" | |
ARCH="x86_64" | |
KERNEL_VERSION="6.3.8-200.fc38" | |
ZFS_VERSION="2.1.12" | |
podman run \ | |
--interactive \ | |
--tty \ | |
--rm \ | |
-v $(pwd):/data:z \ | |
-e FEDORA_MAJOR=${FEDORA_MAJOR} \ | |
-e ARCH=${ARCH} \ | |
-e KERNEL_VERSION=${KERNEL_VERSION} \ | |
-e ZFS_VERSION=${ZFS_VERSION} \ | |
fedora:${FEDORA_MAJOR} \ | |
/data/internal_build.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -Eeuo pipefail | |
set -x | |
KERNEL_FULL_VERSION="${KERNEL_VERSION}.${ARCH}" | |
ZFS_NAME="zfs-${ZFS_VERSION}" | |
ZFS_FILENAME="zfs-${ZFS_VERSION}.tar.gz" | |
WORKDIR=$(mktemp -d) | |
cd $WORKDIR | |
dnf install -y \ | |
koji | |
koji download-build --arch=${ARCH} --rpm kernel-devel-${KERNEL_FULL_VERSION} | |
dnf install -y \ | |
./kernel-devel-${KERNEL_FULL_VERSION}.rpm | |
dnf install -y \ | |
wget | |
wget https://github.com/openzfs/zfs/releases/download/${ZFS_NAME}/${ZFS_FILENAME} | |
tar xfv ${ZFS_FILENAME} | |
cd ${ZFS_NAME} | |
# https://openzfs.github.io/openzfs-docs/Developer%20Resources/Custom%20Packages.html#get-the-source-code | |
dnf install -y --skip-broken \ | |
epel-release \ | |
gcc \ | |
make \ | |
autoconf \ | |
automake \ | |
libtool \ | |
rpm-build \ | |
kernel-rpm-macros \ | |
libtirpc-devel \ | |
libblkid-devel \ | |
libuuid-devel \ | |
libudev-devel \ | |
openssl-devel \ | |
zlib-devel \ | |
libaio-devel \ | |
libattr-devel \ | |
elfutils-libelf-devel \ | |
kernel-devel-$(uname -r) \ | |
python3 \ | |
python3-devel \ | |
python3-setuptools \ | |
python3-cffi \ | |
libffi-devel \ | |
ncompress | |
dnf install -y --skip-broken --enablerepo=epel --enablerepo=powertools \ | |
python3-packaging \ | |
dkms | |
./configure --with-linux=/usr/src/kernels/${KERNEL_FULL_VERSION} | |
# kmodtool patch is obsolete somewhere from zfs 2.1.6 | |
# /lib/modules/${kernel_uname_r}/System.map ${kernel_uname_r} branch is already present | |
#dnf install -y \ | |
# patch | |
#patch -i /data/patches/*.patch -p 1 | |
make -j1 rpm-utils rpm-kmod | |
cp kmod-zfs-${KERNEL_FULL_VERSION}-${ZFS_VERSION}-1.fc${FEDORA_MAJOR}.x86_64.rpm /data/packages/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From: Mikhail Cheshkov <[email protected]> | |
Date: Sat Aug 7 17:15:45 UTC 2021 | |
Subject: Adjust kmodtool %post script to generate System.map in /lib/modules | |
diff -u a/scripts/kmodtool b/scripts/kmodtool | |
--- a/scripts/kmodtool 2021-07-28 19:13:53.373619061 +0300 | |
+++ b/scripts/kmodtool 2021-07-28 19:15:24.643052684 +0300 | |
@@ -182,9 +182,9 @@ | |
%{?KmodsRequires:Requires: %{KmodsRequires}-uname-r = ${kernel_uname_r}} | |
%{?KmodsRequires:BuildRequires: %{KmodsRequires}-uname-r = ${kernel_uname_r}} | |
%post -n kmod-${kmodname}-${kernel_uname_r} | |
-${prefix}${depmod_path} -aeF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} > /dev/null || : | |
+${prefix}${depmod_path} -aeF /lib/modules/${kernel_uname_r}/System.map ${kernel_uname_r} > /dev/null || : | |
%postun -n kmod-${kmodname}-${kernel_uname_r} | |
-${prefix}${depmod_path} -aF /boot/System.map-${kernel_uname_r} ${kernel_uname_r} &> /dev/null || : | |
+${prefix}${depmod_path} -aF /lib/modules/${kernel_uname_r}/System.map ${kernel_uname_r} &> /dev/null || : | |
EOF | |
else |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I only used this with CoreOS, so no idea how to properly upgrade regular Fedora.
Updates that doesn't touch kernel should be happy with simple
rpm-ostree upgrade
.But if there's a new kernel version it will fail with message like this:
package kmod-zfs-%OLD_KMOD_VERSION% from @commandline requires kernel-uname-r = %OLD_KERNEL_VERSION%, but none of the providers can be installed
Basically, you need to remove old ZFS kmod and install new together with kernel upgrade. One way to do this is something like this:
rpm-ostree status
outputrpm-ostree upgrade --preview
, look forkernel
package.rpm-ostree upgrade --uninstall kmod-zfs-%OLD_KMOD_VERSION% --install /var/local/packages/zfs/kmod-zfs-%NEW_KMOD_VERSION%.rpm