Skip to main content

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


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

The Bad (Cons)

5. Typical repack workflow (practical steps)

  1. Inspect original module:
    • unzip module.zip to a working folder.
    • review module.prop, scripts, and payload.
  2. 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).
  3. 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.
  4. 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.
  5. 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).
  6. Iterate until stable; when confident, publish with clear change notes and compatibility tags.