UCore stable kernel & prebuilt ZFS packages + Sanoid
- Kernel RPMs from ghcr.io/ublue-os/coreos-stable-kernel image - Matching ZFS RPMs from ghcr.io/ublue-os/akmods-zfs image - Sanoid installed from gregw-extras-fedora-40 COPR - Add systemd timers for weekly ZFS scrubs
This commit is contained in:
parent
a216e14b27
commit
a0dbc64971
|
@ -40,46 +40,28 @@ ARG SOURCE_TAG="40"
|
||||||
|
|
||||||
ARG FEDORA_VERSION=40
|
ARG FEDORA_VERSION=40
|
||||||
|
|
||||||
### 2. Build ZFS module
|
## Cache images for CoreOS kernel & ZFS kmod RPMs
|
||||||
## Adated from https://github.com/coreos/layering-examples/blob/main/build-zfs-module/Containerfile
|
FROM ghcr.io/ublue-os/coreos-stable-kernel:${SOURCE_TAG} AS kernel-cache
|
||||||
FROM ghcr.io/ublue-os/${SOURCE_IMAGE}${SOURCE_SUFFIX}:${SOURCE_TAG} as kernel-query
|
FROM ghcr.io/ublue-os/akmods-zfs:coreos-stable-${SOURCE_TAG} AS zfs-cache
|
||||||
RUN rpm -qa kernel --queryformat '%{VERSION}-%{RELEASE}.%{ARCH}' > /kernel-version.txt
|
|
||||||
|
|
||||||
# Using https://openzfs.github.io/openzfs-docs/Developer%20Resources/Custom%20Packages.html
|
|
||||||
FROM registry.fedoraproject.org/fedora:${FEDORA_VERSION} as builder
|
|
||||||
COPY --from=kernel-query /kernel-version.txt /kernel-version.txt
|
|
||||||
WORKDIR /etc/yum.repos.d
|
|
||||||
RUN curl -L -O https://src.fedoraproject.org/rpms/fedora-repos/raw/f${FEDORA_VERSION}/f/fedora-updates-archive.repo && \
|
|
||||||
sed -i 's/enabled=AUTO_VALUE/enabled=true/' fedora-updates-archive.repo
|
|
||||||
RUN dnf install -y jq dkms gcc make autoconf automake libtool rpm-build libtirpc-devel libblkid-devel \
|
|
||||||
libuuid-devel libudev-devel openssl-devel zlib-devel libaio-devel libattr-devel elfutils-libelf-devel \
|
|
||||||
kernel-$(cat /kernel-version.txt) kernel-modules-$(cat /kernel-version.txt) kernel-devel-$(cat /kernel-version.txt) \
|
|
||||||
python3 python3-devel python3-setuptools python3-cffi libffi-devel git ncompress libcurl-devel
|
|
||||||
WORKDIR /
|
|
||||||
# Uses project_id from: https://release-monitoring.org/project/11706/
|
|
||||||
RUN curl "https://release-monitoring.org/api/v2/versions/?project_id=11706" | jq --raw-output '.stable_versions[0]' >> /zfs_version.txt
|
|
||||||
RUN curl -L -O https://github.com/openzfs/zfs/releases/download/zfs-$(cat /zfs_version.txt)/zfs-$(cat /zfs_version.txt).tar.gz && \
|
|
||||||
tar xzf zfs-$(cat /zfs_version.txt).tar.gz && mv zfs-$(cat /zfs_version.txt) zfs
|
|
||||||
WORKDIR /zfs
|
|
||||||
RUN ./configure -with-linux=/usr/src/kernels/$(cat /kernel-version.txt)/ -with-linux-obj=/usr/src/kernels/$(cat /kernel-version.txt)/ \
|
|
||||||
&& make -j1 rpm-utils rpm-kmod
|
|
||||||
|
|
||||||
|
|
||||||
### 3. SOURCE IMAGE
|
### 2. SOURCE IMAGE
|
||||||
## this is a standard Containerfile FROM using the build ARGs above to select the right upstream image
|
## this is a standard Containerfile FROM using the build ARGs above to select the right upstream image
|
||||||
FROM ghcr.io/ublue-os/${SOURCE_IMAGE}${SOURCE_SUFFIX}:${SOURCE_TAG}
|
FROM ghcr.io/ublue-os/${SOURCE_IMAGE}${SOURCE_SUFFIX}:${SOURCE_TAG}
|
||||||
|
|
||||||
### 4 Add ZFS RPMS and matching kernel RPMs
|
### 3. Add ZFS RPMS and matching kernel RPMs
|
||||||
#COPY --from=ghcr.io/0ranki/sb-zfs-kernel /rpms/ /tmp/rpms
|
# COPY --from=kernel-cache /tmp/rpms/* /tmp/rpms/
|
||||||
COPY --from=builder /zfs/*.rpm /zfs/
|
# COPY --from=zfs-cache /rpms/kmods/zfs/*.rpm /tmp/rpms/
|
||||||
|
|
||||||
### 5. MODIFICATIONS
|
### 4. MODIFICATIONS
|
||||||
## make modifications desired in your image and install packages by modifying the build.sh script
|
## make modifications desired in your image and install packages by modifying the build.sh script
|
||||||
## the following RUN directive does all the things required to run "build.sh" as recommended.
|
## the following RUN directive does all the things required to run "build.sh" as recommended.
|
||||||
|
|
||||||
COPY build.sh /tmp/build.sh
|
COPY build.sh /tmp/build.sh
|
||||||
|
|
||||||
RUN mkdir -p /var/lib/alternatives && \
|
RUN --mount=type=bind,from=kernel-cache,src=/tmp/rpms,dst=/tmp/rpms/kernel \
|
||||||
|
--mount=type=bind,from=zfs-cache,src=/rpms/kmods/zfs,dst=/tmp/rpms/zfs \
|
||||||
|
mkdir -p /var/lib/alternatives && \
|
||||||
/tmp/build.sh && \
|
/tmp/build.sh && \
|
||||||
ostree container commit
|
ostree container commit
|
||||||
## NOTES:
|
## NOTES:
|
||||||
|
|
67
build.sh
67
build.sh
|
@ -4,6 +4,16 @@ set -ouex pipefail
|
||||||
|
|
||||||
RELEASE="$(rpm -E %fedora)"
|
RELEASE="$(rpm -E %fedora)"
|
||||||
|
|
||||||
|
## Package overrides
|
||||||
|
RMPKGS=(
|
||||||
|
firefox
|
||||||
|
firefox-langpacks
|
||||||
|
)
|
||||||
|
|
||||||
|
ADDPKGS=(
|
||||||
|
sanoid
|
||||||
|
)
|
||||||
|
|
||||||
### Install packages
|
### Install packages
|
||||||
|
|
||||||
# Packages can be installed from any enabled yum repo on the image.
|
# Packages can be installed from any enabled yum repo on the image.
|
||||||
|
@ -11,13 +21,56 @@ RELEASE="$(rpm -E %fedora)"
|
||||||
# List of rpmfusion packages can be found here:
|
# List of rpmfusion packages can be found here:
|
||||||
# https://mirrors.rpmfusion.org/mirrorlist?path=free/fedora/updates/39/x86_64/repoview/index.html&protocol=https&redirect=1
|
# https://mirrors.rpmfusion.org/mirrorlist?path=free/fedora/updates/39/x86_64/repoview/index.html&protocol=https&redirect=1
|
||||||
|
|
||||||
rpm-ostree install \
|
## Add gregw/extras COPR
|
||||||
/zfs/*.$(rpm -qa kernel --queryformat '%{ARCH}').rpm && \
|
curl -so /etc/yum.repos.d/gregw-extras-fedora-40.repo https://copr.fedorainfracloud.org/coprs/gregw/extras/repo/fedora-40/gregw-extras-fedora-40.repo
|
||||||
# Auto-load ZFS module
|
|
||||||
depmod -a "$(rpm -qa kernel --queryformat '%{VERSION}-%{RELEASE}.%{ARCH}')" && \
|
## Add systemd timers for periodic ZFS scrubs
|
||||||
echo "zfs" > /etc/modules-load.d/zfs.conf && \
|
cat << EOF > /usr/lib/systemd/zfs-scrub@.service
|
||||||
# we don't want any files on /var
|
[Unit]
|
||||||
rm -rf /var/lib/pcp
|
Description=zpool scrub on %i
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Nice=19
|
||||||
|
IOSchedulingClass=idle
|
||||||
|
KillSignal=SIGINT
|
||||||
|
ExecStart=/usr/sbin/zpool scrub %i
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat << EOF > /usr/lib//systemd/system/zfs-scrub@.timer
|
||||||
|
[Unit]
|
||||||
|
Description=Weekly zpool scrub on %i
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=Mon *-*-* 04:00:00
|
||||||
|
AccuracySec=1h
|
||||||
|
Persistent=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
RMSTRING=""
|
||||||
|
ADDSTRING=""
|
||||||
|
|
||||||
|
for pkg in ${ADDPKGS[@]}; do
|
||||||
|
ADDSTRING="${ADDSTRING} --install=${pkg}"
|
||||||
|
done
|
||||||
|
|
||||||
|
for pkg in ${RMPKGS[@]}; do
|
||||||
|
RMSTRING="${RMSTRING} --remove=${pkg}"
|
||||||
|
done
|
||||||
|
|
||||||
|
rpm-ostree override replace ${ADDSTRING} ${RMSTRING} /tmp/rpms/kernel/*.rpm /tmp/rpms/zfs/*.rpm
|
||||||
|
|
||||||
|
# Auto-load ZFS module
|
||||||
|
depmod -a "$(rpm -qa kernel --queryformat '%{VERSION}-%{RELEASE}.%{ARCH}')" && \
|
||||||
|
echo "zfs" > /etc/modules-load.d/zfs.conf && \
|
||||||
|
# we don't want any files on /var
|
||||||
|
rm -rf /var/lib/pcp
|
||||||
|
|
||||||
#### Example for enabling a System Unit File
|
#### Example for enabling a System Unit File
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue