ADB, Fastboot, and Magisk Module Repack: A Practical Guide
Flashing custom modules and repackaging Magisk modules can extend Android devices in powerful ways — from enabling systemless mods to adding features that survive OTA updates. This post walks through the purpose, risks, required tools, and a clear, step-by-step workflow to repack a Magisk module and install it via ADB/Fastboot. Intended for experienced tinkers; proceed at your own risk.
Prerequisites
- Unlocked bootloader
- Magisk (24+) installed
- USB debugging enabled
- ADB & fastboot on PC
- Basic zip/unzip tools
What is it?
A "repack" usually refers to a modified Magisk module that packages the ADB and Fastboot binaries for Android. This allows a user to open a terminal emulator (or use an automated script) on the phone itself to flash partitions (like boot.img or recovery.img) without needing a computer.
Part 6: Common Errors and Troubleshooting
C) Repack into flashable ZIP
Method 1 – Manual ZIP (no custom install logic):
cd my_module
zip -r ../my_module_repacked.zip * -x "META-INF*"
# But better: use Magisk template META-INF
Method 2 – Using official Magisk template (recommended):
git clone https://github.com/topjohnwu/magisk-module-template
cp -r magisk-module-template/* my_module/
# copy your system/ and module.prop
cd my_module
zip -r ../my_module_repacked.zip .
Method A – Direct ADB install (no bootloop risk)
adb push my_module_repacked.zip /sdcard/
adb shell
su
magisk --install-module /sdcard/my_module_repacked.zip
reboot
Background: what each piece does
- ADB: Android Debug Bridge — communicates with a device for shell access, file transfer, and sideloading.
- Fastboot: low-level protocol for flashing partitions (boot, recovery, system) while device is in bootloader mode.
- Magisk module: a zipped package that Magisk can install systemlessly by patching the boot image and overlaying files at runtime.
- Repack: extracting an existing Magisk module zip, modifying contents (scripts, binaries, files), and re-zipping so Magisk installs the new version.
The Bad (Cons)
- The "Bootloop" Paradox: This is the fatal flaw. To use the module, you must be booted into Android. If you flash a bad
boot.imgor kernel that causes a bootloop, you cannot access the module to fix it. You will still need a PC to recover the device via fastboot mode. - Security Risks: Repacked binaries are often modified or compiled by third parties. Unlike the official Google Platform Tools, you cannot always verify the integrity of the binaries inside the module. A malicious repack could theoretically execute unintended commands.
- Compatibility Issues: Android versions and partition structures change (e.g., the move to A/B partitions and
fastbootd). Older repacks often fail to recognize modern partition layouts, leading to "remote: partition doesn't exist" errors. - User Error Potential: Typing fastboot commands on a touchscreen keyboard in a terminal emulator is clumsy. A typo in a partition name or path could soft-brick the device much faster than using a full keyboard on a PC.
5. Typical repack workflow (practical steps)
- Inspect original module:
- unzip module.zip to a working folder.
- review module.prop, scripts, and payload.
- Make changes:
- update module.prop (change version, id if creating a fork).
- modify scripts (install.sh) cautiously: avoid destructive operations or absolute paths that break devices.
- replace/add binaries for the target architecture; ensure correct file permissions (chmod 0755 for executables).
- include device-specific tweaks (detect device via ro.product.device or ro.build.hardware).
- Repack:
- compress preserving structure: zip -r ../module-repack.zip * (run from inside folder).
- ensure no extra parent directories; the root of the zip must contain module.prop and the module tree.
- Test locally:
- Push module to device: adb push module-repack.zip /data/local/tmp/
- Install via Magisk Manager (manual install from storage) or using adb shell to unzip into /data/adb/modules_tmp then reboot. Alternatively, use magisk --install-modules command if available.
- Validate behavior:
- Reboot and verify module activation in Magisk Manager.
- Check logs: magisk.log, logcat, and module-specific logs (service.d output).
- Confirm functionality (e.g., binaries load, SELinux permissive patches not applied unintentionally).
- Iterate until stable; when confident, publish with clear change notes and compatibility tags.