This is a tutorial to build KernelSU-Next (rifsxd) with SuSFS (simonpunk) integrated in to an AOSP, GKI (Generic Kernel Image) or GKI LTS (Generic Kernel Image; (Long Term Support)) kernel using AOSP. This is used to gain escalation on your mobile device.

This tutorial will use Pixel 7a (Lynx) as an example (Pixel 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).

This was amended on 8/29/25.
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).

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 7 / 8).
This was amended on 8/29/25.
You can get this information by unpacking the stock boot.img (boot-stock.img) with magiskboot and taking note of the linux version string:
magiskboot unpack boot-stock.img
strings kernel | grep -i 'linux version'

…..

Clone susfs4ksu:
Note: If you have done the previous tutorial(s), then: cd susfs4ksu && git fetch origin aosp-android14-6.1-dev && git checkout aosp-android14-6.1-dev
git clone --depth 3 --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 AOSP (kernel (which is GKI in the past)). For GKI and / or GKI-LTS, please see below (patching with susfs4ksu section).
This was amended on 8/23/25.

Create the source folder for the repository and the destination directory for the build:
Note: If you’ve done the previous tutorial(s), then: rm -rf android-kernel/*
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=3
repo sync -c --no-tags
cd ..

Note: If you want GKI –
This was amended on 8/23/25.
Note2: Use the branch designated for your device’s codename. Replace ‘lynx’ (below) with it.
Note3: If you want to perform a synchronization, change back to the device codename’s branch (replace CODENAME with your device’s codename): cd aosp-kernel/aosp && git checkout android-gs-CODENAME-6.1-android16 && cd ../ && repo sync -c –no-tags
Note4: If you want to synchronize GKI: git checkout android14-6.1-2025-08 && git pull –depth 3 –no-tags aosp android14-6.1-2025-08
Note5: If you want to move to a new date, do to the below (change the date), then remove the previous from local tracking: git branch -D android14-6.1-2025-MONTH


cd aosp-kernel/aosp
git fetch --depth 3 --no-tags aosp android14-6.1-2025-08
git checkout android-gs-lynx-6.1-android16
git checkout android14-6.1-2025-08
cd ../../

Note: If you want GKI-LTS –
This was amended on 8/23/25.
Note2: Use the branch designated for your device’s codename. Replace ‘lynx’ (below) with it.
Note3: If you want to perform a synchronization, change back to the device codename’s branch (replace CODENAME with your device’s codename): cd aosp-kernel/aosp && git checkout android-gs-CODENAME-6.1-android16 && cd ../ && repo sync -c –no-tags
Note4: Use the current date (2025-08 as of this writing) of development in the repository. You can also use the current development tag (i.e. append _rNUM (NUM = 1, 2, 3, etc.) to the DATE).
Note5: You can also use a tag instead of branch
Note6: If you want to synchronize GKI-LTS: git checkout android14-6.1-lts && git pull –depth 3 –no-tags aosp android14-6.1-lts
cd aosp-kernel/aosp
git fetch --depth 3 --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:
This was amended on 8/23/25, 8/29/25, 8/30/25.
cd aosp-14
cp -p ../susfs4ksu/kernel_patches/fs/* aosp/fs
cp -p ../susfs4ksu/kernel_patches/include/linux/* aosp/include/linux

If you want AOSP:
cp -p ../susfs4ksu/kernel_patches/50_add_susfs_in_gki-android14-6.1.patch aosp

If you want GKI:
cp -p ../susfs4ksu/kernel_patches/50_add_susfs_in_gki-android14-6.1_GKI.patch aosp

If you want GKI-LTS:
cp -p ../susfs4ksu/kernel_patches/50_add_susfs_in_gki-android14-6.1_GKI-LTS.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:
This was amended on 8/23/25, 8/29/25, 8/30/25.
cd aosp

If you want AOSP:
patch -p1 -ui 50_add_susfs_in_gki-android14-6.1.patch

If you want GKI:
patch -p1 -ui 50_add_susfs_in_gki-android14-6.1_GKI.patch

If you want GKI-LTS:
patch -p1 -ui 50_add_susfs_in_gki-android14-6.1_GKI-LTS.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:
This was amended on 8/23/25, 8/29/25, 8/30/25.
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)
This was amended on 8/29/25, 8/30/25.
tools/bazel run --kernel_package=@//aosp --config=no_download_gki --config=fast --config=stamp --config=lynx --lto=thin //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):
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
build/building-pixel-kernels
ChatGPT to crawl repos / sanity checking / specific implementation assistance