trying to adapt cachyos kernel from zena linux

This commit is contained in:
tumillanino
2026-04-08 16:37:17 +10:00
parent a78782e54d
commit e00db9e3fa
4 changed files with 74 additions and 2 deletions

View File

@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# Replaces the stock Fedora kernel with the CachyOS LTO kernel.
# CachyOS LTO kernel is compiled with Link-Time Optimization and ships
# sched-ext (SCX) support, giving lower latency for realtime audio workloads.
#
# Adapted from the Zena project (https://github.com/zena-linux/zena),
# specifically build-scripts/modules/base/kernel.sh.
# Zena is licensed under the Apache License 2.0.
# Credit to the Zena contributors: https://github.com/zena-linux/zena/graphs/contributors
set -ouex pipefail
shopt -s nullglob
KERNEL_PACKAGES=(
kernel-cachyos-lto
kernel-cachyos-lto-core
kernel-cachyos-lto-devel-matched
kernel-cachyos-lto-modules
)
# Disable kernel install hooks so the custom kernel installs cleanly into the image
pushd /usr/lib/kernel/install.d
printf '%s\n' '#!/bin/sh' 'exit 0' > 05-rpmostree.install
printf '%s\n' '#!/bin/sh' 'exit 0' > 50-dracut.install
chmod +x 05-rpmostree.install 50-dracut.install
popd
# Remove stock Fedora kernel packages
for pkg in kernel kernel-core kernel-modules kernel-modules-core; do
rpm --erase "$pkg" --nodeps || true
done
# Remove leftover kernel module directory
CURRENT_MODULES=$(ls /usr/lib/modules | head -n1)
if [ -n "$CURRENT_MODULES" ]; then
rm -rf "/usr/lib/modules/$CURRENT_MODULES"
fi
# Install the CachyOS LTO kernel (repos were added via the preceding dnf module)
dnf5 -y install "${KERNEL_PACKAGES[@]}"
# Version-lock to prevent the kernel from being overwritten by base image updates
dnf5 versionlock add "${KERNEL_PACKAGES[@]}" || true
# /boot is not used in atomic container images
rm -rf /boot/*