This is a tutorial to build KernelSU-Next (rifsxd) with SuSFS (simonpunk) integrated in to an AOSP kernel. This is used to gain escalation on your mobile device.

This tutorial will use Pixel 7a (Lynx) as an example (Pixel 6 / 7 / 8 can be used) and is geared towards using AVB Android14-11. Other interfaces can be used (the tutorial shows how to get this information), but you would need to, perhaps, fix hunks and / or rejects against the source that is applicable to your device, when using the patches. We will build using Ubuntu 24.0.4.3 on WSL2 (this requires virtualization to be on).

…..

Pre-requirements:
You will need adb / fastboot.
Install git (sudo apt-get update && sudo apt-get -y install git)
You will need magiskboot (place the binary from x86-64 (if on Windows using WSL2 Linux) in to the root of the ~/.bin directory (see below; where you are putting the manual install of repo)). Ensure you set execute permissions on it: chmod u+x magiskboot
Note: magiskboot is only needed to unpack the stock kernel to take a peek at it (strings, etc.).
Install curl (sudo apt-get -y install curl).

You will need to perform a one-time wipe to turn off boot verification so you can boot and flash things you build, to properly test before committal. Please see below but do not remove the -w (wipe USERDATA), but add on the aforementioned flags before it, Thereafter, you will always pass the needed flags when you flash the monthly updates (but remove the -w).
Note: As per Avo and urkiu, leaving it on, doesn’t appear to prevent you from booting and flashing (SPL is being modified). However, antezero ran in to some odd issues which prevented proper back / forth updates and SweBow ran in to a no boot / crash situation, so it is advised to turn it off, which requires a one-time wipe.

Update to the latest monthly update for your device prior (remove any ramdisk modifications you may have made (Magisk), remove -w after fastboot in flash-all script and replace with –disable-verity –disable-verification):
https://developers.google.com/android/images#xxxxx
Replace xxxxx with the codename for your device.

Repo (Use manual install, its newer).

Put the path to it (repo) in your PATH:
export PATH=PATH_TO_REPO:$PATH
Replace PATH_TO_REPO with the /xxx/xxx/xxx path to repo.
You can make it permanent by adding it in to your shell’s .rc file (i.e. if you use BASH then at the end of ~/.bashrc) and source it after (source ~/.bashrc), so it can reflect in your current shell session.

Create a work area for yourself and enter it:
mkdir workarea && cd workarea

We will use android14-6.1 (Pixel 6 / 7 / 8).
You can get this information by unpacking the stock boot.img (see below) with magiskboot and taking note of the linux version string:
strings kernel | grep -i 'linux version'

…..

Clone susfs4ksu:
git clone --depth 2 --no-tags https://gitlab.com/pershoot/susfs4ksu.git -b aosp-android14-6.1-dev

Note: The repo’s branch in mention is set to patch against LTS (kernel). If you are wanting AOSP (kernel (which is GKI in the past)):
cd susfs4ksu
git revert "$(git log --pretty=oneline | grep -w 'kernel_patches: Fix offsets against GKI 14-6.1-lts$' | cut -f1 -d' ')" --no-edit
cd ..

Create the source folder for the repository and the destination directory for the build:
mkdir aosp-kernel
mkdir android-kernel

Pull down the repository:
Note: Use the branch designated for your device’s codename. Replace ‘lynx’ (below) with it.
cd aosp-kernel
repo init -u https://android.googlesource.com/kernel/manifest -b android-gs-lynx-6.1-android16 --depth=2
repo sync -c --no-tags
cd ..

Note: If you want LTS –
Note: Use the branch designated for your device’s codename. Replace ‘lynx’ (below) with it.
cd aosp-kernel/aosp
git fetch --depth 2 --no-tags aosp android14-6.1-lts
git checkout android-gs-lynx-6.1-android16
git checkout android14-6.1-lts
cd ../../

Create a mirror, which you will work against:
rsync -a --del aosp-kernel/ aosp-14

Copy SuSFS module and patches in:
cd aosp-14
cp -p ../susfs4ksu/kernel_patches/fs/* aosp/fs
cp -p ../susfs4ksu/kernel_patches/include/linux/* aosp/include/linux
cp -p ../susfs4ksu/kernel_patches/50_add_susfs_in_gki-android14-6.1.patch aosp
cp -p ../susfs4ksu/kernel_patches/60_scope-minimized_manual_hooks.patch aosp

cp -p ../susfs4ksu/device_patches/10_disable-prebuilt_build-aosp.patch private/devices/google/common

Patch:
cd aosp
patch -p1 -ui 50_add_susfs_in_gki-android14-6.1.patch
patch -p1 -ui 60_scope-minimized_manual_hooks.patch
cd ../private/devices/google/common
patch -p1 -ui 10_disable-prebuilt_build-aosp.patch
cd ../../../../

Pull down KernelSU-Next and execute setup:
curl -LSs "https://raw.githubusercontent.com/pershoot/KernelSU-Next/refs/heads/next-susfs/kernel/setup.sh" | bash -s next-susfs

Remove patches:
rm aosp/50_add_susfs_in_gki-android14-6.1.patch aosp/60_scope-minimized_manual_hooks.patch private/devices/google/common/10_disable-prebuilt_build-aosp.patch

Commit the changes in to your local repository:
cd aosp
git add -A
git commit -a -m "Add KernelSU-Next-susfs"
cd ../private/devices/google/common
git add -A
git commit -a -m "Disable prebuilt; build AOSP"
cd ../../../../

Build:
Note: concatenate (cat) the build_CODENAME.sh (replace CODENAME with your device’s codename) and replace –config=lynx and lynx:gs201_lynx_dist with what’s found in your designated file (below)
tools/bazel run --config=no_download_gki --kernel_package=@//aosp --config=fast --config=stamp --config=lynx --lto=default //private/devices/google/lynx:gs201_lynx_dist -- --dist_dir=../android-kernel

Change in to the kernel output directory:
cd ../android-kernel

Test your boot image (boot.img is found in android-kernel directory you are in):
adb reboot bootloader or vol down and power
fastboot boot boot.img


Note: Wi-Fi / BT will not work (it will, once you place the module(s) built with the same versioning on to the system).

If all looks well (Pixel 7 / 8; Pixel 6: Build Pixel kernels  |  Android Open Source Project):
adb reboot bootloader
fastboot flash boot boot.img
fastboot flash dtbo dtbo.img
fastboot flash vendor_kernel_boot vendor_kernel_boot.img
fastboot reboot fastboot
fastboot flash vendor_dlkm vendor_dlkm.img
fastboot flash system_dlkm system_dlkm.img
fastboot reboot

…..

Install the latest susfs4ksu module (sidex15) through the KernelSU-Next Manager.

Enjoy!

…..

Sources:
pershoot/KernelSU-Next at next-susfs
pershoot/susfs4ksu/-/tree/aosp-android14-6.1-dev
KernelSU-Next/KernelSU-Next: An advanced Kernel based root solution for Android
simonpunk/susfs4ksu/-/tree/gki-android14-6.1
sidex15/susfs4ksu-module: An addon root hiding service for KernelSU
backslashxx/KernelSU
GPT-5 to crawl repos / sanity checking

«