Skip to content

Instantly share code, notes, and snippets.

@supechicken
Last active March 21, 2026 01:27
Show Gist options
  • Select an option

  • Save supechicken/c0e4dcac64e3d64bed30737bda8a082e to your computer and use it in GitHub Desktop.

Select an option

Save supechicken/c0e4dcac64e3d64bed30737bda8a082e to your computer and use it in GitHub Desktop.
Script for installing KernelSU on Debian-based distros with DKMS
#!/bin/bash
# kernelsu-dkms.sh: Install KernelSU on Debian-based Linux distros with DKMS, tested on Linux Mint 22.3
#
# Usage: curl -L https://gist.github.com/supechicken/c0e4dcac64e3d64bed30737bda8a082e/raw/kernelsu-dkms.sh | sudo bash
set -eu
RED='\e[1;31m'
YELLOW='\e[1;33m'
GREEN='\e[1;32m'
BLUE='\e[1;34m'
GRAY='\e[0;37m'
MAGENTA='\e[1;35m'
RESET='\e[0m'
WORK_DIR="${TMPDIR:-/tmp}/kernelsu-dkms"
AUR_GIT="https://aur.archlinux.org/kernelsu-dkms.git"
AUR_BRANCH="master"
KSU_GIT="https://github.com/supechicken/KernelSU.git"
KSU_BRANCH="waydroid"
MODLOADER_URL="https://github.com/shadichy/modloader/releases/download/v2.0.0/modloader-x86_64-glibc"
# root check
if [[ ${EUID} != 0 ]]; then
echo -e "${RED}[+] Please run this script as root!${RESET}"
exit 1
fi
function cleanup() {
echo -e "${BLUE}[+] Cleanup...${RESET}"
rm -rf "${WORK_DIR}"
}
trap cleanup EXIT
# install required packages
if command -v git &>/dev/null; then
echo -e "${BLUE}[+] Installing required packages...${RESET}"
apt install dkms git
fi
mkdir -p "${WORK_DIR}"
cd "${WORK_DIR}"
echo -e "${BLUE}[+] Downloading sources...${RESET}"
git clone "${AUR_GIT}" -b "${AUR_BRANCH}"
git clone "${KSU_GIT}" -b "${KSU_BRANCH}"
curl -L "${MODLOADER_URL}" -o modloader
# extract version info, setup dkms.conf
KSU_VER="$(grep -m1 '^pkgver=' kernelsu-dkms/PKGBUILD | cut -d'=' -f2)"
KSU_GIT_VER="$(git -C KernelSU rev-list --count HEAD)"
DKMS_DIR="/usr/src/kernelsu-${KSU_VER}"
rm -rf "${DKMS_DIR}"
cp -r KernelSU/kernel "${DKMS_DIR}"
cp -r kernelsu-dkms/{dkms.conf,Makefile} "${DKMS_DIR}"
sed -i "s|@PKGVER@|${KSU_VER}|g; s|@KSU_GIT_VERSION@|${KSU_GIT_VER}|g;" "${DKMS_DIR}/dkms.conf"
# build it
echo -e "${BLUE}[+] Building KernelSU with DKMS...${RESET}"
dkms install "kernelsu/${KSU_VER}"
# install utilities/configs
echo -e "${BLUE}[+] Installing utilities...${RESET}"
install -Dm755 kernelsu-dkms/00-kernelsu.conf /etc/modprobe.d/00-kernelsu.conf
install -Dm755 kernelsu-dkms/load-kernelsu.in /usr/bin/load-kernelsu
install -Dm755 modloader /usr/bin/modloader
echo -e "${BLUE}[+] Relaxing seccomp restrictions for Waydroid...${RESET}"
sed -i '/reboot/d' /var/lib/waydroid/lxc/waydroid/waydroid.seccomp
echo
echo -e "${GREEN}[+] Done!"
echo -e "${GREEN}[+] Load KernelSU with 'sudo load-kernelsu'${RESET}"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment