This repository provides scripts to automatically download, patch and compile any version ≥ 5.4 of the Linux Kernel.
linux-tkg also ships with a selection of patches that can improve the desktop/gaming experience: most can be toggled by editing the customization.cfg file, or by simply following the interactive install script.
Important information
- Non-pacman distros support can be considered experimental. You're invited to report issues you might encounter with it.
- If your distro isn't using systemd, please set _configfile="running-kernel" in customization.cfg or you might end up with a non-bootable kernel
- Building recent linux kernels with GCC will require ~20-25GB of disk space. Using llvm/clang, LTO, ccache and/or enabling more drivers in the defconfig will push that requirement higher, so make sure you have enough free space on the volume you're using to build.
- Nvidia drivers might need to be patched to cleanly build/work on latest kernels. Frogging-Family nvidia-all can help you with that 🐸
Customization options
Most customizations can be toggled by:
- Editing the variables in customization.cfg, those values can be overridden by (in increasing priority)
- An external config file: given by the
_EXT_CONFIG_PATHvariable: in the above file or in the environment, defaults to~/.config/frogminer/linux-tkg.cfg. - Setting the variables in the shell environment.
- An external config file: given by the
- Following the interactive install script (it does not prompt for all of them).
Overview
Here's an overview a few toggles from customization.cfg
_timer_freq- Timer frequency depend on sheduler_cpusched- Chose a different CPU scheduler_processor_opt- Tune the compiled code to to a specified CPU eg.znver4._compileroptlevel- Compile with GCC or Clang with optionalO2/O3_lto_mode: Clang only, enableLTOcompiler optimizations.- Build a kernel with less modules: reduces compile time, needed TMPFS/RAM space, and produces a smaller kernel
_kernel_on_diet: uses a ready-made stripped down list of modules to build- Advanced users: using your own module list NOT recommended
- Using
_modprobeddband_modprobeddb_db_pathoptions - Modprobed-db can help build the list: make sure to read thoroughly about it first as a list too short list can produce unbootable kernels or have runtime issues because of missing modules.
- Using
NTsync&Fsyncsupport, including older kernel versions that don't ship them- A patched wine may be needed, see wine-tkg
CPU task schedulers
A CPU task scheduler is the algorithm that decides which task (app, game, background service... etc) one runs when, for how long, on which core, and make it take turns with which other tasks. Those decisions can have an impact on throughput (how many things get done globally per unit of time), and latency (how long tasks have to wait before running again). Gaming is generally more sensitive to latency and some schedulers can be more more adapted for that.
Runtime scheduler swap: sched-ext
Starting kernel ≥ 6.12, it's possible to switch CPU schedulers at runtime while keeping the kernel's built-in default scheduler one as fallback/backup,
using sched-ext. sched-ext offers various schedulers, LAVD is geared towards gaming workloads and used by Steam's
Deck handheld console.
Notes:
- Arch users get scx schedulers from the
scx-schedspackage or on the AUR thanks to @sirlucjan. - For persistence of the chosen runtime scheduler upon reboots:
- set scheduler in
/etc/default/scx - enable the
scxservice:systemctl enable scx.
- set scheduler in
Build-time scheduler swap
EEVDF is the only CPU scheduler available in the upstream "vanilla" kernel sources ≥ 6.6, and CFS for earlier kernel versions.
Alternative build-time default schedulers are optionally available in linux-tkg:
- BORE (Burst-Oriented Response Enhancer) by Masahito Suzuki - CFS/EEVDF based : code repository
- Project C / PDS & BMQ by Alfred Chen: blog, code repository
- MuQSS by Con Kolivas : blog, code repository
- Undead PDS : TkG's port of the pre-Project C "PDS-mq" scheduler by Alfred Chen. While PDS-mq got dropped with kernel 5.1 in favor of its BMQ evolution/rework, it wasn't on par with PDS-mq in gaming. "U" PDS still performed better in some cases than other schedulers, so it's been kept undead for a while.
These alternative schedulers may offer a better performance/latency ratio in some scenarios. The availability of each scheduler depends on the chosen Kernel version: the script will display what's available on a per-version basis.
Bring your own patches
To apply your own patches with linux-tkg:
- Create a
linuxXY-tkg-userpatchesfolder at the root of the clone- where
XandYspecify the kernel version the patches applies to.- Examples:
linux65-tkg-userpatches,linux618-tkg-userpatches
- Examples:
- where
- Set
_user_patches=truein your customization file. - Drop your patches within that folder the
.mypatchextension.
The install script will then find them, and ask if you want to apply each patch.
Kernel config options
linux-tkg starts by default on Arch's full defconfig,
tweaks some CONFIG options in it (either always or based on input from customization.cfg), then proceeds to build the kernel.
To modify kernel config options:
- The baseline kernel defconfic can be overriden with the
_configfilecustomization- Note: The interactive script will override some entries, see next point to revert them if needed.
- Config options can be modified right before the kernel starts building
- GUI/TUI
- The interactive script prompts the user for
make xconfig/menuconfig, then prompts to save the eventual changes into "frag" files- Note: make sure to append the
.myfragextension to the name so the script can automatically reuse them.
- Note: make sure to append the
- The interactive script prompts the user for
- "frag" files: defconfig "fragments" to override the defconfig file, right before the compilation starts
- These files must reside at the root of the
linux-tkgclone and have a.myfragextension. - The intractive script will prompt to apply them, one frag at a time.
- These files must reside at the root of the
- GUI/TUI
Install procedure
For all the supported linux distributions, linux-tkg has to be cloned with git. It is recommended to clone it only once and update it with git pull.
as it keeps a relatively big clone of the kernel's sources within (in the linux-src-git folder, created during the first build after a fresh clone).
Arch & derivatives
git clone https://github.com/Frogging-Family/linux-tkg.git cd linux-tkg # Optional: edit the "customization.cfg" file makepkg -si
The options selected at build-time are installed to /usr/share/doc/$pkgbase/customization.cfg, where $pkgbase is the package name.
Note: the base-devel package group is expected to be installed, see here for more information.
DEB and RPM based distributions
The interactive install.sh script will create, depending on the selected distro, .deb or .rpm packages, move them in the the subfolder DEBS or RPMS then prompts to install them with the distro's package manager.
.debpackages: for Debian, Ubuntu....rpmpackages: Fedora, RHEL, SUSE...
git clone https://github.com/Frogging-Family/linux-tkg.git cd linux-tkg # Optional: edit the "customization.cfg" file ./install.sh install
Uninstalling custom kernels installed through the script has to be done
manually. install.sh can can help out with some useful information:
cd path/to/linux-tkg
./install.sh uninstall-helpGeneric install
The interactive install.sh script can be used to perform a "Generic" install by choosing Generic when prompted or in the _distro customization option.
git clone https://github.com/Frogging-Family/linux-tkg.git cd linux-tkg # Optional: edit the "customization.cfg" file ./install.sh install
The script will compile the kernel then prompt before doing the following:
sudo cp -R . /usr/src/linux-tkg-${kernel_flavor} cd /usr/src/linux-tkg-${kernel_flavor} sudo make modules_install sudo make install
Notes:
- All the needed dependencies to patch, configure, compile or install the kernel are expected to be installed by the user beforehand.
- If you only want the script to patch the sources in
linux-src-git, you can use./install.sh config ${kernel_flavor}is a default naming scheme but can be customized with the_kernel_localversioncustomization option._libunwind_replacecustomization option can replacelibunwindwithllvm-libunwind.- The script uses Arch's
.configfile as a base. A custom one can be provided in the_configfilecustomization option. - The installed files will not be tracked by your package manager and uninstalling requires manual intervention.
./install.sh uninstall-helpcan help with useful information if your install procedure follows theGenericapproach. - Installing the kernel with
make installcalls/sbin/installkernel(see here) to put the kernel at the right place and trigger an initramfs (and UKI) generation, check your distro's documentation on how to configure it to your needs
Gentoo
The interactive install.sh script supports Gentoo by following the same procedure as Generic, with minor additions
- Applies few Gentoo patches
https://dev.gentoo.org/~mpagano/genpatches/trunk/$kver/4567_distro-Gentoo-Kconfig.patchhttps://dev.gentoo.org/~mpagano/genpatches/trunk/$kver/3000_Support-printing-firmware-info.patch
- If using an init other than
systemd, set_gentoo_init='script'incustomization.cfg- Note: for a minimal defconfig, it is then advised to provide your own defconfig through
_configfile=incustomization.cfg: the default Arch defconfig is otherwise used withsystemdrelated config options enabled regardless.
- Note: for a minimal defconfig, it is then advised to provide your own defconfig through
- Symlinks the newly installed
/usr/src/linux-tkg-${kernel_flavor}src folder to/usr/src/linux - Offers to do a
emerge @module-rebuildfor convenience
git clone https://github.com/Frogging-Family/linux-tkg.git cd linux-tkg # Optional: edit the "customization.cfg" file ./install.sh install