Magisk modules: why none loaded on our panels, and the busybox Magisk needs first
Status (2026-11-19): working on the S1. Magisk v31.1 loads no module, and runs no post-fs-data.d or
service.d script, until /data/adb/magisk/busybox exists. The Magisk app puts it there; our installers never ran
that step, so no panel we installed loaded a module. The S1's boot image now carries Magisk's own busybox and copies
it in place at post-fs-data, just before Magisk checks. Verified on the dev S1 on 2026-11-19: busybox in place on
the first boot, and #430's module mounted. The fresh-install path (no /data/adb yet) is read, not run.
Device: Aqara S1 Plus, Android 10, our Magisk v31.1 boot patch (Kiln or patch-boot-magisk.sh). Tools: Magisk
v31.1 source (tag v31.1, commit 0972f67), AOSP android10-release.
Question
The S1's setup hotspot name (#430) ships as a Magisk module: a static overlay under
/data/adb/modules/s1kiosk_hotspot_name/system/product/overlay/. On the dev S1 the module sat in place, but
after a restart nothing was mounted. Why, and what's the smallest fix that reaches every panel?
What we tried
-
The panel run of #430 (2026-11-19, verified by the root on the dev S1). The module was in place, root-owned, 755/644. After the restart
/product/overlay/S1HotspotNamewas missing andcmd overlay listwas empty./cache/magisk.log:** post-fs-data mode running * Initializing Magisk environment * Magisk environment incomplete, abort/data/adb/magisk/was empty. -
Why Magisk stops (read, Magisk v31.1).
setup_magisk_envmakes/data/adb/magisk,/data/adb/modules,post-fs-data.dandservice.d, then returns false when/data/adb/magisk/busyboxis missing (native/src/core/bootstages.rs:76-79).post_fs_datalogs "Magisk environment incomplete, abort" and returns before the safe-mode check, thepost-fs-data.dscripts andhandle_modules()(:132-134). It returns "safe mode" for that boot, solate_start(theservice.dscripts) is skipped too (:203-218).- Only
busyboxis checked. Magisk copies it into its tmpfs and installs its applets there (:81-95).magisk32andmagiskpolicyare optional (:97-113). - The Magisk app fills
/data/adb/magisk:fix_env(scripts/app_functions.sh:49-57) with the filesMagiskInstaller.kt:124-150takes out of its own APK,lib/<abi>/libbusybox.soamong them. Kiln andpatch-boot-magisk.shpatch the boot image from the same APK but never run that step, and our panels have no Magisk app. /data/adbitself:post_fs_dataaborts with "/data/adbis not present" when it's missing (:120-123), andboot_completemakes it (:181-185). AOSP's Android 10init.rcdoesn't make it.
-
Where our own step can run (read, Magisk v31.1 and AOSP
android10-release).magiskinitappends everyoverlay.d/*.rctoinit.rc, then its ownon post-fs-datawithexec ... magisk --post-fs-dataafter them (native/src/init/rootdir.cpp:96-104,rootdir.rs:20-22).- init queues the actions of one trigger in the order it parsed them (
init/action_manager.cpp:56-66), so anon post-fs-datain our overlay runs before Magisk's. copyis an init built-in (init/builtins.cpp:925-935). It reads withO_NOFOLLOWand refuses a group- or world-writable source (init/util.cpp:159-174), and writes the target0600(:200-210).mkdirgives a new top-level/datadirectory an encryption policy on a file-encrypted device, and boots into recovery with a wipe prompt if that fails (init/builtins.cpp:345-349). Second-level paths are skipped (system/extraslibfscrypt/fscrypt_init_extensions.cpp:72-78). Somkdir /data/adb/magiskis safe andmkdir /data/adbfrom init is not.- The boot animation already runs at
on post-fs-datafrom our overlay (s1kiosk_branding.rc), with${MAGISKTMP}paths. That is verified on the S1 since #63.
-
The busybox itself (read).
lib/armeabi-v7a/libbusybox.soin the official Magisk v31.1 APK (sha25689cefac0…c6e7, the one the installers pin): 1,282,828 bytes, sha2567edf6024…1b6d. BusyBox 1.36.1, built by Magisk from topjohnwu/ndk-busybox (branchandroid-ndk-1.36.1) and fetched by Magisk's build asbusybox-1.36.1.1.zip(app/build-logic/src/main/java/Setup.kt:103-106). GPL-2.0. -
Room in
boot(verified on the host, 2026-11-19, Kiln'spatchBootover the stock 4.5.80boot).Ramdisk (gzip) Left in the 32 MiB bootLeft before the DTB's load address Before (Glass Tile animation of #63, 8.72 MB) 10,799,772 2,050,048 With Magisk's busybox 11,628,162 1,222,656 5,149,054 (ramdisk at 0x43000000, DTB at0x44000000)Both installers refuse an image that no longer fits, so it can't go over silently.
-
The two installers agree (verified on the host, 2026-11-19).
patch-boot-magisk.shfrom the branch over the eight golden inputs ofkiln/packages/bootpatch/test/bootpatch.test.ts(stock, re-patched, no animation, no key, preinit onmetadata), then Kiln'spatchBootover the same inputs: byte-identical in all eight. The goldens hold Aqara's boot images and live outside the repo. -
The panel run (2026-11-19, verified by the root on the dev S1, boot image from this change through
fel-install.sh,DEV_SU_HOURS). The panel'sbootwas already our Magisk dev image.- First boot:
/data/adb/magisk/busyboxroot,-rwxr-xr-x, 1,282,828 bytes, sha2567edf6024…1b6d.magisk.loggoes fromInitializing Magisk environmenton to the module scripts: noenvironment incomplete. - Second restart (33 s): busybox written again at that boot (its mtime), Magisk's bootloop count
0. With #430's module in place:s1kiosk_hotspot_name: loading module files, the overlay mounted under/product/overlay/S1HotspotName/and enabled. - The radio stayed
ok thread_routerthroughout. - On the host, the patch first stopped at
cat: magisk.cfg: Permission deniedwith that already-patched input (see "How to reproduce"); fixed in the script since.
- First boot:
Result
| Option | Verdict |
|---|---|
(a) The installer fills /data/adb/magisk over adb |
No: a fresh panel has no root after the flash. Kiln's adb session is uid 2000 |
(b) The boot image carries busybox and copies it at post-fs-data |
Built. s1kiosk_magiskenv.rc (in the frame loader's image, the first lines of glassworks.rc's post-fs-data, #549): mkdir /data/adb/magisk, copy ${MAGISKTMP}/magisk-busybox, chmod 0755. init built-ins only, so nothing can hang the boot. Rewritten every boot, so a torn write heals on the next one |
| (c) Mount the overlay ourselves, no Magisk modules | Also a boot-image change, plus a hand-rolled magic mount before the package manager scans /product/overlay |
| (d) The app downloads Magisk and the helper extracts busybox | A runtime download of a GPL binary, and more code. Only worth it if field panels must get it without a Kiln visit |
What changes on a panel with (b):
- Which boot loads modules. Right after an install
/data/adbdoesn't exist yet: on the first boot the rc'smkdirandcopyfail (init logs them, nothing else happens) and Magisk aborts as before. Magisk makes/data/adbatboot_complete. From the second boot on, busybox is in place before Magisk checks, and modules load. On a panel that already ran (any panel installed before this), the first boot with the new image is enough. - Magisk's bootloop guard turns on. With its setup complete,
post_fs_datacounts boots that don't reachboot_complete. At the third in a row it writes adisablemark into every module (bootstages.rs:137-155,native/src/core/module.rs:668-679). On the S1 that means a panel that lost power twice during boot comes up with the hotspot name module off. #430's helper keeps adisablemark and saysandroid: the module is disabled in Magisk; turning the name off and on again (Manage) makes the module fresh. The volume-down key also triggers safe mode (native/src/core/utils.cpp:87-111); the S1 has no volume keys. - Scripts.
/data/adb/post-fs-data.dandservice.dnow run. Ours are empty. - Undo. Flashing the stock
bootback (Kiln's restore,fel-install.sh --undo) removes Magisk; the file in/data/adb/magiskstays and nothing reads it. With this boot image, removing/data/adb/magisk/busyboxdoes nothing: init copies it back on the next boot, before Magisk checks. To stop one module, leave adisablefile in its directory (what Magisk's app does), or, for #430's, set the name back to Android. To stop every module, go back to a boot image withouts1kiosk_magiskenv.rc(or, with the loader, without those lines inglassworks.rc), then remove the file. Each takes effect at the next boot: Magisk mounts modules once, atpost-fs-data, and what it mounted stays until a restart. So restart after the change (after removing the file, in the last case: the boot that brought the old image back may still have loaded them).
How to reproduce
- Read-only, on a panel with root:
cat /cache/magisk.log(look forenvironment incomplete),ls -la /data/adb/magisk. - The probe without a new boot image (root only, writes
/data/adb/magisk): copy the APK'slib/armeabi-v7a/libbusybox.soto/data/adb/magisk/busybox(root, 0755) and restart. Undo: remove it and restart. The S1's panel plan for #430 and this change has the exact steps. - The goldens (host only): run
patch-boot-magisk.shover the eight inputs (as~/src/aqara-panel-backups/web-golden/gen.shdoes), copyglassworks.rc(before the loader,s1kiosk_magiskenv.rc) intofixtures/overlay/, thenS1_WEB_GOLDEN=<dir> npx vitest runinkiln/packages/bootpatch. Through OrbStack on macOS, root in the container can't read the mode-000magisk.cfgthe CLI extracts (the host's permissions win). The CLI now makes it readable before printing it (chmod u+r); before that it stopped there. The image bytes don't depend on it. The root's run of 2026-11-19 hit the same stop with an already-patched input.
Open questions
- The fresh-install path on a real panel (no
/data/adbon the first boot): read only. The combined panel plan's step 4b simulates it by moving/data/adbaside for two boots. - Is the S1's
/datafile-encrypted (ro.crypto.type)? The rc avoids the one path where it matters, so the answer doesn't change the fix. - With the frame loader (#549), the three lines move into
glassworks.rc'son post-fs-datablock, before the loader'sexec.