diff --git a/.github/workflows/install-zfs-dkms-module.yml b/.github/workflows/install-zfs-dkms-module.yml new file mode 100644 index 0000000..fbc7720 --- /dev/null +++ b/.github/workflows/install-zfs-dkms-module.yml @@ -0,0 +1,34 @@ +name: "Build image: install-zfs-dkms-module" + +env: + IMAGE_NAME: "install-zfs-dkms-module" + +on: + pull_request: + branches: + - main + paths: + - install-zfs-dkms-module/* + - .github/workflows/install-zfs-dkms-module.yml + push: + branches: + - main + paths: + - install-zfs-dkms-module/* + - .github/workflows/install-zfs-dkms-module.yml + +jobs: + build-image: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Build container image + uses: redhat-actions/buildah-build@v2 + with: + context: ${{ env.IMAGE_NAME }} + containerfiles: ${{ env.IMAGE_NAME }}/Containerfile + image: ${{ env.IMAGE_NAME }} + layers: false + oci: true diff --git a/README.md b/README.md index d023b97..118fe08 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ functionality. - [butane](butane/): Demos using https://github.com/coreos/butane - [initramfs-module](initramfs-module/): Demos generating a initramfs with specific modules added and omitted. - [inject-go-binary](inject-go-binary/): Demos adding building and injecting a Go binary + systemd unit +- [install-zfs-dkms-module](install-zfs-dkms-module/): Install ZFS DKMS Kernel Module - [podman-next](podman-next): Use COPR to install the podman-next package - [rsyslog](rsyslog/): Install and configure rsyslog to forward to a remote host - [replace-kernel](replace-kernel): Replace the kernel using packages from Koji diff --git a/install-zfs-dkms-module/Containerfile b/install-zfs-dkms-module/Containerfile new file mode 100644 index 0000000..797d2e3 --- /dev/null +++ b/install-zfs-dkms-module/Containerfile @@ -0,0 +1,23 @@ +# Install ZFS DKMS Kernel Module +FROM quay.io/fedora/fedora-coreos:stable + +# Install ZFS repository +RUN rpm-ostree install \ + https://zfsonlinux.org/fedora/zfs-release-2-3$(rpm --eval "%{dist}").noarch.rpm && \ + ostree container commit + +# Install dkms dependencies +RUN rpm-ostree install kernel-devel kernel-devel-matched kernel-headers kernel-srpm-macros && \ + ostree container commit + +# TODO: Remove the following line once these bugs are fixed: +# - https://github.com/coreos/rpm-ostree/issues/4201 +# - https://github.com/coreos/rpm-ostree/issues/1614 +RUN test -f /usr/bin/ld || ln -s /usr/bin/ld.bfd /usr/bin/ld + +# Install zfs package and tell dkms to install the kernel module now +RUN rpm-ostree install zfs && \ + dkms autoinstall -k $(rpm -qa kernel --queryformat '%{VERSION}-%{RELEASE}.%{ARCH}') && \ + rm -vrf /var && \ + test -h /usr/bin/ld && rm -v /usr/bin/ld && \ + ostree container commit diff --git a/install-zfs-dkms-module/README.md b/install-zfs-dkms-module/README.md new file mode 100644 index 0000000..2fce306 --- /dev/null +++ b/install-zfs-dkms-module/README.md @@ -0,0 +1,7 @@ +# Install ZFS DKMS Kernel Module + +This example installs the [ZFS](https://openzfs.org/) [DKMS](https://en.wikipedia.org/wiki/Dynamic_Kernel_Module_Support) kernel module. + +This is useful because typically DKMS modules are built during system startup after a kernel has been updated. This doesn't work in `ostree` based distributions because DKMS attempts to install kernel modules into `/usr`, which on `ostree` based distributions is mounted read-only. + +This example is not specific to ZFS and should be able to be applied to other DKMS modules.