Run the XanMod kernel on Clear Linux with ease.
The motivation comes from liking the Clear and XanMod Linux kernels, and opportunity to run a preempt-enabled kernel patched with BORE (Burst-Oriented Response Enhancer) CPU Scheduler. The kernels are configured to run equally well on all x86-64 CPUs with minimum support of x86-64-v3.
All variants include the v4l2-loopback patch and NTSync for fast kernel-backed Wine.
clear - Clear native kernel + preemption
bore - XanMod kernel + preemption + BORE
The *-rt
variants include the Linux realtime patch set.
clear-rt
bore-rt
The Clear kernel config enables ZSTD module compression, since 41850. Thus, installation requires CL 41850 (or later) to continue i.e. kmod, toolchain, and zstd updates.
Install build-essential bundles or prerequisites for building the kernel.
The wget
command is used to fetch the source archive from the web.
sudo swupd bundle-add \
bc bison c-basic devpkg-gmp devpkg-elfutils devpkg-openssl flex \
kernel-install linux-firmware lz4 make package-utils wget xz \
dkms hardware-uefi init-rdahead
The power tweaks service is how Clear Linux sets reasonable power management
defaults. For additional tweaking and response time consistency, copy the
sample file to the /etc
folder, or merge the entries manually. This requires
the clr-power
service, enabled by default.
sudo cp share/clr-power-tweaks.conf /etc/.
Set boot-timeout and system‐wide configuration to avoid clr‐boot‐manager
changing efi variables.
sudo mkdir -p "/etc/kernel"
sudo tee "/etc/kernel/timeout" >/dev/null <<'EOF'
5
EOF
sudo tee "/etc/kernel/update_efi_vars" >/dev/null <<'EOF'
false
EOF
Copy the NTSync udev rule.
sudo mkdir -p /etc/udev/rules.d
sudo cp share/99-ntsync.rules /etc/udev/rules.d/.
The GitHub repo provides auto completion for the bash
shell.
git clone https://github.com/marioroy/clearmod
cd clearmod
mkdir -p ~/.local/share/bash-completion/completions
cp -a share/bash-completion/completions/* \
~/.local/share/bash-completion/completions/
The fetch-src
command (run first) fetches *.src.rpm
and *.tar.gz
from
Clear and XanMod, respectively. The optional release argument to xm-install
and xm-uninstall
is described below.
Note: Running a realtime kernel using NVIDIA graphics requires 550 minimally. The 535 driver on RT may result in schedule/lock errors.
./fetch-src
./xm-build clear | clear-rt | bore | bore-rt
./xm-install clear | clear-rt | bore | bore-rt [<release>]
./xm-uninstall clear | clear-rt | bore | bore-rt [<release>]
./xm-uninstall all
./xm-kernels - list kernels and packages
./xm-purge - purge packages
The following are the steps to fetch the stable sources, build, and install the kernel.
./fetch-src
./xm-build bore
./xm-install bore
sync
To quickly build a trimmed Linux kernel, LOCALMODCONFIG=1
will build only
the modules you have running. Therefore, make sure that all modules you will
ever need are loaded. Keyboard modules for the cpio
package, CD-ROM/DVD and
EXFAT/NTFS3 filesystems, and NTSYNC are added in the SPEC files.
The default timer frequency is HZ_800
. To override, define HZ=value
to
100
, 250
, 300
, 500
, 625
, 800
, or 1000
. A lower Hz value
may decrease power consumption or fan speed revving up and down. A great Hz
value for the desktop environment is 800 or 1000.
./fetch-src
LOCALMODCONFIG=1 HZ=800 ./xm-build clear
./xm-install clear
sync
The xm-kernels
command lists xm*
kernels only. An asterisk indicates
the kernel is live or running. One may not install over it or uninstall.
Boot into another kernel before removal via xm-uninstall
.
./xm-kernels
XM boot-manager entries
* org.clearlinux.xmbore.6.10.5-194
org.clearlinux.xmclear.6.10.5-194
XM installed packages (excluding dev,extra,license)
* linux-xmbore-6.10.5-194
linux-xmclear-6.10.5-194
The xm-install
and xm-uninstall
commands accept an optional argument to
specify the release number. By default, xm-install
installs the most recent
build. Omitting the 2nd argument, xm-uninstall
removes all releases.
Though, skips the running kernel.
./xm-uninstall clear 194
Removing org.clearlinux.xmclear.6.10.5-194
The clr-boot-manager update
command may remove older kernel versions.
Run the purge script, periodically, to uninstall packages for xm-kernels
no longer present in /lib/modules
.
./xm-purge
The /boot
partition has limited space. So, no reason to install many kernels.
Build the one you want and enjoy the Clear or XanMod kernel. If changing your
mind later, remember to manage and uninstall any unused kernels. Important:
Keep at least one Clear Linux kernel, installed with the OS or via swupd
.
To limit the number of CPUs used by rpmbuild
, override the %_smp_mflags
macro. Adjust the integer value to your liking.
echo "%_smp_mflags -j4" >> ~/.rpmmacros
You may add a build
script at the top level, ignored by git
.
Set execute bits chmod +x build
and run ./build
.
#!/bin/bash
time LOCALMODCONFIG=1 HZ=800 ./xm-build bore
Configuring PAM or security limits, allowing users to run commands with
real-time capabilities, does not work on Clear Linux. A workaround is making
a copy of chrt
and giving it cap_sys_nice+ep
capabilities. The +ep
indicate the capability sets effective and permitted.
chrt -f 10 echo "Aloha!"
chrt: failed to set pid 0's policy: Operation not permitted
sudo mkdir -p /usr/local/bin
sudo cp -a /usr/bin/chrt /usr/local/bin/.
sudo setcap cap_sys_nice+ep /usr/local/bin/chrt
# The path /usr/local/bin is searched before /usr/bin in $PATH env.
chrt -f 10 echo "Aloha!"
Aloha!