Telegram

Adaway Not Working With KernelSU: How to Fix

Understanding the KernelSU and Adaway Interaction

We understand the frustration that arises when a trusted utility like Adaway fails to function correctly after switching root management solutions to KernelSU. For years, the Android rooting ecosystem relied heavily on Magisk as the de facto standard. However, KernelSU has emerged as a powerful, modern alternative based on the KernelSU kernel patching approach. While it offers superior isolation and security, it also introduces differences in how systemless modules and applications interact with the underlying operating system.

Adaway is the gold standard for system-wide ad blocking on Android. It operates by modifying the /etc/hosts file to redirect ad-serving domains to a null IP address (127.0.0.1 or ::1). Historically, this required the app to have root access to write to the system partition or, in the case of Magisk, to utilize the Magisk Module system to overlay the hosts file systemlessly.

When users migrate to KernelSU, they often find that Adaway cannot gain the necessary permissions to write the hosts file, or the changes simply do not persist after a reboot. This occurs because KernelSU manages access control differently. It does not automatically grant root access to all system apps, and it handles “mount namespaces” distinctively. Adaway relies on a su binary to execute commands as root. If KernelSU does not recognize the request or if the Hosts Module mechanism is not present, the ad-blocking process fails. We will provide a comprehensive, step-by-step solution to bridge this gap and restore seamless ad blocking.

Prerequisites for KernelSU Ad Blocking

Before attempting the fixes outlined in this guide, we must ensure your device environment is correctly configured. A mismatched kernel or missing binaries are the primary causes of failure.

  1. KernelSU Installed: You must have a working KernelSU installation. Check the KernelSU manager app to confirm you have root access.
  2. Compatible Kernel: Ensure your device is running a kernel that has been successfully patched with KernelSU. Custom kernels are often required unless you are using a GKI (Generic Kernel Image) device.
  3. Adaway App: Have the latest version of Adaway installed. We recommend downloading the official APK from the Adaway website or a trusted repository like Magisk Module Repository.
  4. Busybox (Optional but Recommended): While KernelSU often includes its own tools, having Busybox installed ensures that shell scripts used by ad blockers have access to a full suite of Unix utilities.

Fix 1: The Official KernelSU Hosts Module Method

The most robust and recommended method to make Adaway work with KernelSU is to bypass the app’s internal request for a su binary and instead rely on KernelSU’s native module system. KernelSU supports modules similar to Magisk, but the implementation differs. We will utilize a specific module designed to handle the /system/etc/hosts file.

Why the Native App Fails

Adaway tries to execute su -c "cat $hosts > /system/etc/hosts". In a KernelSU environment, the KernelSU manager might intercept this request, but the app’s fallback mechanism might fail if it specifically looks for the Magisk su path or if the SELinux context is not properly relaxed for that specific operation.

Implementing the Fix via KernelSU Modules

We will install a module that creates a writable overlay for the hosts file.

  1. Open the KernelSU Manager: Launch the KernelSU app on your device.
  2. Navigate to Modules: Tap on the Modules tab within the app.
  3. Install New Module: Select “Install from storage” or “Online Module” if available. However, the most reliable method is manually installing a hosts module.
  4. Download the Hosts Module: You need a specific Hosts Module compatible with KernelSU. You can find this in the Magisk Module Repository or community forums like XDA. Look for “KernelSU Hosts Module” or “Universal Hosts Module for KernelSU”.
  5. Flash the Module: Select the downloaded zip file. KernelSU will flash it.
  6. Reboot: A reboot is mandatory for the kernel to load the new module overlay.
  7. Configure Adaway: Open Adaway. Go to Preferences -> Root-based ad blocking. Ensure the “Use backup method” is unchecked. Adaway will detect that it cannot write to the file directly, but it can still read the file.
  8. Update Sources: Tap “Update sources” in Adaway. The app will download the lists. Since we are using a Hosts Module, Adaway technically does not need to write the file anymore. However, Adaway has a feature where it can generate the hosts file and then “apply” it. In this context, “Applying” might fail, but the module handles the mounting.

Note: Some users prefer to use Adaway solely as a source generator. You can use Adaway to download the lists, export the resulting hosts file to a location like /sdcard/hosts, and then manually place that file into the KernelSU module directory via a root explorer. However, the module method is automated and preferred.

Fix 2: The Systemless Hosts Solution (The “Magisk” Way)

If you are using KernelSU alongside Magisk (dual boot patching is rare, but some users switch back and forth), or if you are using a KernelSU fork that maintains Magisk compatibility, you can use the Magisk Systemless Hosts module.

However, pure KernelSU users should look for the “Systemless Hosts” logic adapted for KernelSU. This usually involves a custom module that mounts a new hosts file over the system default.

Crafting a Custom KernelSU Module for Adaway

If you cannot find a pre-built module, we can guide you on the structure required to make Adaway work manually. This requires creating a simple zip file that KernelSU can flash.

  1. Create the Structure:
    • Create a folder named AnyName.
    • Inside, create module.prop.
    • Inside, create a folder structure: system/etc/.
  2. The module.prop File:
    • id=hosts_module
    • name=Hosts Module
    • version=1.0
    • versionCode=1
    • author=YourName
    • description=Redirects system-wide ads
  3. The Hosts File:
    • Run Adaway on your device.
    • Tap “Your lists are up to date”.
    • Tap “Export to SD Card”.
    • Locate the exported hosts file.
    • Copy this file into your system/etc/ folder inside your module structure.
  4. Zip and Flash: Zip the AnyName folder and flash it via KernelSU.

This method is manual but ensures that Adaway never needs to touch the system partition. It simply acts as a manager for the file you manually create.

Fix 3: Adjusting SELinux and Access Control Policies

KernelSU is stricter than traditional root solutions regarding SELinux contexts. Adaway may fail to execute the mount command or write to the temporary directory because the process context is not allowed.

Checking SELinux Status

  1. Open a terminal (Termux).
  2. Type getenforce.
  3. If it returns Enforcing, we need to be careful.

Using KernelSU DenyList / Superuser Rules

  1. Go to the Superuser tab in KernelSU.
  2. Find Adaway in the list.
  3. Check if it has root access granted.
  4. Crucial Step: Tap on the Adaway entry to configure settings.
  5. Mount Namespace: Ensure that “Mount Namespace” is toggled on or off depending on the app’s requirement. For Adaway, it often requires seeing the full system view to modify the hosts file. We recommend enabling “Override KernelSU Context” if available in your version of KernelSU.
  6. SELinux Context: Some KernelSU versions allow you to set SELinux to Permissive specifically for the app. This is a powerful troubleshooting step. Grant Adaway this permission temporarily to see if it resolves the “Apply” issue.

Warning: Running apps in permissive mode can be a security risk. Only do this to verify the fix. If it works, you should revert to Enforcing and rely on the Hosts Module method (Fix 1).

Fix 4: The “Magisk Daemon” Replication Technique

A common reason Adaway fails on KernelSU is that it waits for the Magisk daemon to be active. KernelSU does not have a “Magisk daemon,” but it has its own ksud binary.

Symlinking the Binary

Some users have reported success by creating a symbolic link from the KernelSU binary to the location where Adaway expects the Magisk su binary.

  1. Locate KernelSU Binary: Usually located at /data/adb/ksu/bin/ksud or /system/bin/ksud.
  2. Create Symlink:
    su
    mount -o rw,remount /system
    ln -s /data/adb/ksu/bin/su /system/bin/su
    mount -o ro,remount /system
    
    Note: This is a hack and may break with kernel updates. It is better to patch the Adaway app itself to look for ksud, but that requires recompiling the APK.

Instead of symlinking, we should ensure Adaway is actually calling the correct binary. If you open the Adaway logs (inside the app settings), you might see “Command failed”. This indicates the shell command su is not found or permission denied.

Alternative Approach: Use a Terminal Emulator

  1. Open Termux.
  2. Run su.
  3. Run the command that Adaway is failing to run manually. Usually, this is: cat /data/data/org.adaway/files/hosts > /system/etc/hosts
  4. If this command works manually in the terminal, the issue is purely within the Adaway app’s automation script. You can then rely on the manual export method described in Fix 2.

Fix 5: Using Alternative Ad Blockers Compatible with KernelSU

If Adaway continues to be stubborn, we should consider using an ad blocker that is native to the KernelSU ecosystem. KernelSU allows for more advanced kernel-level filtering.

Rethink DNS

While not a root ad blocker, Rethink DNS is an excellent open-source app that runs a local VPN to block ads. It does not require root, but if you have root, it can use KernelSU to intercept traffic more efficiently via a local DoH/DoT server.

AdGuard

AdGuard has a root version. However, it is proprietary.

Hosts-based Manual Management

If you want to stick to Adaway but simplify the process:

  1. Use Adaway to download lists.
  2. Export the hosts file.
  3. Use a file manager with root access (like MiXplorer or Root Explorer).
  4. Navigate to /data/adb/modules/.
  5. Create a folder my_hosts.
  6. Inside, create system/etc/hosts.
  7. Paste the content from your exported file.
  8. KernelSU will mount this over the system hosts file immediately without a reboot (usually).

Troubleshooting Common Errors with KernelSU and Adaway

We will address specific error messages users encounter when trying to get Adaway working with KernelSU.

“Root Access Denied”

This is the most common error. KernelSU acts as a firewall for root requests. If Adaway is not listed in the Superuser log, it hasn’t requested access.

“Read-only File System”

This happens when KernelSU has mounted the system partition as Read-Only to protect integrity.

“Update Failed: Could not download sources”

This is an Adaway network error, not a root error.

Advanced: Compiling a Kernel with Built-in Hosts Support

For the absolute power user, we can modify the kernel source code to include a default hosts file that is immutable and updated via a script. However, this is overkill for 99% of users and is not recommended unless you are building custom ROMs.

The standard, stable solution remains the Hosts Module approach. It utilizes the KernelSU architecture exactly as intended: modifying the system partition virtually, without touching the actual read-only partitions.

To ensure Adaway functions perfectly with KernelSU, we recommend the following workflow to our users:

  1. Do not rely on the “Apply” button inside Adaway. Treat Adaway as a lists generator.
  2. Install a Hosts Module for KernelSU. Search the Magisk Module Repository for “KernelSU Hosts”.
  3. Configure Adaway to export. Set Adaway to export the list to a file.
  4. Manual Update (if needed). If the module does not auto-update, use a script or a file manager to copy the exported hosts file to the module directory.

By decoupling the ad-blocking enforcement (the Module) from the list generation (the App), you create a stable system that respects KernelSU’s security model.

Conclusion

KernelSU represents the evolution of Android root management, prioritizing security and kernel integrity. While this shifts away from the “everything is root” philosophy of older systems, it does not mean we lose access to essential utilities like Adaway. By understanding the interaction between user-space apps and kernel-space modules, we can adapt our methods.

The failure of Adaway is not a bug in the app, but a difference in environment. We have demonstrated that with the correct Hosts Module and a slight adjustment in how we view the app’s role, you can enjoy a completely ad-free experience on KernelSU.

We advise users to always download modules from trusted sources. The Magisk Module Repository remains a vital resource for these tools. Ensure you keep your KernelSU manager updated, as the team frequently patches bugs related to module mounting and superuser requests. With these steps, your device will be clean, fast, and ad-free.

Explore More
Redirecting in 20 seconds...