Why spend money on a Raspberry Pi 4 when you have an old Snapdragon phone sitting in a drawer doing absolutely nothing?
Look at the hardware inside a Realme 8 Pro (RMX3081, Snapdragon 720G / SM7125):
- CPU: 2× Cortex-A76 @ 2.32 GHz + 6× Cortex-A55 @ 1.80 GHz (~2× the CPU speed of a Raspberry Pi 4!)
- RAM: 6 GB LPDDR4X
- Storage: 128 GB UFS 2.1 (miles faster than a Pi microSD card waiting to corrupt itself)
- Power: ~2–4W idle, plus a built-in 4,500 mAh battery UPS and Wi-Fi 5
On paper, it’s a dream little ARM64 Linux server. In reality, most people trying to run Linux on Android hit a wall: Termux proot-distro is painfully slow because of ptrace syscall emulation, and stock Android kernels strip out everything native Docker needs — namespaces, overlayfs, WireGuard, BTRFS, CIFS/NFS, eBPF, PSI — while CONFIG_ANDROID_PARANOID_NETWORK actively blocks normal Linux users from opening sockets.
This is the story of how I compiled an unrestricted Linux 4.14 kernel on my MacBook Air, got threatened by Realme’s bootloader to “contact customer service”, survived four bootloops, ran real dockerd natively alongside Android 13 (no proot, no VM), and caught Realme’s own power HAL secretly throttling my CPU by 480 MHz.
[ Custom 4.14.180-perf+ Linux Kernel ]
(WireGuard, BBR, eBPF, BTRFS, PSI, KSM)
│ │
┌────────────┘ └────────────┐
▼ ▼
Android 13 Core Docker Engine (overlay2)
├─ Wi-Fi (wlan.ko) ├─ Private cgroup v1 (unshare -m)
├─ Charging & Thermals ├─ Persistent Debian 12 (arm64)
├─ Magisk 30.7 + service.d └─ Native ARM64 Containers
└─ Stripped Realme Bloat (More to come...)
// Table of Contents
- Fixing
fastboot boot‘unknown command’ & AVB2 on Realme - Compiling a Custom Qualcomm Snapdragon (SM7125) Linux Kernel
- Cooking the Unrestricted Kernel
- Fixing
runcBPF_CGROUP_DEVICEFailed on Android 13 & Kernel 4.14 - Running Native Debian 12 on Android, Debloating & Unlocking CPU Throttling
- Frequently Asked Questions
Fixing fastboot boot ‘unknown command’ & AVB2 on Realme
I wanted to do this the safe, civilized way: compile a test kernel and run fastboot boot test-boot.img so it only lives in RAM and a reboot restores stock.
Realme had other plans.
Sending 'boot.img' (31680 KB) OKAY [ 0.735s]
Booting FAILED (remote: 'unknown command')
Even with an unlocked bootloader (unlocked:yes), Realme literally compiled the boot command out of their abl UEFI bootloader. RAM-only testing was off the table — flashing boot directly (with SHA256-verified backups of stock boot.img and dtbo.img ready via hardware Vol Down + Power fastboot) was the only way forward.
So I flashed my first custom image and rebooted. The phone immediately greeted me with a giant warning:
“The current image (boot/recovery) have been destroyed and can not boot. Please flash the correct image or contact customer service to fix it.”
(Yeah, I’m sure Realme customer service would love to help me debug my custom Docker kernel).
The culprit? Realme’s abl enforces the Android Verified Boot (AVBf / VBMETA) footer at the end of the 64 MiB boot partition even when unlocked. Instead of fighting custom Python packers and generated test keys, I extracted the official magiskboot binary from Magisk and used magiskboot unpack / magiskboot repack — preserving the original Magisk 30.7 ramdisk, stock DTB, and OEM VBMETA block byte-for-byte.
Compiling a Custom Qualcomm Snapdragon (SM7125) Linux Kernel
If you’ve ever touched OEM Android kernel sources, you know the pain.
- Realme’s official Android 13 source (
realme_8pro-AndroidT-kernel-source): Shipped with 63 broken symlinks pointing to a private../../../vendor/oplus/kernel/...directory that doesn’t exist in the repo (touchscreen, optical fingerprint,sched_assist). Dead on arrival. - LineageOS
4.14.357(android_kernel_realme_sm7125): Compiled cleanly inside a case-sensitiveext4Docker volume (so macOS APFS wouldn’t choke onxt_DSCP.cvsxt_dscp.c), but refused to boot against stock Realme UI 4.0vendor/dtbo— kicking me straight into TWRP beforeramoopscould even initialize. - The winner (
perilouspike/android_kernel_realme_nasha): A4.14.181tree synced withRMX3081_11_F.03where the broken Oplus symlinks were already fixed in-tree.
The One-Digit Bootanimation Hang
Starting directly from my phone’s live /proc/config.gz, the 4.14.181-perf+ baseline finally booted past the Realme logo, started init, brought up adbd, and played the boot animation… forever.
Checking logcat and /proc/modules over ADB made me laugh out loud:
/proc/moduleswas completely empty.- Every stock module in
/vendor/lib/modules/(qca_cld3_wlan.ko,audio_adsp_loader.ko,audio_apr.ko,audio_q6.ko) expectsvermagic=4.14.180-perf+. - Because
4.14.181was off by one single digit,audio_adsp_loadernever loaded, ADSP never came up, andSystemServerspun in an infinite loop waiting onSoundTriggerHal.
Two surgical edits solved it:
- Set
SUBLEVEL = 180inMakefilesoUTS_RELEASEmatched4.14.180-perf+byte-for-byte. - Disabled
CONFIG_MODULE_SIG_FORCEand patchedcheck_version()inkernel/module.cto warn instead of rejecting minor symbol CRC differences.
The next flash booted straight to the lockscreen. Wi-Fi, audio, camera, optical fingerprint, and Magisk 30.7 all worked natively on the first try.
Cooking the Unrestricted Kernel
With a rock-solid 4.14.180-perf+ baseline safely backed up, I wired in wireguard-linux-compat (fixing a KERNEL_VERSION(4, 14, 181) ipv6_dst_lookup_flow macro check in compat.h) and turned on everything a real Linux box needs:
- Docker & Containers:
PID_NS,USER_NS,IPC_NS,UTS_NS,NET_NS,CGROUP_PIDS,CGROUP_DEVICE,OVERLAY_FS,BINFMT_MISC,DEVTMPFS, andCONFIG_ANDROID_PARANOID_NETWORKexplicitly disabled. - Networking, VPN & eBPF: In-kernel
CONFIG_WIREGUARD=y(with ARM64 ChaCha20/Poly1305 asm),TCP_CONG_BBRas default,NF_TABLES,BPF_SYSCALL,BPF_JIT_ALWAYS_ON,CGROUP_BPF,TPROXY,IP_SET,MACVLAN,VXLAN. - Filesystems & ZRAM:
BTRFS,SQUASHFS,FUSE,CIFS,NFS(v3/v4),NBD, andZSTDfor ZRAM. - USB Gadgets & Hardware:
USB_CONFIGFS_MASS_STORAGE,NCM,RNDIS,ECM,ACM,F_HID,UVC, USB serial (CH341,CP210X,FTDI_SIO), andMAC80211. - Memory & Telemetry:
KSMandPSI(withcgroup_disable=pressurestripped out of theboot.imgcmdline).
Fixing runc BPF_CGROUP_DEVICE Failed on Android 13 & Kernel 4.14
Installing docker (dockerd 24.0.6, containerd 1.6.21, runc 1.6.0) from Termux’s root-repo brought up dockerd with overlay2 immediately — until I tried to launch alpine:
runc create failed: bpf_prog_query(BPF_CGROUP_DEVICE) failed: bpf: invalid argument
Android mounts cgroup2 on /sys/fs/cgroup, so runc assumes it can use eBPF device cgroups (BPF_CGROUP_DEVICE) — a feature that didn’t exist until Linux 4.15.
Unmounting Android’s /sys/fs/cgroup would break Android’s own process management. Instead, I launched dockerd inside a private mount namespace (unshare -m):
unshare -m /system/bin/sh -c '
mount -t tmpfs -o mode=755 tmpfs /sys/fs/cgroup
mkdir -p /sys/fs/cgroup/devices /sys/fs/cgroup/pids
mount -t cgroup -o devices cgroup /sys/fs/cgroup/devices
mount -t cgroup -o pids cgroup /sys/fs/cgroup/pids
exec dockerd --iptables=false --ip-masq=false
'
Android keeps its untouched cgroup2 view, while dockerd and runc get clean cgroup v1 devices + pids controllers. One second later, docker run --rm --net=host alpine printed Alpine Linux on 4.14.180-perf+.
Running Native Debian 12 on Android, Debloating & Unlocking Qualcomm CPU Throttling
With native Docker working, I spun up a persistent debian:bookworm (arm64) container (--privileged --net=host, /dev/tun:/dev/net/tun, wireguard-tools, iptables, openssh-server) so I can SSH straight into real Debian from my Mac.
Then I audited RAM and storage:
- Disabled 32 unused Realme/HeyTap telemetry and Google background apps (
pm disable-user --user 0), freeing hundreds of megabytes of RAM while keeping Wi-Fi, camera, and Settings intact. - Found 25.75 GB of deleted files silently rotting inside Realme File Manager’s hidden
/data/media/0/.FileManagerRecyclerfolder, plus an old1.6 GBchroot-distroinstall — freeing 84 GB of fast UFS storage.
The 480 MHz Secret Cap
When I checked cpufreq, I noticed something annoying: my two Kryo 465 Gold cores (policy6) are rated for 2.32 GHz (2323200), yet scaling_max_freq was stuck at 1.84 GHz (1843200). Even after uncapping it, Realme’s perf HAL (vendor.qti.hardware.perf@2.2-service) kept quietly re-clamping it back down during runtime.
The fix in /data/adb/service.d/99-appliance.sh (which runs after sys.boot_completed=1, switches 6 GB ZRAM to zstd, sets wifi_sleep_policy=2, grabs a kernel wakelock, exempts Termux from Doze, starts dockerd + debian, and sets oom_score_adj=-1000 so Android’s OOM killer can never touch Docker):
echo "6:2323200 7:2323200" > /sys/module/msm_performance/parameters/cpu_max_freq
echo 2323200 > /sys/devices/system/cpu/cpufreq/policy6/scaling_max_freq
chmod 444 /sys/module/msm_performance/parameters/cpu_max_freq /sys/devices/system/cpu/cpufreq/policy6/scaling_max_freq
Under a 60-second 8-core sha256sum stress test inside Debian, CPU temps peaked at 47.8°C (31.2°C battery) with zero throttling and 2.32 GHz holding rock solid.
Frequently Asked Questions
Why run native Docker on Android instead of Termux proot-distro?
proot-distro intercepts every Linux syscall in userspace via ptrace, which tanks I/O performance and cannot run real Docker containers, iptables, or in-kernel WireGuard. Compiling a custom kernel with namespaces, overlayfs, and cgroups gives you bare-metal ARM64 Linux speed with zero emulation overhead.
Can you run native Docker on any Qualcomm Snapdragon Android phone?
Yes — any rooted Snapdragon device with an unlocked bootloader and compilable kernel source can do this. Devices on Linux 4.14–4.19 alongside Android 12/13 just need the unshare -m private cgroup v1 namespace trick above, while newer 5.4+ GKI kernels support cgroup v2 directly.
Does Android still work normally while running Docker and Debian?
Completely. Because dockerd runs in its own mount namespace and the custom kernel matches the stock vermagic for /vendor/lib/modules/, Wi-Fi, camera, charging, Magisk, and regular Android apps all work normally alongside your containers.
Conclusion
Is compiling a custom Linux 4.14 kernel in Docker on a MacBook Air just to run containers on a 5-year-old Realme phone overkill? Absolutely.
Was it a headache? Only the first four bootloops.
Does it crush a Raspberry Pi 4 while sipping ~3W with built-in battery backup and 84 GB of UFS storage? 100%.
Now that the phone runs ARM64 Docker containers natively with in-kernel WireGuard, BBR, eBPF, and Debian 12 auto-booting on startup, this opens the door to a lot more self-hosted experiments. Plenty more to come.
All configs, surgical kernel patches, the Docker build setup, and the sanitized 99-appliance.sh boot script are open-source on GitHub: adinetech/realme-8-pro-docker-kernel.
More From the Homelab Rabbit Hole
Want to see the rest of my self-hosted infrastructure and off-grid solar setup? Check out State of My Homelab 2026 → and The Off-Grid Edge (7.1kWh LiFePO4 Solar) →