Magisk Documentation

The Magic Mask for Android

62,178 stars Kotlin Kotlin 1 file ยท ~29,966 tokens
RAW Doc

File: docs/app_changes.md

Magisk Manager Changelog

v8.0.7

  • Fix sepolicy rule migration when upgrading

v8.0.6

  • Minor UI changes
  • Update internal scripts

v8.0.5

  • Fix sepolicy rule copying

v8.0.4

  • A lot of stability changes and minor bug fixes
  • Collect device properties, app logcat, and Magisk logs when saving logs in the logs menu

v8.0.3

  • Switch to the new Magisk Module Repo setup in preparation to allow 3rd party repos
  • Add tapjacking protection on Superuser request dialog
  • Stability changes and bug fixes

v8.0.2

  • Fix an issue with requesting permission on devices older than Android 10
  • Make more files download through CDN

v8.0.1

  • Fix vbmeta.img patching for Samsung AP.tar files. This fixes bootloops on devices like Galaxy S10 after flashing updated AP files.
  • Properly truncate existing files before writing to prevent corrupted files
  • Prevent a possible UI loop when device ran into very low memory
  • Switch to use JSDelivr CDN for several files

v8.0.0

  • 100% full app rewrite! Will highlight functional changes below.
  • Add detailed device info in home screen to assist user installation
  • Support Magisk v21.0 communication protocol
  • Support patching modern Samsung AP.tar

v7.5.1

  • Fix toggling app components in MagiskHide screen
  • Update translations

v7.5.0

  • Support new MagiskSU communication method (ContentProvider)
  • Fix several issues with hidden stub APK
  • Support using BiometricPrompt (face unlock)

v7.4.0

  • Hide Magisk Manager with stub APKs on Android 9.0+
  • Allow customizing app name when hiding Magisk Manager
  • Generate random keys to sign the hidden Magisk Manager to prevent signature detections
  • Fix fingerprint UI infinite loop

v7.3.5

  • Sort installed modules by name
  • Better pre-5.0 support
  • Fix potential issues when patching tar files

v7.3.4

  • App is now fully written in Kotlin!
  • New downloading system
  • Add new "Recovery Mode" to Advanced Settings

v7.3.0/1/2

  • HUGE code base modernization, thanks @diareuse!
  • More sweet changes coming in the future!
  • Reboot device using proper API (no more abrupt reboot)
  • New floating button in Magisk logs to go to bottom

v7.2.0

  • Huge UI overhaul
  • More sweet changes coming in the future!

v7.1.2

  • Support patching Samsung AP firmware
  • Much better module downloading mechanism

v7.1.1

  • Fix a bug that causes some modules using new format not showing up

v7.1.0

  • Support the new module format
  • Support per-application component granularity MagiskHide targets (only on v19+)
  • Ask for fingerprint before deleting rules if enabled
  • Fix the bug that causes repackaging to lose settings
  • Several UI fixes

v7.0.0

  • Major UI redesign!
  • Render Markdown natively (no more buggy WebView!)
  • Support down to Android 4.1 (native Magisk only support Android 4.2 though)
  • Significantly improve Magisk log display performance
  • Fix post OTA scripts for A/B devices
  • Reduce memory usages when verifying and signing boot image
  • Drop support for Magisk lower than v18.0

v6.1.0

  • Introduce new downloading methods: no longer uses buggy system Download Manager
  • Introduce many new notifications for better user experience
  • Add support for Magisk v18.0
  • Change application name to "Manager" after hiding(repackaging) to prevent app name detection
  • Add built-in systemless hosts module (access in settings)
  • Auto launch the newly installed app after hiding(repackaging) and restoring Magisk Manager
  • Fix bug causing incomplete module.prop in modules to have improper UI

v6.0.1

  • Update to use new online module's organizing method
  • When fingerprint authentication is enabled, toggling root permissions in "Superuser" section now requires fingerprint beforehand
  • Fix crashes when entering MagiskHide section on some devices
  • Remove support to Magisk version lower than v15.0
  • Ask storage permissions before patching stock boot image
  • Update dark theme CardView color

v6.0.0

  • Update to latest AndroidX support library
  • Fix crashes when online repos contain incomplete metadata
  • Optimize BootSigner to use as little memory as possible, prevent OutOfMemoryError
  • Support new communication scheme between Magisk v17.2 and Magisk Manager
  • Enable excessive obfuscation to prevent APK analysis root detections (still not 100% obfuscated due to backwards compatibility with stable channel)

v5.9.0/v5.9.1

  • No more on boot notifications
  • Support new mechanism for installing to inactive slot for OTAs on A/B devices
  • Fix restore Magisk Manager settings on Android P
  • Verify existing file checksums to prevent unnecessary re-downloads
  • Update SNET extension to use new Google API, fix "Invalid Response" errors
  • Move fingerprint settings to magisk database to prevent the settings to be easily removed
  • Fingerprint settings are now guarded with fingerprint authentications before it can get changed
  • Prevent any files to be downloaded to /sdcard/MagiskManager

v5.8.3

  • Prevent invalid modules in the online repo crashing the app
  • Update Stable and Beta channel URLs

v5.8.1

  • Fix a bug that cause the root shell initializer not running in BusyBox environment

v5.8.0

  • Remain hidden when upgrading within repackaged Magisk Manager
  • New feature: support reconstructing a proper Magisk environment if error detected (e.g. after factory reset)
  • New uninstall method: download uninstaller and completely remove Magisk + Magisk Manager, following with a reboot
  • Hidden apps are now shown on the top of the list in MagiskHide fragment
  • Tons of under-the-hood bug fixes and improvements

v5.7.0

  • Add app shortcuts for Android 7.1+
  • Bump minimal module minMagisk requirement to 1500
  • Adjustments for new sepolicies on v16.4+
  • Fix crashes when refreshing the online repo

v5.6.4

  • Remove the blacklisted apps using SafetyNet (e.g. Pokemon GO)

v5.6.3

  • Fix repo loading UI logic

v5.6.2

  • Cleanup folders if installation failed
  • Add support for Android P

v5.6.1

  • Fix database crashes on F2FS with SQLite 3.21.0+
  • Optimize several settings options
  • Use native XML for settings migration

v5.6.0

  • Remove JNI requirement, Magisk Manager is now pure Java
  • Update the method of handling su database, may fix the issue that root requests won't save
  • Add the option to restore Magisk Manager after repackaging with random package name
  • Massive under-the-hood

v5.5.5

  • Fix crashes on Lollipop and some devices not following AOSP standards

v5.5.4

  • Fix dtbo on-boot detection, should follow configured dtbo patching behavior on Pixel 2 devices
  • Add fingerprint authentication for Superuser requests

v5.5.3

  • Update translations
  • Update internal scripts (in sync with Magisk)
  • Minor adjustments

v5.5.2

  • Support sorting online repos with last update
  • Fix issue that advanced installation settings won't stick
  • Prevent sudb crashing Magisk Manager

v5.5.1

  • Fix an issue in setting up superuser database, which causes some users to experience tons of root issues

v5.5.0

  • Fix dynamic resource loading, prevent crashes when checking SafetyNet
  • Update SignAPK to use very little RAM for supporting old devices
  • Support settings migration after hiding Magisk Manager
  • Add reboot menu in modules section
  • Add dark theme to superuser request dialogs
  • Properly handle new HIGHCOMP and add recommended KEEPVERITY and KEEPFORCEENCRYPT flags for installation
  • Support new paths for v14.6
  • Massive improvements in repackaging Magisk Manager

v5.4.3

  • Add flags to intent to prevent crashes
  • Update translations

v5.4.2

  • Support new paths and setup of v14.5
  • Support repackaging Magisk Manager for hiding (only works on v14.5+)
  • Support hardlinking global su database into app data
  • Support signing boot images (AVB 1.0)
  • Update app icon to adaptive icons
  • Remove app from MagiskHide list if uninstalled
  • Add support to save detailed logs when installing Magisk or modules
  • Fix download progress error if module is larger than 20MB
  • Changed the way how downloaded repos are processed, should be rock stable
  • Prevent crashes when database is corrupted - clear db instead
  • Fix saving wrong UID issue on multiuser mode
  • Add custom update channel support - you can now switch to your own update server!
  • Some UI adjustments and asynchronous UI performance improvements

v5.4.0

  • SafetyNet checks now require external code extension (for 100% FOSS)
  • Repo loading will now show real-time progress instead of blank screen
  • Show progress when downloading an online module
  • Allow secondary users to access superuser settings if allowed
  • Fix several places where external storage is needed but forgot to request
  • Fetching online repo info from sever is significantly faster thanks to multithreading
  • Pulling down Download page will now force a full refresh, thanks to the faster loading speed
  • Using new resetprop tool to properly detect MagiskHide status

v5.3.5

  • Fix error when MagiskManager folder doesn't exist
  • Offload many logic to scripts: script fixes will also be picked up in the app
  • Add installing Magisk to second slot on A/B partition devices
  • Support file based encryption: store necessary files into DE storage
  • Update uninstall method to self remove app and prompt user to manually reboot

v5.3.0

  • Add hide Magisk Manager feature - hide the app from detection
  • Add update channel settings - you can now receive beta updates through the app
  • Proper runtime permission implementation - request storage permission only when needed
  • Add boot image file patch feature - you can patch boot images without root!
  • Rewrite Magisk direct install method - merge with boot image file patch mode
  • Add feature to restore stock boot image - convenient for applying OTAs

v5.2.0

  • Fix force close which occurs when failure in flashing zips
  • Remove several external dependencies and rewrite a large portion of components
  • Improve MarkDown support: showing README.MD is much faster and will properly render Unicode characters (e.g. Chinese characters)
  • Add language settings: you can now switch to languages other than system default
  • Remove busybox included within APK; download through Internet if needed
  • Use Magisk internal busybox if detected
  • Busybox is added to the highest priority in PATH to create reliable shell environment
  • Always use global namespace for internal shell if possible

v5.1.1

  • Fix Magisk Manager hanging when reading files with no end newline
  • Massive rewrite AsyncTasks to prevent potential memory leak
  • Fix some minor issues with notifications
  • Improve update notification and popup behavior
  • Update internal uninstaller script

v5.1.0

  • Introduce a new flash log activity, so you know what is actually happening, just like flashing in custom recoveries!
  • Rewritten Java native shall interface: merged root shell and normal shell
  • Cleaned up implementation of repo recyclerview and adapters

v5.0.6

  • Fix crash when installing modules downloading from repos

v5.0.5

  • Fix update notifications on Android O
  • Fix crash when trying to install Magisk Manager update
  • Update translations

v5.0.4

  • Fix bug in su timeout

v5.0.3

  • Fix FC on boot on Android O
  • Adapt to Android O broadcast limitations: re-authenticate app when update is disabled on Android O

v5.0.2

  • Rewrite zip signing part, zips downloaded from repo will be properly signed and adjusted for custom recoveries

v5.0.1

  • Add namespace mode options
  • Fix a bug in Manager OTA system

v5.0.0

  • Support the new Magisk unified binary
  • Properly handle application install / uninstall root management issues
  • Add multiuser mode support
  • Add application upgrade re-authentication feature
  • Add basic integrity check for SafetyNet
  • Merged install fragment and status fragment into Magisk fragment
  • Fix theme switching glitch
  • Update translations

v4.3.3

  • Re-build APK with stable build tools

v4.3.2

  • Improve usage of Github API to support unlimited amount of online repos
  • Update translations (thanks to all contributors!!)

v4.3.1

  • Update proper Magisk busybox detection, will not be confused by busybox installed by default in custom roms

v4.3.0

  • Add Core Only Mode option
  • Fix crashes when selecting release note on Samsung devices
  • Hide modules using template lower than version 3

v4.2.7

  • Update translations
  • Update uninstall scripts

v4.2.6

  • Samsung crashes finally fixed (confirmed!)
  • Add settings to disable update notifications
  • Adjust Dark theme colors
  • Refined download section, now support download only when root is not detected
  • Fix crashes in boot image selection

v4.2

  • Change Repo cache to database
  • Dark theme refined
  • Alert Dialog buttons now properly aligned
  • Support very large online modules' zip processing
  • You can now download online modules without installing
  • Add notifications when new Magisk version is available
  • Removed changelog, donation link, support link in download cards
  • Read and display README.md for online modules

v4.1

  • Change MagiskHide startup
  • Reduce static data (= less memory leaks/issues)
  • Translation updates

v4.0

  • Whole new Superuser section for MagiskSU management!
  • Add Superuser tab in Logs section
  • Add lots of Superuser settings
  • Handle MagiskSU requests, logging, notifications
  • Controls MagiskHide initialization
  • Add disable button
  • Add uninstall button
  • Tons of improvements, not practical to list all :)

v3.1

  • Fix online repo inaccessible issue
  • Fix repo list card expanding issues
  • Change SafetyNet check to manually triggered
  • Update translations
  • Tons of bug fixes preventing potential crashes

v3.0

  • Now on Play Store
  • Add Status Section, you can check Safety Net, root status, and Magisk status in one place
  • Add Install Section, you can manually choose the boot image location and advanced options

v2.5

  • Add Magisk Hide section, you can now add/remove apps from Magisk Hide list
  • Support custom Magisk Version names, any string is now accepted (for custom builds)
  • Fixed modules and repos not sorted by name

v2.1

  • Add Magisk Hide settings
  • Add search bar in "Downloads Sections"
  • Fix crashes when no root is available
  • Fix trash can icon not updated when removing module
  • Prevent crash when Magisk Version is set incorrectly

v2.0

  • Massive refactor
  • Material Design
  • Module Management
  • Download Section
  • And much more....

v1.0

  • Initial release

File: docs/boot.md

Android Booting Shenanigans

Terminologies

  • rootdir: the root directory (/). All files/folders/filesystems are stored in or mounted under rootdir. On Android, the filesystem may be either rootfs or the system partition.
  • initramfs: a section in Android's boot image that the Linux kernel will use as rootfs. People also use the term ramdisk interchangeably
  • recovery and boot partition: these 2 are actually very similar: both are Android boot images containing ramdisk and Linux kernel (plus some other stuff). The only difference is that booting boot partition will bring us to Android, while recovery has a minimalist self contained Linux environment for repairing and upgrading the device.
  • SAR: System-as-root. That is, the device uses system as rootdir instead of rootfs
  • A/B, A-only: For devices supporting Seamless System Updates, it will have 2 slots of all read-only partitions; we call these A/B devices. To differentiate, non A/B devices will be called A-only
  • 2SI: Two Stage Init. The way Android 10+ boots. More info later.

Here are a few parameters to more precisely define a device's Android version:

  • LV: Launch Version. The Android version the device is launched with. That is, the Android version pre-installed when the device first hit the market.
  • RV: Running Version. The Android version the device is currently running on.

We will use Android API level to represent LV and RV. The mapping between API level and Android versions can be seen in this table. For example: Pixel XL is released with Android 7.1, and is running Android 10, these parameters will be (LV = 25, RV = 29)

Boot Methods

Android booting can be roughly categorized into 3 major different methods. We provide a general rule of thumb to determine which method your device is most likely using, with exceptions listed separately.

Method Initial rootdir Final rootdir
A rootfs rootfs
B system system
C rootfs system
  • Method A - Legacy ramdisk: This is how all Android devices used to boot (good old days). The kernel uses initramfs as rootdir, and exec /init to boot.
    • Devices that does not fall in any of Method B and C's criteria
  • Method B - Legacy SAR: This method was first seen on Pixel 1. The kernel directly mounts the system partition as rootdir and exec /init to boot.
    • Devices with (LV = 28)
    • Google: Pixel 1 and 2. Pixel 3 and 3a when (RV = 28).
    • OnePlus: 6 - 7
    • Maybe some (LV < 29) Android Go devices?
  • Method C - 2SI ramdisk SAR: This method was first seen on Pixel 3 Android 10 developer preview. The kernel uses initramfs as rootdir and exec /init in rootfs. This init is responsible to mount the system partition and use it as the new rootdir, then finally exec /system/bin/init to boot.
    • Devices with (LV >= 29)
    • Devices with (LV < 28, RV >= 29), excluding those that were already using Method B
    • Google: Pixel 3 and 3a with (RV >= 29)

Discussion

From documents online, Google's definition of SAR only considers how the kernel boots the device (Initial rootdir in the table above), meaning that only devices using Method B is officially considered an SAR device from Google's standpoint.

However for Magisk, the real difference lies in what the device ends up using when fully booted (Final rootdir in the table above), meaning that as far as Magisk's concern, both Method B and C is a form of SAR, but just implemented differently. Every instance of SAR later mentioned in this document will refer to Magisk's definition unless specifically says otherwise.

The criteria for Method C is a little complicated, in layman's words: either your device is modern enough to launch with Android 10+, or you are running an Android 10+ custom ROM on a device that was using Method A.

  • Any Method A device running Android 10+ will automatically be using Method C
  • Method B devices are stuck with Method B, with the only exception being Pixel 3 and 3a, which Google retrofitted the device to adapt the new method.

SAR is a very important part of Project Treble as rootdir should be tied to the platform. This is also the reason why Method B and C comes with (LV >= ver) criterion as Google has enforced all OEMs to comply with updated requirements every year.

Some History

When Google released the first generation Pixel, it also introduced A/B (Seamless) System Updates. Due to storage size concerns, there are several differences compared to A-only, the most relevant one being the removal of recovery partition and the recovery ramdisk being merged into boot.

Let's go back in time when Google is first designing A/B. If using SAR (only Boot Method B exists at that time), the kernel doesn't need initramfs to boot Android (because rootdir is in system). This mean we can be smart and just stuff the recovery ramdisk (containing the minimalist Linux environment) into boot, remove recovery, and let the kernel pick whichever rootdir to use (ramdisk or system) based on information from the bootloader.

As time passed from Android 7.1 to Android 10, Google introduced Dynamic Partitions. This is bad news for SAR, because the Linux kernel cannot directly understand this new partition format, thus unable to directly mount system as rootdir. This is when they came up with Boot Method C: always boot into initramfs, and let userspace handle the rest of booting. This includes deciding whether to boot into Android or recovery, or as they officially call: USES_RECOVERY_AS_BOOT.

Some modern devices using A/B with 2SI also comes with recovery_a/_b partitions. This is officially supported with Google's standard. These devices will then only use the boot ramdisk to boot into Android as recovery is stored on a separate partition.

Piecing Things Together

With all the knowledge above, now we can categorize all Android devices into these different types:

Type Boot Method Partition 2SI Ramdisk in boot
I A A-only No boot ramdisk
II B A/B Any recovery ramdisk
III B A-only Any N/A
IV C Any Yes Hybrid ramdisk

These types are ordered chronologically by the time they were first available.

  • Type I: Good old legacy ramdisk boot
  • Type II: Legacy A/B devices. Pixel 1 is the first device of this type, being both the first A/B and SAR device
  • Type III: Late 2018 - 2019 devices that are A-only. The worst type of device to ever exist as far as Magisk is concerned.
  • Type IV: All devices using Boot Method C are Type IV. A/B Type IV ramdisk can boot into either Android or recovery based on info from bootloader; A-only Type IV ramdisk can only boot into Android.

Further details on Type III devices: Magisk is always installed in the ramdisk of a boot image. For all other device types, because their boot partition have ramdisk included, Magisk can be easily installed by patching boot image through the Magisk app or flash zip in custom recovery. However for Type III devices, they are limited to install Magisk into the recovery partition. Magisk will not function when booted normally; instead Type III device owners have to always reboot to recovery to maintain Magisk access.

Some Type III devices' bootloader will still accept and provide initramfs that was manually added to the boot image to the kernel (e.g. some Xiaomi phones), but many device don't (e.g. Samsung S10, Note 10). It solely depends on how the OEM implements its bootloader.


File: docs/build.md

Building and Development

Setup Environment

  • Supported platforms:
    • Linux x64
    • macOS x64 (Intel)
    • macOS arm64 (Apple Silicon)
    • Windows x64
  • Windows only: Enable developer mode. This is required because we need symbolic link support.
  • Install Python 3.8+:
    • On Unix, install python3 using your favorite package manager
    • On Windows, download and install the latest Python version on the official website.
      Make sure to select "Add Python to PATH" during installation.
    • (Optional on Windows): Run pip install colorama to install the colorama python package
  • Install Git:
    • On Unix, install git with your favorite package manager
    • On Windows, download the install the latest Git version on the official website.
      Make sure to "Enable symbolic links" during installation.
  • Install Android Studio and follow the instructions and go through the initial setup.
  • Set environment variable ANDROID_HOME to the Android SDK folder. This path can be found in Android Studio settings.
  • Setup JDK:
    • The recommended option is to set environment variable ANDROID_STUDIO to the path where your Android Studio is installed. The build script will automatically find and use the bundled JDK.
    • You can also setup JDK 17 yourself, but this guide will not cover the instructions.
  • Clone sources: git clone --recurse-submodules https://github.com/topjohnwu/Magisk.git
  • Run ./build.py ndk to let the script download and install NDK for you

Building

  • To build everything and create the final Magisk APK, run ./build.py all.
  • You can also build specific sub-components; call build.py to see your options.
    For each action, use -h to access help (e.g. ./build.py binary -h)
  • Configure the build by using config.prop. A sample config.prop.sample is provided.

IDE Support

  • Kotlin, Java, C++, and C code in the project should be supported in Android Studio out of the box. This repository can be directly opened with Android Studio as a project.
  • For Rust development, see the next section.
  • Before working on any native code, build all native code first with ./build.py binary, as some generated code is only created during the build process.

Developing Rust

First, install rustup, the official Rust toolchain manager. The Magisk NDK package ONDK (the one installed with ./build.py ndk) bundles a complete Rust toolchain, so building the Magisk project itself does not require any further configuration.

However, if you'd like to work on the Rust codebase, it'll be easier if you link ONDK's Rust toolchain in rustup and set it as default so several development tools and IDEs will work properly:

bash
# Link the ONDK toolchain with the name "magisk"
rustup toolchain link magisk "$ANDROID_HOME/ndk/magisk/toolchains/rust"
# Set magisk as default
rustup default magisk

If you plan to use VSCode, you can then install the rust-analyzer plugin and everything should be good to go. If you plan to use Jetbrain IDEs (e.g. Rustrover, or its Rust Plugin), we need some additional setup:

  • Install the official nightly toolchain and add some components. We won't actually use the nightly toolchain for anything other than tricking the IDE to cooperate; the magic happens in the wrapper we setup in the next step.
bash
rustup toolchain install nightly
# Add some components that is also included in ONDK
rustup +nightly component add rust-src clippy
  • Create a wrapper cargo bin directory to workaround rustup limitations
bash
# We choose ~/.cargo/wrapper here as an example (and a good recommendation)
# Pick any path you like, you just need to use this path in the next step
./build.py rustup ~/.cargo/wrapper
  • In Settings > Rust > Toolchain location, set this to the path of the wrapper directory we just created.
  • The IDE should now be fully functional, and you are able to enable rustfmt and use Clippy as the external linter.

Signing and Distribution

  • In release builds, the certificate of the key signing the Magisk APK will be used by Magisk's root daemon as a reference to reject and forcefully uninstall any non-matching Magisk apps to protect users from malicious and unverified Magisk APKs.
  • To do any development on Magisk itself, switch to an official debug build and reinstall Magisk to turn off the signature check.
  • To distribute your own Magisk builds signed with your own keys, set your signing configs in config.prop.
  • Check Google's Documentation for more details on generating your own key.

File: docs/changes.md

Magisk Changelog

v31.0 (2026.9.4)

  • [App] Complete UI overhaul with Jetpack Compose and Material 3, completely removing the legacy View and Fragment architecture
  • [App] Add new built-in terminal emulator with full TTY and ANSI support for module flashing and action scripts
  • [App] Support downloading and streaming boot image extraction directly from remote OTA URLs
  • [MagiskBoot] Support dynamic zImage payload sizes without requiring exact size padding during repack
  • [MagiskBoot] Update AVB hash descriptor image size to match unpacked image size
  • [MagiskBoot] Lower default compression preset for XZ and LZMA to reduce memory usage during repacking
  • [Zygisk] Support Android 17 (API 37)
  • [Zygisk] Support Meta Quest (Horizon OS) lazy partition zygotes
  • [MagiskPolicy] Fix identifier parsing for names containing hyphens
  • [resetprop] Add --compact (-c) flag to compact property storage areas
  • [MagiskInit] Properly prioritize charger mode detection before force_normal_boot
  • [DenyList] Add webview_zygote as an unmount target

v30.7 (2026.2.23)

  • [MagiskInit] Support Android 16 QPR2 sepolicy format
  • [MagiskInit] Support using klogdump partition as pre-init storage
  • [Zygisk] Support Android 16 QPR2 and higher
  • [Zygisk] Support Android XR and some Nubia devices
  • [MagiskSU] Do not drop capabilities by default, even when switching to non-root UIDs. Explicitly use the --drop-cap argument to drop capabilities.
  • [MagiskBoot] Better lzma format detection
  • [MagiskBoot] Fix various commandline argument parsing bugs

v30.6 (2025.12.1)

  • [MagiskInit] Revert a change that could result in bootloops

v30.5 (2025.12.1)

  • [General] Improve commandline argument parsing logic
  • [resetprop] Properly support Android versions with property overrides

v30.4 (2025.10.2)

  • [MagiskSU] Fix several implementation bugs

v30.3 (2025.9.29)

  • [General] Support installing Magisk into vendor_boot partition
  • [MagiskPolicy] Support new sepolicy binary format introduced in Android 16 QPR2
  • [Core] Migrate much more code into Rust
  • [MagiskSU] Fallback to older implementation when the kernel doesn't support zero userspace copy APIs

v30.2 (2025.8.6)

  • [Core] Fix an edge case breaking modules when overlayfs is involved
  • [Core] Fix module .replace functionality in certain situations
  • [resetprop] Reduce property modification traces

v30.1 (2025.7.3)

  • [Core] Fix bug in module mounting implementation
  • [MagiskSU] Add ability to restrict Linux capabilities even if running as root (uid=0)

v30.0 (2025.7.1)

  • [General] Various minor bug fixes
  • [Core] Migrate module implementation to Rust
  • [Core] Improve Magisk specific files injection logic
  • [MagiskBoot] Migrate compression code to Rust

v29.0 (2025.5.14)

  • [General] Massive internal refactoring and code migration
  • [App] Support downloading module zip files with XZ compression
  • [App] Disable app animations when system animations are disabled
  • [Core] Support systemlessly deleting files with modules using blank file nodes
  • [MagiskInit] Redesign sepolicy patching and injection logic
  • [MagiskSU] Better TTY/PTY support

v28.1 (2024.12.6)

  • [App] Fix stub APK download link
  • [App] Fix support for Android lower than 8.0
  • [General] Fix support for MTK Samsung devices
  • [MagiskInit] Fix a regression for 2SI devices
  • [MagiskPolicy] Fix a regression causing overlay.d replaced files to be not accessible

v28.0 (2024.10.10)

  • [General] Support 16k page size
  • [General] Add basic support for RISC-V (not built in releases)
  • [General] Use a minimal libc to build static executables (magiskinit and magiskboot) for smaller sizes
  • [Core] Remove unnecessary mirror for magic mount
  • [Core] Update boot image detection logic to support more devices
  • [MagiskInit] Rewrite 2SI logic for injecting magiskinit as init
  • [MagiskInit] Update preinit partition detection
  • [Zygisk] Update internal JNI hooking implementation
  • [MagiskPolicy] Preserve sepolicy config flag after patching
  • [MagiskPolicy] Optimize patching rules to reduce the amount of new rules being injected
  • [DenyList] Support enforcing denylist when Zygisk is disabled
  • [Resetprop] Improve implementation to workaround several property modification detections
  • [Resetprop] Update to properly work with property overlays
  • [App] Major internal code refactoring
  • [App] Support patching Samsung firmware with images larger than 8GiB
  • [App] Use user-initiated job instead of foreground services on Android 14
  • [App] Support Android 13+ built-in per-app language preferences
  • [App] Add action.sh support to allow modules to define an action triggered from UI
  • [MagiskBoot] Support spliting kernel images without decompression
  • [MagiskBoot] Properly support vendor boot images
  • [MagiskBoot] Disable Samsung PROCA from kernel image

v27.0 (2024.2.3)

  • [Zygisk] Introduce new code injection mechanism
  • [Zygisk] Support new signature introduced in U QPR2
  • [SEPolicy] Update libsepol to properly set some policy config bits
  • [MagiskBoot] Support compressing init so Magisk is installable on devices with small boot partitions
  • [ResetProp] Add new wait for property feature resetprop -w

v26.4 (2023.11.5)

  • [MagiskBoot] Don't pad zeros if signed boot image is larger
  • [MagiskPolicy] Fix genfscon and filename_trans
  • [MagiskPolicy] Fix bug in libsepol
  • [Zygisk] Fix and simplify file descriptor sanitization logic
  • [App] Prevent OOM when patching AP tarfiles
  • [App] Fix bug in device configuration detection
  • [Daemon] Fix certificate parsing of APKs
  • [General] Fix logging errors from C++ code being ignored

v26.3 (2023.9.4)

  • [General] Fix device information detection script
  • [General] Update BusyBox to 1.36.1
  • [General] Update toolchain that produces broken arm32 executables
  • [App] Fix root service unable to bind on OnePlus devices

v26.2 (2023.8.27)

  • [MagiskBoot] Support extracting boot image from payload.bin
  • [MagiskBoot] Support cpio files containing character files
  • [MagiskBoot] Support listing cpio content
  • [MagiskBoot] Directly handle AVB 1.0 signing and verification without going through Java implementation
  • [Daemon] Make daemon socket a fixed path in MAGISKTMP
  • [resetprop] Support printing property context
  • [resetprop] Support only printing persistent properties from storage
  • [resetprop] Properly support setting persistent properties bypassing property_service
  • [MagiskSU] Support -g and -G options
  • [MagiskSU] Support switching mount namespace to PID with -t
  • [MagiskPolicy] Fix patching extended permissions
  • [MagiskPolicy] Support more syntax for extended permissions
  • [MagiskPolicy] Support printing out the loaded sepolicy rules
  • [App] Support patching boot image from ROM zips
  • [App] Properly preserve boot.img when patching Samsung firmware with init_boot.img

v26.1 (2023.4.11)

  • [App] Fix crashing when revoking root permissions
  • [MagiskInit] Always prefer ext4 partitions over f2fs when selecting the pre-init partition
  • [General] Restore module files' context/owner/group from mirror. This is a regression introduced in v26.0

v26.0 (2023.4.5)

  • [General] Bump minimum supported Android version to Android 6.0
  • [General] New magic mount backend. It supports loading modules into system with overlayfs files injected
  • [Zygisk] Release new API version 4
  • [Zygisk] Prevent crashing daemon in error
  • [Zygisk] Rewrite zygote code injection with new loader library approach
  • [Zygisk] Rewrite code unloading implementation
  • [MagiskBoot] Support amonet microloader devices
  • [MagiskBoot] Always use lz4_legacy compression on v4 boot images. This fixes boot image patching issues on Android U preview.
  • [MagiskInit] Support replacing existing *.rc files in overlay.d
  • [MagiskInit] Rewrite sepolicy.rules mounting and loading implementation
  • [App] Make stub patching 100% offline
  • [App] Support patching init_boot.img for Samsung ODIN firmware
  • [MagiskPolicy] Fix minor bug in command line argument parsing
  • [MagiskPolicy] Update rules to support Android U

v25.2 (2022.7.20)

  • [MagiskInit] Fix a potential issue when stub cpio is used
  • [MagiskInit] Fix reboot to recovery when stub cpio is used
  • [MagiskInit] Fix sepolicy.rules symlink for rootfs devices
  • [General] Better data encryption detection
  • [General] Move the whole logging infrastructure into Rust

v25.1 (2022.6.19)

  • [MagiskBoot] Fix ramdisk backup being incorrectly skipped
  • [MagiskBoot] Add new feature to detect unsupported dtb and abort during installation
  • [Zygisk] Change binary hijack paths
  • [App] Fix incorrect recovery mode detection and installation
  • [MagiskInit] Fix config not properly exported in legacy SAR devices
  • [General] Enforce the Magisk app to always match or be newer than magiskd

v25.0 (2022.6.7)

  • [MagiskInit] Update 2SI implementation, significantly increase device compatibility (e.g. Sony Xperia devices)
  • [MagiskInit] Introduce new sepolicy injection mechanism
  • [MagiskInit] Support Oculus Go
  • [MagiskInit] Support Android 13 GKIs (Pixel 6)
  • [MagiskBoot] Fix vbmeta extraction implementation
  • [App] Fix stub app on older Android versions
  • [App] [MagiskSU] Properly support apps using sharedUserId
  • [MagiskSU] Fix a possible crash in magiskd
  • [MagiskSU] Prune unused UIDs as soon as system_server restarts to prevent UID reuse attacks
  • [MagiskSU] Verify and enforce the installed Magisk app's certificate to match the distributor's signature
  • [MagiskSU] [Zygisk] Proper package management and detection
  • [Zygisk] Fix function hooking on devices running Android 12 with old kernels
  • [Zygisk] Fix Zygisk's self code unloading implementation
  • [DenyList] Fix DenyList on shared UID apps
  • [BusyBox] Add workaround for devices running old kernels

v24.3 (2022.3.10)

  • [General] Stop using getrandom syscall
  • [Zygisk] Update API to v3, adding new fields to AppSpecializeArgs
  • [App] Improve app repackaging installation workflow

v24.2 (2022.3.1)

  • [MagiskSU] Fix buffer overflow
  • [MagiskSU] Fix owner managed multiuser superuser settings
  • [MagiskSU] Fix command logging when using su -c <cmd>
  • [MagiskSU] Prevent su request indefinite blocking
  • [MagiskBoot] Support lz4_legacy archive with multiple magic
  • [MagiskBoot] Fix lz4_lg compression
  • [DenyList] Allow targeting processes running as system UID
  • [Zygisk] Workaround Samsung's "early zygote"
  • [Zygisk] Improved Zygisk loading mechanism
  • [Zygisk] Fix application UID tracking
  • [Zygisk] Fix improper umask being set in zygote
  • [App] Fix BusyBox execution test
  • [App] Improve stub loading mechanism
  • [App] Major app upgrade flow improvements
  • [General] Improve commandline error handling and messaging

v24.1 (2022.1.28)

  • [App] Stability improvements

v24.0 (2022.1.26)

  • [General] MagiskHide is removed from Magisk
  • [General] Support Android 12
  • [General] Support devices that do not support 32-bit and only runs 64-bit code
  • [General] Update BusyBox to 1.34.1
  • [Zygisk] Introduce new feature: Zygisk
  • [Zygisk] Introduce DenyList feature to revert Magisk features in user selected processes
  • [MagiskBoot] Support patching 32-bit kernel zImages
  • [MagiskBoot] Support boot image header v4
  • [MagiskBoot] Support patching out skip_initramfs from dtb bootargs
  • [MagiskBoot] Add new env variable PATCHVBMETAFLAG to configure whether vbmeta flags should be patched
  • [MagiskInit] Support loading fstab from /system/etc (required for Pixel 6)
  • [MagiskInit] Support /proc/bootconfig for loading boot configurations
  • [MagiskInit] Better support for some Meizu devices
  • [MagiskInit] Better support for some OnePlus/Oppo/Realme devices
  • [MagiskInit] Support init.real on some Sony devices
  • [MagiskInit] Skip loading Magisk when detecting DSU
  • [MagiskPolicy] Load *_compat_cil_file from system_ext
  • [MagiskSU] Use isolated devpts if the kernel supports it
  • [MagiskSU] Fix root shell if isolated mount namespace is set
  • [resetprop] Deleted properties are now wiped from memory instead of just unlinking
  • [App] Build a single APK for all ABIs
  • [App] Switch to use standard bottom navigation bar
  • [App] Downloading modules from the centralized Magisk-Modules-Repo is removed
  • [App] Support user configuration of boot image vbmeta patching
  • [App] Restore the ability to install Magisk on the other slot on some A/B devices
  • [App] Allow modules to specify an update URL for in-app update + install

v23.0 (2021.5.12)

  • [App] Update snet extension. This fixes SafetyNet API errors.
  • [App] Fix a bug in the stub app that causes APK installation to fail
  • [App] Hide annoying errors in logs when hidden as stub
  • [App] Fix issues when patching ODIN tar files when the app is hidden
  • [General] Remove all pre Android 5.0 support
  • [General] Update BusyBox to use proper libc
  • [General] Fix C++ undefined behaviors
  • [General] Several sepolicy.rule copy/installation fixes
  • [MagiskPolicy] Remove unnecessary sepolicy rules
  • [MagiskHide] Update package and process name validation logic
  • [MagiskHide] Some changes that prevents zygote deadlock

v22.1 (2021.4.9)

  • [App] Prevent multiple installation sessions running in parallel
  • [App] Prevent OutOfMemory crashes when checking boot signature on PXA boot images
  • [General] Proper cgroup migration implementation
  • [General] Rewrite log writer from scratch, should resolve any crashes and deadlocks
  • [General] Many scripts updates fixing regressions
  • [MagiskHide] Prevent possible deadlock when signal arrives
  • [MagiskHide] Partial match process names if necessary
  • [MagiskBoot] Preserve and patch AVB 2.0 structures/headers in boot images
  • [MagiskBoot] Properly strip out data encryption flags
  • [MagiskBoot] Prevent possible integer overflow
  • [MagiskInit] Fix sepolicy.rule mounting strategy
  • [resetprop] Always delete existing ro. props before updating. This will fix bootloops that could be caused by modifying device fingerprint properties.

v22.0 (2021.2.23)

  • [General] Magisk and Magisk Manager is now merged into the same package!
  • [App] The term "Magisk Manager" is no longer used elsewhere. We refer it as the Magisk app.
  • [App] Support hiding the Magisk app with advanced technique (stub APK loading) on Android 5.0+ (it used to be 9.0+)
  • [App] Disallow re-packaging the Magisk app on devices lower than Android 5.0
  • [App] Detect and warn about multiple invalid states and provide instructions on how to resolve it
  • [MagiskHide] Fix a bug when stopping MagiskHide does not take effect
  • [MagiskBoot] Fix bug when unpacking lz4_lg compressed boot images
  • [MagiskInit] Support Galaxy S21 series
  • [MagiskSU] Fix incorrect APEX paths that caused libsqlite.so fail to load

v21.4 (2021.1.17)

  • [MagiskSU] Fix su -c behavior that broke many root apps
  • [General] Properly handle read/write over sockets (the broken pipe issue)

v21.3 (2021.1.16)

  • [MagiskInit] Avoid mounting f2fs userdata as it may result in kernel crashes. This shall fix a lot of bootloops
  • [MagiskBoot] Fix a minor header checksum bug for DHTB header and ASUS blob image formats
  • [MagiskHide] Allowing hiding isolated processes if the mount namespace is separated

v21.2 (2020.12.28)

  • [MagiskInit] Detect 2SI after mounting system_root on legacy SAR devices
  • [General] Make sure post-fs-data scripts cannot block more than 35 seconds
  • [General] Fix the magisk --install-module command
  • [General] Trim Windows newline when reading files
  • [General] Directly log to file to prevent logcat weirdness
  • [MagiskBoot] Fix header dump/load for header v3 images

v21.1 (2020.11.13)

  • [MagiskBoot] Support boot header v3 (Pixel 5 and 4a 5G)
  • [MagiskBoot] Distinguish lz4_lg and lz4_legacy (Pixel 5 and 4a 5G)
  • [MagiskBoot] Support vendor boot images (for dev, not relevant for Magisk installation)
  • [MagiskInit] Support kernel cmdline androidboot.fstab_suffix
  • [MagiskInit] Support kernel initialized dm-verity on legacy SAR
  • [General] Significantly broaden sepolicy.rule compatibility
  • [General] Add Magisk binaries to PATH when executing boot scripts
  • [General] Update --remove-modules command implementation
  • [General] Make Magisk properly survive after factory reset on Android 11
  • [MagiskSU] Add APEX package com.android.i18n to LD_LIBRARY_PATH when linking libsqlite.so
  • [MagiskHide] Support hiding apps installed in secondary users (e.g. work profile)
  • [MagiskHide] Make zygote detection more robust

v21.0 (2020.10.3)

  • [General] Support Android 11 ๐ŸŽ‰
  • [General] Add Safe Mode detection. Disable all modules when the device is booting into Safe Mode.
  • [General] Increase post-fs-data mode timeout from 10 seconds to 40 seconds
  • [MagiskInit] Rewritten 2SI support from scratch
  • [MagiskInit] Support when no /sbin folder exists (Android 11)
  • [MagiskInit] Dump fstab from device-tree to rootfs and force init to use it for 2SI devices
  • [MagiskInit] Strip out AVB for 2SI as it may cause bootloop
  • [Modules] Rewritten module mounting logic from scratch
  • [MagiskSU] For Android 8.0+, a completely new policy setup is used. This reduces compromises in Android's sandbox, providing more policy isolation and better security for root users.
  • [MagiskSU] Isolated mount namespace will now first inherit from parent process, then isolate itself from the world
  • [MagiskSU] Update communication protocol with Magisk Manager to work with the hardened SELinux setup
  • [MagiskPolicy] Optimize match all rules. This will significantly reduce policy binary size and save memory and improve general kernel performance.
  • [MagiskPolicy] Support declaring new types and attributes
  • [MagiskPolicy] Make policy statement closer to stock *.te format. Please check updated documentation or magiskpolicy --help for more details.
  • [MagiskBoot] Support compressed extra blobs
  • [MagiskBoot] Pad boot images to original size with zeros
  • [MagiskHide] Manipulate additional vendor properties

v20.4 (2020.3.23)

  • [MagiskInit] Fix potential bootloop in A-only 2SI devices
  • [MagiskInit] Properly support Tegra partition naming
  • [General] Load libsqlite.so dynamically, which removes the need to use wrapper scripts on Android 10+
  • [General] Detect API level with a fallback method on some devices
  • [General] Workaround possible bug in x86 kernel readlinkat system call
  • [BusyBox] Enable SELinux features. Add chcon/runcon etc., and '-Z' option to many applets
  • [BusyBox] Introduce standalone mode. More details in release notes
  • [MagiskHide] Disable MagiskHide by default
  • [MagiskHide] Add more potential detectable system properties
  • [MagiskHide] Add workaround for Xiaomi devices bootloop when MagiskHide is enabled on cross region ROMs
  • [MagiskBoot] Support patching special Motorolla DTB format
  • [MagiskPolicy] Support 'genfscon' sepolicy rules
  • [Scripts] Support NAND based boot images (character nodes in /dev/block)
  • [Scripts] Better addon.d (both v1 and v2) support
  • [Scripts] Support Lineage Recovery for Android 10+

v20.3 (2020.1.10)

  • [MagiskBoot] Fix lz4_legacy decompression

v20.2 (2020.1.2)

  • [MagiskSU] Properly handle communication between daemon and application (root request prompt)
  • [MagiskInit] Fix logging in kmsg
  • [MagiskBoot] Support patching dtb/dtbo partition formats
  • [General] Support pre-init sepolicy patch in modules
  • [Scripts] Update magisk stock image backup format

v20.1 (2019.11.2)

  • [MagiskSU] Support component name agnostic communication (for stub APK)
  • [MagiskBoot] Set proper header_size in boot image headers (fix vbmeta error on Samsung devices)
  • [MagiskHide] Scan zygote multiple times
  • [MagiskInit] Support recovery images without /sbin/recovery binary. This will fix some A/B devices unable to boot to recovery after flashing Magisk
  • [General] Move acct to prevent daemon being killed
  • [General] Make sure "--remove-modules" will execute uninstall.sh after removal

v20.0 (2019.10.11)

  • [MagiskBoot] Support inject/modify mnt_point value in DTB fstab
  • [MagiskBoot] Support patching QCDT
  • [MagiskBoot] Support patching DTBH
  • [MagiskBoot] Support patching PXA-DT
  • [MagiskInit] [2SI] Support non A/B setup (Android 10)
  • [MagiskHide] Fix bug that reject process names with ":"
  • [MagicMount] Fix a bug that cause /product mirror not created

v19.4 (2019.9.19)

  • [MagiskInit] [SAR] Boot system-as-root devices with system mounted as /
  • [MagiskInit] [2SI] Support 2-stage-init for A/B devices (Pixel 3 Android 10)
  • [MagiskInit] [initramfs] Delay sbin overlay creation to post-fs-data
  • [MagiskInit] [SARCompat] Old system-as-root implementation is deprecated, no more future changes
  • [MagiskInit] Add overlay.d support for root directory overlay for new system-as-root implementation
  • [MagiskSU] Unblock all signals in root shells (fix bash on Android)
  • [MagicMount] Support replacing files in /product
  • [MagiskHide] Support Android 10's Zygote blastula pool
  • [MagiskHide] All random strings now also have random length
  • [MagiskBoot] Allow no recompression for ramdisk.cpio
  • [MagiskBoot] Support some weird Huawei boot images
  • [General] Add new --remove-modules command to remove modules without root in ADB shell
  • [General] Support Android 10 new APEX libraries (Project Mainline)

v19.3 (2019.6.5)

  • [MagiskHide] Hugely improve process monitor implementation, hopefully should no longer cause 100% CPU and daemon crashes
  • [MagiskInit] Wait for partitions to be ready for early mount, should fix bootloops on a handful of devices
  • [MagiskInit] Support EROFS used in EMUI 9.1
  • [MagiskSU] Properly implement mount namespace isolation
  • [MagiskBoot] Proper checksum calculation for header v2

v19.2 (2019.5.20)

  • [General] Fix uninstaller
  • [General] Fix bootloops on some devices with tmpfs mounting to /data
  • [MagiskInit] Add Kirin hi6250 support
  • [MagiskSU] Stop claiming device focus for su logging/notify if feasible.
    This fix issues with users locking Magisk Manager with app lock, and prevent
    video apps get messed up when an app is requesting root in the background.

v19.1 (2019.5.1)

  • [General] Support recovery based Magisk
  • [General] Support Android Q Beta 2
  • [MagiskInit] New sbin overlay setup process for better compatibility
  • [MagiskInit] Allow long pressing volume up to boot to recovery in recovery mode
  • [MagicMount] Use proper system_root mirror
  • [MagicMount] Use self created device nodes for mirrors
  • [MagicMount] Do not allow adding new files/folders in partition root folder (e.g. /system or /vendor)

v19.0 (2019.3.28)

  • [General] Remove usage of magisk.img
  • [General] Add 64 bit magisk binary for native 64 bit support
  • [General] Support A only system-as-root devices that released with Android 9.0
  • [General] Support non EXT4 system and vendor partitions
  • [MagiskHide] Use Zygote ptracing for monitoring new processes
  • [MagiskHide] Targets are now per-application component
  • [MagiskInit] Support Android Q (no logical partition support yet!)
  • [MagiskPolicy] Support Android Q new split sepolicy setup
  • [MagiskInit] Move sbin overlay creation from main daemon post-fs-data to early-init
  • [General] Service scripts now run in parallel
  • [MagiskInit] Directly inject magisk services to init.rc
  • [General] Use lzma2 compressed ramdisk in extreme conditions
  • [MagicMount] Clone attributes from original file if exists
  • [MagiskSU] Use ACTION_REBOOT intent to workaround some OEM broadcast restrictions
  • [General] Use skip_mount instead of auto_mount: from opt-in to opt-out

v18.1 (2019.2.4)

  • [General] Support EMUI 9.0
  • [General] Support Kirin 960 devices
  • [General] Support down to Android 4.2
  • [General] Major code base modernization under-the-hood

v18.0 (2018.12.8)

  • [General] Migrate all code base to C++
  • [General] Modify database natively instead of going through Magisk Manager
  • [General] Deprecate path /sbin/.core, please start using /sbin/.magisk
  • [General] Boot scripts are moved from <magisk_img>/.core/<stage>.d to /data/adb/<stage>.d
  • [General] Remove native systemless hosts (Magisk Manager is updated with a built-in systemless hosts module)
  • [General] Allow module post-fs-data.sh scripts to disable/remove modules
  • [MagiskHide] Use component names instead of process names as targets
  • [MagiskHide] Add procfs protection on SDK 24+ (Nougat)
  • [MagiskHide] Remove the folder /.backup to prevent detection
  • [MagiskHide] Hide list is now stored in database instead of raw textfile in images
  • [MagiskHide] Add "--status" option to CLI
  • [MagiskHide] Stop unmounting non-custom related mount points
  • [MagiskSU] Add FLAG_INCLUDE_STOPPED_PACKAGES in broadcasts to force wake Magisk Manager
  • [MagiskSU] Fix a bug causing SIGWINCH not properly detected
  • [MagiskPolicy] Support new av rules: type_change, type_member
  • [MagiskPolicy] Remove all AUDITDENY rules after patching sepolicy to log all denies for debugging
  • [MagiskBoot] Properly support extra_cmdline in boot headers
  • [MagiskBoot] Try to repair broken v1 boot image headers
  • [MagiskBoot] Add new CPIO command: "exists"

v17.3 (2018.10.20)

  • [MagiskBoot] Support boot image header v1 (Pixel 3)
  • [MagiskSU] No more linked lists for caching su_info
  • [MagiskSU] Parse command-lines in client side and send only options to daemon
  • [MagiskSU] Early ACK to prevent client freezes and early denies
  • [Daemon] Prevent bootloops in situations where /data is mounted twice
  • [Daemon] Prevent logcat failures when /system/bin is magic mounting, could cause MagiskHide to fail
  • [Scripts] Switch hexpatch to remove Samsung Defex to a more general pattern
  • [Scripts] Update data encryption detection for better custom recovery support

v17.2 (2018.9.21)

  • [ResetProp] Update to AOSP upstream to support serialized system properties
  • [MagiskInit] Randomize Magisk service names to prevent detection (e.g. FGO)
  • [MagiskSU] New communication scheme to communicate with Magisk Manager

v17.0/17.1 (2018.9.1)

  • [General] Bring back install to inactive slot for OTAs on A/B devices
  • [Script] Remove system based root in addon.d
  • [Script] Add proper addon.d-v2 for preserving Magisk on custom ROMs on A/B devices
  • [Script] Enable KEEPVERITY when the device is using system_root_image
  • [Script] Add hexpatch to remove Samsung defex in new Oreo kernels
  • [Daemon] Support non ext4 filesystems for mirrors (system/vendor)
  • [MagiskSU] Make pts sockets always run in dev_pts secontext, providing all terminal emulator root shell the same power as adb shells
  • [MagiskHide] Kill all processes with same UID of the target to workaround OOS embryo optimization
  • [MagiskInit] Move all sepolicy patches pre-init to prevent Pixel 2 (XL) boot service breakdown

v16.7 (2018.7.19)

  • [Scripts] Fix boot image patching errors on Android P (workaround the strengthened seccomp)
  • [MagiskHide] Support hardlink based ns proc mnt (old kernel support)
  • [Daemon] Fix permission of /dev/null after logcat commands, fix ADB on EMUI
  • [Daemon] Log fatal errors only on debug builds
  • [MagiskInit] Detect early mount partname from fstab in device tree

v16.6 (2018.7.8)

  • [General] Add wrapper script to overcome weird LD_XXX flags set in apps
  • [General] Prevent bootloop when flashing Magisk after full wipe on FBE devices
  • [Scripts] Support patching DTB placed in extra sections in boot images (Samsung S9/S9+)
  • [Scripts] Add support for addon.d-v2 (untested)
  • [Scripts] Fix custom recovery console output in addon.d
  • [Scripts] Fallback to parsing sysfs for detecting block devices
  • [Daemon] Check whether a valid Magisk Manager is installed on boot, if not, install stub APK embedded in magiskinit
  • [Daemon] Check whether Magisk Manager is repackaged (hidden), and prevent malware from hijacking com.topjohnwu.magisk
  • [Daemon] Introduce new daemon: magisklogd, a dedicated daemon to handle all logcat related monitoring
  • [Daemon] Replace old invincible mode with handshake between magiskd and magisklogd, one will respawn the other if disconnected
  • [Daemon] Support GSI adbd bind mounting
  • [MagiskInit] Support detecting block names in upper case (Samsung)
  • [MagiskBoot] Check DTB headers to prevent false detections within kernel binary
  • [MagiskHide] Compare mount namespace with PPID to make sure the namespace is actually separated, fix root loss
  • [MagiskSU] Simplify su_info caching system, should use less resources and computing power
  • [MagiskSU] Reduce the amount of broadcasting to Magisk Manager
  • [ImgTool] Separate all ext4 image related operations to a new applet called "imgtool"
  • [ImgTool] Use precise free space calculation methods
  • [ImgTool] Use our own set of loop devices hidden along side with sbin tmpfs overlay. This not only eliminates another possible detection method, but also fixes apps that mount OBB files as loop devices (huge thanks to dev of Pzizz for reporting this issue)

v16.4 (2018.4.29)

  • [Daemon] Directly check logcat command instead of detecting logd, should fix logging and MagiskHide on several Samsung devices
  • [Daemon] Fix startup Magisk Manager APK installation on Android P
  • [MagiskPolicy] Switch from AOSP u:r:su:s0 to u:r:magisk:s0 to prevent conflicts
  • [MagiskPolicy] Remove unnecessary sepolicy rules to reduce security penalty
  • [Daemon] Massive re-design /sbin tmpfs overlay and daemon start up
  • [MagiskInit] Remove magiskinit_daemon, the actual magisk daemon (magiskd) shall handle everything itself
  • [Daemon] Remove post-fs stage as it is very limited and also will not work on A/B devices; replaced with simple mount in post-fs-data, which will run ASAP even before the daemon is started
  • [General] Remove all 64-bit binaries as there is no point in using them; all binaries are now 32-bit only.
    Some weirdly implemented root apps might break (e.g. Tasker, already reported to the developer), but it is not my fault :)
  • [resetprop] Add Protobuf encode/decode to support manipulating persist properties on Android P
  • [MagiskHide] Include app sub-services as hiding targets. This might significantly increase the amount of apps that could be properly hidden

v16.3 (2018.3.28)

  • [General] Remove symlinks used for backwards compatibility
  • [MagiskBoot] Fix a small size calculation bug

v16.2 (2018.3.18)

  • [General] Force use system binaries in handling ext4 images (fix module installation on Android P)
  • [MagiskHide] Change property state to disable if logd is disabled

v16.1 (2018.3.11)

  • [MagiskBoot] Fix MTK boot image packaging
  • [MagiskBoot] Add more Nook/Acclaim headers support
  • [MagiskBoot] Support unpacking DTB with empty kernel image
  • [MagiskBoot] Update high compression mode detection logic
  • [Daemon] Support new mke2fs tool on Android P
  • [resetprop] Support Android P new property context files
  • [MagiskPolicy] Add new rules for Android P

v16.0 (2018.2.22)

  • [MagiskInit] Support non skip_initramfs devices with slot suffix (Huawei Treble)
  • [MagiskPolicy] Add rules for Magisk Manager
  • [Compiler] Workaround an NDK compiler bug that causes bootloops

v15.4 (2018.2.13)

  • [MagiskBoot] Support Samsung PXA, DHTB header images
  • [MagiskBoot] Support ASUS blob images
  • [MagiskBoot] Support Nook Green Loader images
  • [MagiskBoot] Support pure ramdisk images
  • [MagiskInit] Prevent OnePlus angela sepolicy_debug from loading
  • [MagiskInit] Obfuscate Magisk socket entry to prevent detection and security
  • [Daemon] Fix subfolders in /sbin shadowed by overlay
  • [Daemon] Obfuscate binary names to prevent naive detections
  • [Daemon] Check logd before force trying to start logcat in a loop

v15.3 (2018.1.12)

  • [Daemon] Fix the bug that only one script would be executed in post-fs-data.d/service.d
  • [Daemon] Add MS_SILENT flag when mounting, should fix some devices that cannot mount magisk.img
  • [MagiskBoot] Fix potential segmentation fault when patching ramdisk, should fix some installation failures

v15.2 (2018.1.1)

  • [MagiskBoot] Fix dtb verity patches, should fix dm-verity bootloops on newer devices placing fstabs in dtb
  • [MagiskPolicy] Add new rules for proper Samsung support, should fix MagiskHide
  • [MagiskInit] Support non skip_initramfs devices using split sepolicies (e.g. Zenfone 4 Oreo)
  • [Daemon] Use specific logcat buffers, some devices does not support all log buffers
  • [scripts] Update scripts to double check whether boot slot is available, some devices set a boot slot without A/B partitions

v15.1 (2017.12.29)

  • [MagiskBoot] Fix faulty code in ramdisk patches which causes bootloops in some config and fstab format combos

v15.0 (2017.12.26)

  • [Daemon] Fix the bug that Magisk cannot properly detect /data encryption state
  • [Daemon] Add merging /cache/magisk.img and /data/adb/magisk_merge.img support
  • [Daemon] Update to upstream libsepol to support cutting edge split policy custom ROM cil compilations

v14.6 (2017.12.22)

  • [General] Move all files into a safe location: /data/adb
  • [Daemon] New invincible implementation: use magiskinit_daemon to monitor sockets
  • [Daemon] Rewrite logcat monitor to be more efficient
  • [Daemon] Fix a bug where logcat monitor may spawn infinite logcat processes
  • [MagiskSU] Update su to work the same as proper Linux implementation:
    Initialize window size; all environment variables will be migrated (except HOME, SHELL, USER, LOGNAME, these will be set accordingly),
    "--preserve-environment" option will preserve all variables, including those four exceptions.
    Check the Linux su manpage for more info
  • [MagiskBoot] Massive refactor, rewrite all cpio operations and CLI
  • [MagiskInit][magiskboot] Support ramdisk high compression mode

v14.5 (1456) (2017.11.23)

  • [Magiskinit] Fix bootloop issues on several devices
  • [misc] Build binaries with NDK r10e, should get rid of the nasty linker warning when executing magisk

v14.5 (1455) (2017.11.23)

  • [Daemon] Moved internal path to /sbin/.core, new image mountpoint is /sbin/.core/img
  • [MagiskSU] Support switching package name, used when Magisk Manager is hidden
  • [MagiskHide] Add temporary /magisk removal
  • [MagiskHide] All changes above contributes to hiding from nasty apps like FGO and several banking apps
  • [Magiskinit] Use magiskinit for all devices (dynamic initramfs)
  • [Magiskinit] Fix Xiaomi A1 support
  • [Magiskinit] Add Pixel 2 (XL) support
  • [Magiskboot] Add support to remove avb-verity in dtbo.img
  • [Magiskboot] Fix typo in handling MTK boot image headers
  • [script] Along with updates in Magisk Manager, add support to sign boot images (AVB 1.0)
  • [script] Add dtbo.img backup and restore support
  • [misc] Many small adjustments to properly support old platforms like Android 5.0

v14.3 (2017.10.15)

  • [MagiskBoot] Fix Pixel C installation
  • [MagiskBoot] Handle special lz4_legacy format properly, should fix all LG devices
  • [Daemon] New universal logcat monitor is added, support plug-and-play to worker threads
  • [Daemon] Invincible mode: daemon will be restarted by init, everything should seamlessly through daemon restarts
  • [Daemon] Add new restorecon action, will go through and fix all Magisk files with selinux unlabeled to system_file context
  • [Daemon] Add brute-force image resizing mode, should prevent the notorious Samsung crappy resize2fs from affecting the result
  • [resetprop] Add new "-p" flag, used to toggle whether alter/access the actual persist storage for persist props

v14.2 (2017.9.28)

  • [MagicMount] Clone attributes to tmpfs mountpoint, should fix massive module breakage

v14.1 (2017.9.28)

  • [MagiskInit] Introduce a new init binary to support skip_initramfs devices (Pixel family)
  • [script] Fix typo in update-binary for x86 devices
  • [script] Fix stock boot image backup not moved to proper location
  • [script] Add functions to support A/B slot and skip_initramfs devices
  • [script] Detect Meizu boot blocks
  • [MagiskBoot] Add decompress zImage support
  • [MagiskBoot] Support extracting dtb appended to zImage block
  • [MagiskBoot] Support patching fstab within dtb
  • [Daemon/MagiskSU] Proper file based encryption support
  • [Daemon] Create core folders if not exist
  • [resetprop] Fix a bug which delete props won't remove persist props not in memory
  • [MagicMount] Remove usage of dummy folder, directly mount tmpfs and construct file structure skeleton in place

v14.0 (2017.9.6)

  • [script] Simplify installation scripts
  • [script] Fix a bug causing backing up and restoring stock boot images failure
  • [script] Installation and uninstallation will migrate old or broken stock boot image backups to proper format
  • [script] Fix an issue with selabel setting in util_functions.sh on Lollipop
  • [rc script] Enable logd in post-fs to start logging as early as possible
  • [MagiskHide] magisk.img mounted is no longer a requirement
    Devices with issues mounting magisk.img can now run in proper core-only mode
  • [MagiskBoot] Add native function to extract stock SHA1 from ramdisk
  • [b64xz] New tool to extract compressed and encoded binary dumps in shell script
  • [busybox] Add busybox to Magisk source, and embed multi-arch busybox binary into update-binary shell script
  • [busybox] Busybox is added into PATH for all boot scripts (post-fs-data.d, service.d, and all module scripts)
  • [MagiskSU] Fully fix multiuser issues
  • [Magic Mount] Fix a typo in cloning attributes
  • [Daemon] Fix the daemon crashing when boot scripts opens a subshell
  • [Daemon] Adjustments to prevent stock Samsung kernel restrictions on exec system calls for binaries started from /data
  • [Daemon] Workaround on Samsung device with weird fork behaviors

v13.3 (2017.7.18)

  • [MagiskHide] Update to bypass Google CTS (2017.7.17)
  • [resetprop] Properly support removing persist props
  • [uninstaller] Remove Magisk Manager and persist props

v13.2 (2017.7.14)

  • [magiskpolicy] Fix magiskpolicy segfault on old Android versions, should fix tons of older devices that couldn't use v13.1
  • [MagiskHide] Set proper selinux context while re-linking /sbin to hide Magisk, should potentially fix many issues
  • [MagiskBoot] Change lzma compression encoder flag from LZMA_CHECK_CRC64 to LZMA_CHECK_CRC32, kernel only supports latter
  • [General] Core-only mode now properly mounts systemless hosts and magiskhide

v13.1 (2017.7.11)

  • [General] Merge MagiskSU, magiskhide, resetprop, magiskpolicy into one binary
  • [General] Add Android O support (tested on DP3)
  • [General] Dynamic link libselinux.so, libsqlite.so from system to greatly reduce binary size
  • [General] Remove bundled busybox because it causes a lot of issues
  • [General] Unlock all block devices for read-write support instead of emmc only (just figured not all devices uses emmc lol)
  • [Scripts] Run all ext4 image operations through magisk binary in flash scripts
  • [Scripts] Updated scripts to use magisk native commands to increase compatibility
  • [Scripts] Add addon.d survival support
  • [Scripts] Introduce util_functions.sh, used as a global shell script function source for all kinds of installation
  • [MagiskBoot] Moved boot patch logic into magiskboot binary
  • [MagiskSU] Does not fork new process for each request, add new threads instead
  • [MagiskSU] Added multiuser support
  • [MagiskSU] Introduce new timeout queue mechanism, prevent performance hit with poorly written su apps
  • [MagiskSU] Multiple settings moved from prop detection to database
  • [MagiskSU] Add namespace mode option support
  • [MagiskSU] Add master-mount option
  • [resetprop] Updated to latest AOSP upstream, support props from 5.0 to Android O
  • [resetprop] Renamed all functions to prevent calling functions from external libc
  • [magiskpolicy] Updated libsepol from official SELinux repo
  • [magiskpolicy] Added xperm patching support (in order to make Android O work properly)
  • [magiskpolicy] Updated rules for Android O, and Liveboot support
  • [MagiskHide] Remove pseudo permissive mode, directly hide permissive status instead
  • [MagiskHide] Remove unreliable list file monitor, change to daemon request mode
  • [MagiskHide] MagiskHide is now enabled by default
  • [MagiskHide] Update unmount policies, passes CTS in SafetyNet!
  • [MagiskHide] Add more props for hiding
  • [MagiskHide] Remove background magiskhide daemon, spawn short life process for unmounting purpose
  • [Magic Mount] Ditched shell script based mounting, use proper C program to parse and mount files. Speed is SIGNIFICANTLY improved

v12.0 (2017.3.31)

  • [General] Move most binaries into magisk.img (Samsung cannot run su daemon in /data)
  • [General] Move sepolicy live patch to late_start service
    This shall fix the long boot times, especially on Samsung devices
  • [General] Add Samsung RKP hexpatch back, should now work on Samsung stock kernels
  • [General] Fix installation with SuperSU
  • [MagiskHide] Support other logcat am_proc_start patterns
  • [MagiskHide] Change /sys/fs/selinux/enforce(policy) permissions if required
    Samsung devices cannot switch selinux states, if running on permissive custom kernel, the users will stuck at permissive
    If this scenario is detected, change permissions to hide the permissive state, leads to SafetyNet passes
  • [MagiskHide] Add built in prop rules to fake KNOX status
    Samsung apps requiring KNOX status to be 0x0 should now work (Samsung Pay not tested)
  • [MagiskHide] Remove all ro.build props, since they cause more issues than they benefit...
  • [MagiskBoot] Add lz4 legacy format support (most linux kernel using lz4 for compression is using this)
  • [MagiskBoot] Fix MTK kernels with MTK headers

v11.5/11.6 (2017.3.21)

  • [Magic Mount] Fix mounting issues with devices that have separate /vendor partitions
  • [MagiskBoot] Whole new boot image patching tool, please check release note for more info
  • [magiskpolicy] Rename sepolicy-inject to magiskpolicy
  • [magiskpolicy] Update a rule to allow chcon everything properly
  • [MagiskHide] Prevent multirom crashes
  • [MagiskHide] Add patches for ro.debuggable, ro.secure, ro.build.type, ro.build.tags, ro.build.selinux
  • [MagiskHide] Change /sys/fs/selinux/enforce, /sys/fs/selinux/policy permissions for Samsung compatibility
  • [MagiskSU] Fix read-only partition mounting issues
  • [MagiskSU] Disable -cn option, the option will do nothing, preserved for compatibility

v11.1 (2017.2.6)

  • [sepolicy-inject] Add missing messages
  • [magiskhide] Start MagiskHide with scripts

v11.0 (2017.2.6)

  • [Magic Mount] Support replacing symlinks.
    Symlinks cannot be a target of a bind mounted, so they are treated the same as new files
  • [Magic Mount] Fix the issue when file/folder name contains spaces
  • [BusyBox] Updated to v1.26.2. Should fix the black screen issues of FlashFire
  • [resetprop] Support reading prop files that contains spaces in prop values
  • [MagiskSU] Adapt communication to Magisk Manager; stripped out unused data transfer
  • [MagiskSU] Implement SuperUser access option (Disable, APP only, ADB Only, APP & ADB)
    phh Superuser app has this option but the feature isn't implemented within the su binary
  • [MagiskSU] Fixed all issues with su -c "commands" (run commands with root)
    This feature is supposed to only allow one single option, but apparently adb shell su -c "command" doesn't work this way, and plenty of root apps don't follow the rule. The su binary will now consider everything after -c as a part of the command.
  • [MagiskSU] Removed legacy context hack for TiBack, what it currently does is slowing down the invocation
  • [MagiskSU] Preserve the current working directory after invoking su
    Previously phh superuser will change the path to /data/data after obtaining root shell. It will now stay in the same directory where you called su
  • [MagiskSU] Daemon now also runs in u:r:su:s0 context
  • [MagiskSU] Removed an unnecessary fork, reduce running processes and speed up the invocation
  • [MagiskSU] Add -cn option to the binary
    Not sure if this is still relevant, and also not sure if implemented correctly, but hey it's here
  • [sepolicy-inject] Complete re-write the command-line options, now nearly matches supolicy syntax
  • [sepolicy-inject] Support all matching mode for nearly every action (makes pseudo enforced possible)
  • [sepolicy-inject] Fixed an ancient bug that allocated memory isn't reset
  • [uninstaller] Now works as a independent script that can be executed at boot
    Fully support recovery with no /data access, Magisk uninstallation with Magisk Manager
  • [Addition] Busybox, MagiskHide, hosts settings can now be applied instantly; no reboots required
  • [Addition] Add post-fs-data.d and service.d
  • [Addition] Add option to disable Magisk (MagiskSU will still be started)

v10.2 (2017.1.2)

  • [Magic Mount] Remove apps/priv-app from whitelist, should fix all crashes
  • [phh] Fix binary out-of-date issue
  • [scripts] Fix root disappear issue when upgrading within Magisk Manager

v10 (2017.1.2)

  • [Magic Mount] Use a new way to mount system (vendor) mirrors
  • [Magic Mount] Use universal way to deal with /vendor, handle both separate partition or not
  • [Magic Mount] Adding anything to any place is now officially supported (including /system root and /vendor root)
  • [Magic Mount] Use symlinks for mirroring back if possible, reduce bind mounts for adding files
  • [Magisk Hide] Check init namespace, zygote namespace to prevent Magic Mount breakage (a.k.a root loss)
  • [Magisk Hide] Send SIGSTOP to pause target process ASAP to prevent crashing if unmounting too late
  • [Magisk Hide] Hiding should work under any conditions, including adding libs and /system root etc.
  • [phh] Root the device if no proper root detected
  • [phh] Move /sbin to /sbin_orig and link back, fix Samsung no-suid issue
  • [scripts] Improve SuperSU integration, now uses sukernel to patch ramdisk, support SuperSU built in ramdisk restore
  • [template] Add PROPFILE option to load system.prop

v9 (2016.11.14)

  • [API Change] Remove the interface for post-fs modules
  • [resetprop] New tool "resetprop" is added to Magisk to replace most post-fs modules' functionality
  • [resetprop] Magisk will now patch "ro.boot.verifiedbootstate", "ro.boot.flash.locked", "ro.boot.veritymode" to bypass Safety Net
  • [Magic Mount] Move dummy skeleton / mirror / mountinfo filesystem tree to tmpfs
  • [Magic Mount] Rewritten dummy cloning mechanism from scratch, will result in minimal bind mounts, minimal file traversal, eliminate all possible issues that might happen in extreme cases
  • [Magic Mount] Adding new items to /system/bin, /system/vendor, /system/lib(64) is properly supported (devices with separate vendor partition is not supported yet)
  • [Magisk Hide] Rewritten from scratch, now run in daemon mode, proper list monitoring, proper mount detection, and maybe more.....
  • [Boot Image] Add support for Motorola boot image dtb, it shall now unpack correctly
  • [Uninstaller] Add removal of SuperSU custom patch script

v8 (2016.10.19)

  • Add Magisk Hide to bypass SafetyNet
  • Improve SuperSU integration: no longer changes the SuperSU PATH
  • Support rc script entry points not located in init.rc

v7 (2016.10.04)

  • Fully open source
  • Remove supolicy dependency, use my own sepolicy-injection
  • Run everything in its own selinux domain, should fix all selinux issues
  • Add Note 7 stock kernel hex patches
  • Add support to install Magisk in Magisk Manager
  • Add support for image merging for module flashing in Magisk Manager
  • Add root helpers for SuperSU auto module-ize and auto upgrading legacy phh superuser
  • New paths to toggle busybox, and support all root solutions
  • Remove root management API; both SuperSU and phh has their own superior solutions

[v6 (2016.8.21)](https://xdaforums.com/t/magisk-general-support-discussion.3432382/post-68298121)

  • Fixed the algorithm for adding new files and dummy system
  • Updated the module template with a default permission, since people tend to forget them :)

[v5 (2016.8.20)](https://xdaforums.com/t/magisk-general-support-discussion.3432382/post-68274534)

  • Hotfix for older Android versions (detect policy before patching)
  • Update uninstaller to NOT uninstall Magisk Manager, since it cause problems

[v4 (2016.8.19)](https://xdaforums.com/t/magisk-general-support-discussion.3432382/post-68269300)

  • Important: Uninstall v1 - v3 Magisk before upgrading with the uninstaller in the OP!!
  • Massive Rewrite Magisk Interface API! All previous mods are NOT compatible! Please download the latest version of the mods you use (root/xposed)
  • Mods are now installed independently in their own subfolder. This paves the way for future Magisk Manager versions to manage mods, just like how Xposed Modules are handled
  • Support small boot partition devices (Huawei devices)
  • Use minimal sepolicy patch in boot image for smaller ramdisk size. Live patch policies after bootup
  • Include updated open source sepolicy injection tool (source code available), support nearly all SuperSU supolicy tool's functionality

[v3 (2016.8.11)](https://xdaforums.com/t/magisk-general-support-discussion.3432382/post-68146978)

  • Fix bootimg-extract for Exynos Samsung devices (thanks to @phhusson), should fix all Samsung device issues
  • Add supolicy back to patch sepolicy (stock Samsung do not accept permissive domain)
  • Update sepolicy-injection to patch su domain for Samsung devices to use phh's root
  • Update root disable method, using more aggressive approach
  • Use lazy unmount to unmount root from system, should fix some issues with custom roms
  • Use the highest possible compression rate for ramdisk, hope to fix some devices with no boot partition space
  • Detect boot partition space insufficient, will abort installer instead of breaking your device

[v2 (2016.8.9)](https://xdaforums.com/t/magisk-general-support-discussion.3432382/post-68108058)

  • Fix verity patch. It should now work on all devices (might fix some of the unable-to-boot issues)
  • All scripts will now run in selinux permissive mode for maximum compatibility (this will NOT turn your device to permissive)
  • Add Nougat Developer Preview 5 support
  • Add systemless host support for AdBlock Apps (enabled by default)
  • Add support for new root disable method
  • Remove sepolicy patches that uses SuperSU's supolicy tool; it is now using a minimal set of modifications
  • Removed Magisk Manager in Magisk patch, it is now included in Magisk phh's superuser only

[v1 (2016.8.3)](https://xdaforums.com/t/magisk-general-support-discussion.3432382/post-68034103)

  • Initial release

File: docs/details.md

Internal Details

File Structure

Paths in "Magisk tmpfs directory"

Magisk will mount a tmpfs directory to store some temporary data. For devices with the /sbin folder, it will be chosen as it will also act as an overlay to inject binaries into PATH. From Android 11 onwards, the /sbin folder might not exist, so Magisk will use /debug_ramdisk as the base folder.

text
# In order to get the current base folder Magisk is using,
# use the command `magisk --path`.
# Binaries like magisk, magiskinit, and all symlinks to
# applets are directly stored in this path. This means when
# this is /sbin, these binaries will be directly in PATH.
MAGISKTMP=$(magisk --path)

# Magisk internal stuffs
INTERNALDIR=$MAGISKTMP/.magisk

# /data/adb/modules will be bind mounted here.
# The original folder is not used due to nosuid mount flag.
$INTERNALDIR/modules

# The current Magisk installation config
$INTERNALDIR/config

# Partition mirrors
# Each directory in this path will be mounted with the
# partition of its directory name.
# e.g. system, system_ext, vendor, data ...
$INTERNALDIR/mirror

# Root directory patch files
# On system-as-root devices, / is not writable.
# All pre-init patched files are stored here and bind mounted.
$INTERNALDIR/rootdir

Paths in `/data`

Some binaries and files should be stored on non-volatile storages in /data. In order to prevent detection, everything has to be stored somewhere safe and undetectable in /data. The folder /data/adb was chosen because of the following advantages:

  • It is an existing folder on modern Android, so it cannot be used as an indication of the existence of Magisk.
  • The permission of the folder is by default 700, owner as root, so non-root processes are unable to enter, read, write the folder in any possible way.
  • The folder is labeled with secontext u:object_r:adb_data_file:s0, and very few processes have the permission to do any interaction with that secontext.
  • The folder is located in Device encrypted storage, so it is accessible as soon as data is properly mounted in FBE (File-Based Encryption) devices.
text
SECURE_DIR=/data/adb

# Folder storing general post-fs-data scripts
$SECURE_DIR/post-fs-data.d

# Folder storing general late_start service scripts
$SECURE_DIR/service.d

# Magisk modules
$SECURE_DIR/modules

# Magisk modules that are pending for upgrade
# Module files are not safe to be modified when mounted
# Modules installed through the Magisk app will be stored here
# and will be merged into $SECURE_DIR/modules in the next reboot
$SECURE_DIR/modules_update

# Database storing settings and root permissions
MAGISKDB=$SECURE_DIR/magisk.db

# All magisk related binaries, including busybox,
# scripts, and magisk binaries. Used in supporting
# module installation, addon.d, the Magisk app etc.
DATABIN=$SECURE_DIR/magisk

Magisk Booting Process

Pre-Init

magiskinit will replace init as the first program to run.

  • Early mount required partitions. On legacy system-as-root devices, we switch root to system; on 2SI devices, we patch the original init to redirect the 2nd stage init file to magiskinit and execute it to mount partitions for us.
  • Inject magisk services into init.rc
  • On devices using monolithic policy, load sepolicy from /sepolicy; otherwise we hijack nodes in selinuxfs with FIFO, set LD_PRELOAD to hook security_load_policy and assist hijacking on 2SI devices, and start a daemon to wait until init tries to load sepolicy.
  • Patch sepolicy rules. If we are using "hijack" method, load patched sepolicy into kernel, unblock init and exit daemon
  • Execute the original init to continue the boot process

post-fs-data

This triggers on post-fs-data when /data is decrypted and mounted. The daemon magiskd will be launched, post-fs-data scripts are executed, and module files are magic mounted.

late_start

Later in the booting process, the class late_start will be triggered, and Magisk "service" mode will be started. In this mode, service scripts are executed.

Resetprop

Usually, system properties are designed to only be updated by init and read-only to non-root processes. With root you can change properties by sending requests to property_service (hosted by init) using commands such as setprop, but changing read-only props (props that start with ro. like ro.build.product) and deleting properties are still prohibited.

resetprop is implemented by distilling out the source code related to system properties from AOSP and patched to allow direct modification to property area, or prop_area, bypassing the need to go through property_service. Since we are bypassing property_service, there are a few caveats:

  • on property:foo=bar actions registered in *.rc scripts will not be triggered if property changes does not go through property_service. The default set property behavior of resetprop matches setprop, which WILL trigger events (implemented by first deleting the property then set it via property_service). There is a flag -n to disable it if you need this special behavior.
  • persist properties (props that starts with persist., like persist.sys.usb.config) are stored in both prop_area and /data/property. By default, deleting props will NOT remove it from persistent storage, meaning the property will be restored after the next reboot; reading props will NOT read from persistent storage, as this is the behavior of getprop. With the flag -p, deleting props will remove the prop in BOTH prop_area and /data/property, and reading props will be read from BOTH prop_area and persistent storage.

SELinux Policies

Magisk will patch the stock sepolicy to make sure root and Magisk operations can be done in a safe and secure way. The new domain magisk is effectively permissive, which is what magiskd and all root shell will run in. magisk_file is a new file type that is setup to be allowed to be accessed by every domain (unrestricted file context).

Before Android 8.0, all allowed su client domains are allowed to directly connect to magiskd and establish connection with the daemon to get a remote root shell. Magisk also have to relax some ioctl operations so root shells can function properly.

After Android 8.0, to reduce relaxation of rules in Android's sandbox, a new SELinux model is deployed. The magisk binary is labelled with magisk_exec file type, and processes running as allowed su client domains executing the magisk binary (this includes the su command) will transit to magisk_client by using a type_transition rule. Rules strictly restrict that only magisk domain processes are allowed to attribute files to magisk_exec. Direct connection to sockets of magiskd are not allowed; the only way to access the daemon is through a magisk_client process. These changes allow us to keep the sandbox intact, and keep Magisk specific rules separated from the rest of the policies.

The full set of rules can be found in sepolicy/rules.cpp.


File: docs/faq.md

Frequently Asked Questions

Q: I installed a module and it bootlooped my device. Help!

If you have USB debugging enabled in developer options, connect your phone to the PC. If your device is detected (check by adb devices), enter ADB shell and run the command magisk --remove-modules. This will remove all your modules and automatically reboot the device.

If unfortunately you do not have USB debugging enabled you can boot using the Safe Mode key combo to cause Magisk to create an empty file named 'disable' in modules directories which disables modules when next booted with Magisk. Most modern Android devices support such a special key combo at boot to enter system Safe Mode as an emergency option, but please note that Magisk's key combo detection occurs earlier than system detection so the key combo timing indicated by many online guides may need to be altered to activate Magisk's Safe Mode. (It's possible to activate system Safe Mode but not Magisk Safe Mode and vice versa.)

The following details should ensure that modules are properly disabled:

  1. Many online guides for entering Safe Mode say 'When the animated logo appears, press and hold the volume down button until the system boots' or similar. This may actually be too late for Magisk detection however and result in activating system Safe Mode but modules are not disabled.
  2. By pressing the volume down button some seconds before the animation and releasing it as soon as the boot animation appears, Magisk's Safe Mode should be activated without activating system Safe Mode (thus avoiding disabling other device and app settings) and the device should then simply boot to normal system with modules disabled.
  3. By pressing the volume down button some seconds before the animation and holding it until the system boots, both Magisk's Safe Mode and system Safe Mode should be activated. Next, after booting back to normal system, modules will be disabled.

Q: Why is X app detecting root?

Magisk no longer handles root hiding. There are plenty of Magisk/Zygisk modules available that specifically provide these functionalities, please search around ๐Ÿ˜‰

Q: Magisk App shows Magisk Installed = N/A after an update but magisk su is still working.

If upgrading with App hidden (ie. you took the 'Hide the Magisk app' option), the stub app (for hiding Magisk) may remain while a full Magisk app is also installed. This creates a conflict and the full app fails to see or access root... Uninstalling and reinstalling the full app can fix this, but not if a hidden app (stub) still exists.

The solution is to check for a hidden stub app and remove it. It may not show up normally in your launcher homescreen any longer, but should be visible from general settings, Apps. The hidden app will be named 'Settings' (default) or whatever you named it during the hiding process. Note that it is possible to have multiple obfuscated apps present. Uninstall any iterations of the hidden app you find and try opening the full app again. If necessary, uninstall it and reinstall the full app matching the binaries installed. Typing magisk -c in a terminal emulator app will show the version and version code for Magisk binaries installed (despite Installed = N/A showing).

Additionally, if a 'second space', eg. Workspace, Parallel Space etc, or another sandboxed environment, eg. a Multiple User additional profile, Island app or similar, is set up, check that no iterations of Magisk (either hidden or full apps) are running within these environments.

Q: After I take the 'Hide the Magisk app' option the app icon is broken.

When hiding the Magisk app, it will install a "stub" APK that has nothing in it. The only functionality this stub app has is to download the full Magisk app APK data into its internal storage and dynamically load it. Due to the fact that the stub APK is literally empty, it does not contain the image resource for the app icon.

When you open the hidden Magisk app, it will offer you the option to create a shortcut in the homescreen (which has both the correct app name and icon) for your convenience. You can also manually ask the app to create the icon in app settings.

Q: How to use Magisk in the emulator?

With the emulator running and accessible via ADB, run ./build.py emulator to temporarily install Magisk on to the emulator. The patch is not persistent, meaning Magisk will be lost after a reboot, so re-execute the script to emulate a reboot if required.

The script is only tested on the official Android Virtual Device (AVD) shipped alongside Android Studio; other emulators may work, but the emulator must have SELinux enabled.


File: docs/guides.md

Developer Guides

BusyBox

Magisk ships with a feature complete BusyBox binary (including full SELinux support). The executable is located at /data/adb/magisk/busybox. Magisk's BusyBox supports runtime toggle-able "ASH Standalone Shell Mode". What this standalone mode means is that when running in the ash shell of BusyBox, every single command will directly use the applet within BusyBox, regardless of what is set as PATH. For example, commands like ls, rm, chmod will NOT use what is in PATH (in the case of Android by default it will be /system/bin/ls, /system/bin/rm, and /system/bin/chmod respectively), but will instead directly call internal BusyBox applets. This makes sure that scripts always run in a predictable environment and always have the full suite of commands no matter which Android version it is running on. To force a command not to use BusyBox, you have to call the executable with full paths.

Every single shell script running in the context of Magisk will be executed in BusyBox's ash shell with standalone mode enabled. For what is relevant to 3rd party developers, this includes all boot scripts and module installation scripts.

For those who want to use this "Standalone Mode" feature outside of Magisk, there are 2 ways to enable it:

  1. Set environment variable ASH_STANDALONE to 1Example: ASH_STANDALONE=1 /data/adb/magisk/busybox sh <script>
  2. Toggle with command-line options:/data/adb/magisk/busybox sh -o standalone <script>

To make sure all subsequent sh shell executed also runs in standalone mode, option 1 is the preferred method (and this is what Magisk and the Magisk app internally use) as environment variables are inherited down to child processes.

Magisk Modules

A Magisk module is a folder placed in /data/adb/modules with the structure below:

text
/* Detailed source-code truncated for AI context efficiency. */

module.prop

This is the strict format of module.prop

text
id=<string>
name=<string>
version=<string>
versionCode=
author=<string>
description=<string>
updateJson= (optional)
  • id has to match this regular expression: ^[a-zA-Z][a-zA-Z0-9._-]+$
    ex: โœ“ a_module, โœ“ a.module, โœ“ module-101, โœ— a module, โœ— 1_module, โœ— -a-module
    This is the unique identifier of your module. You should not change it once published.
  • versionCode has to be an integer. This is used to compare versions
  • updateJson should point to a URL that downloads a JSON to provide info so the Magisk app can update the module.
  • Others that weren't mentioned above can be any single line string.
  • Make sure to use the UNIX (LF) line break type and not the Windows (CR+LF) or Macintosh (CR).

Update JSON format:

text
{
    "version": string,
    "versionCode": int,
    "zipUrl": url,
    "changelog": url
}

Shell scripts (`*.sh`)

Please read the Boot Scripts section to understand the difference between post-fs-data.sh and service.sh. For most module developers, service.sh should be good enough if you just need to run a boot script. If you need to wait for boot completed, you can use resetprop -w sys.boot_completed 0.

In all scripts of your module, please use MODDIR=${0%/*} to get your module's base directory path; do NOT hardcode your module path in scripts.
If Zygisk is enabled, the environment variable ZYGISK_ENABLED will be set to 1.

The `system` folder

All files you want to replace/inject should be placed in this folder. This folder will be recursively merged into the real /system; that is: existing files in the real /system will be replaced by the one in the module's system, and new files in the module's system will be added to the real /system.

If you place a file named .replace in any of the folders, instead of merging its contents, that folder will directly replace the one in the real system. This can be very handy for swapping out an entire folder.

If you want to replace files in /vendor, /product, or /system_ext, please place them under system/vendor, system/product, and system/system_ext respectively. Magisk will transparently handle whether these partitions are in a separate partition or not.

If you want to remove a specific file or folder, please place a dummy character device with major number 0 and minor number 0 in the same path. For example, if you want to remove /system/app/GoogleCamera, you can mknod GoogleCamera c 0 0 in $MODDIR/system/app.

Zygisk

Zygisk is a feature of Magisk that allows advanced module developers to run code directly in every Android applications' processes before they are specialized and running. For more details about the Zygisk API and building a Zygisk module, please checkout the Zygisk Module Sample project.

system.prop

This file follows the same format as build.prop. Each line comprises of [key]=[value].

sepolicy.rule

If your module requires some additional sepolicy patches, please add those rules into this file. Each line in this file will be treated as a policy statement. For more details about how a policy statement is formatted, please check magiskpolicy's documentation.

Magisk Module Installer

A Magisk module installer is a Magisk module packaged in a zip file that can be flashed in the Magisk app or custom recoveries such as TWRP. The simplest Magisk module installer is just a Magisk module packed as a zip file, in addition to the following files only if the module supports flashing in recovery:

  • update-binary: Download the latest module_installer.sh and rename/copy that script as update-binary
  • updater-script: This file should only contain the string #MAGISK

The module installer script will setup the environment, extract the module files from the zip file to the correct location, then finalizes the installation process, which should be good enough for most simple Magisk modules.

text
module.zip
โ”‚
โ”œโ”€โ”€ META-INF                           <--- Only needed for flashing in recovery
โ”‚   โ””โ”€โ”€ com
โ”‚       โ””โ”€โ”€ google
โ”‚           โ””โ”€โ”€ android
โ”‚               โ”œโ”€โ”€ update-binary      <--- The module_installer.sh you downloaded
โ”‚               โ””โ”€โ”€ updater-script     <--- Should only contain the string "#MAGISK"
โ”‚
โ”œโ”€โ”€ customize.sh                       <--- (Optional, more details later)
โ”‚                                           This script will be sourced by update-binary
โ”œโ”€โ”€ ...
โ”œโ”€โ”€ ...  /* The rest of module's files */
โ”‚

Customization

If you need to customize the module installation process, optionally you can create a script in the installer named customize.sh. This script will be sourced (not executed!) by the module installer script after all files are extracted and default permissions and secontext are applied. This is very useful if your module require additional setup based on the device ABI, or you need to set special permissions/secontext for some of your module files.

If you would like to fully control and customize the installation process, declare SKIPUNZIP=1 in customize.sh to skip all default installation steps. By doing so, your customize.sh will be responsible to install everything by itself.

The customize.sh script runs in Magisk's BusyBox ash shell with "Standalone Mode" enabled. The following variables and functions are available:

Variables

  • MAGISK_VER (string): the version string of current installed Magisk (e.g. v20.0)
  • MAGISK_VER_CODE (int): the version code of current installed Magisk (e.g. 20000)
  • BOOTMODE (bool): true if the module is being installed in the Magisk app
  • MODPATH (path): the path where your module files should be installed
  • TMPDIR (path): a place where you can temporarily store files
  • ZIPFILE (path): your module's installation zip
  • ARCH (string): the CPU architecture of the device. Value is either arm, arm64, x86, x64, or riscv64
  • IS64BIT (bool): true if $ARCH is either arm64, x64, or riscv64
  • API (int): the API level (Android version) of the device (e.g. 23 for Android 6.0)

Functions

text
ui_print <msg>
    Print <msg> to console
    Avoid using 'echo' as it will not display in custom recovery's console

abort <msg>
    Print error message <msg> to console and terminate the installation
    Avoid using 'exit' as it will skip the termination cleanup steps

set_perm <target> <owner> <group>  [context]
    If [context] is not specified, the default is "u:object_r:system_file:s0"
    This function is a shorthand for the following commands:
       chown owner.group target
       chmod permission target
       chcon context target

set_perm_recursive <directory> <owner> <group> <dirpermission> <filepermission> [context]
    If [context] is not specified, the default is "u:object_r:system_file:s0"
    This function is a shorthand for the following psuedo code:
      set_perm <directory> owner group dirpermission context
      for file in <directory>:
        set_perm file owner group filepermission context
      for dir in <directory>:
        set_perm_recursive dir owner group dirpermission context

For convenience, you can also declare a list of folders you want to replace in the variable name REPLACE. The module installer script will create the .replace file into the folders listed in REPLACE. For example:

sh
REPLACE="
/system/app/YouTube
/system/app/Bloatware
"

The list above will result in the following files being created: $MODPATH/system/app/YouTube/.replace and $MODPATH/system/app/Bloatware/.replace.

For convenience, you can also declare a list of files/folders you want to remove in the variable name REMOVE. The module installer script will create the corresponding dummy devices. For example:

sh
REMOVE="
/system/app/YouTube
/system/fonts/Roboto.ttf
"

The list above will result in the following dummy devices being created: $MODPATH/system/app/YouTube and $MODPATH/system/fonts/Roboto.ttf.

Notes

  • When your module is downloaded with the Magisk app, update-binary will be forcefully replaced with the latest module_installer.sh. DO NOT try to add any custom logic in update-binary.
  • Due to historical reasons, DO NOT add a file named install.sh in your module installer zip.
  • DO NOT call exit at the end of customize.sh. The module installer script has to perform some cleanups before exiting.

Boot Scripts

In Magisk, you can run boot scripts in 2 different modes: post-fs-data and late_start service mode.

  • post-fs-data mode
    • This stage is BLOCKING. The boot process is paused before execution is done, or 40 seconds have passed.
    • Scripts run before any modules are mounted. This allows a module developer to dynamically adjust their modules before it gets mounted.
    • This stage happens before Zygote is started, which pretty much means everything in Android
    • WARNING: using setprop will deadlock the boot process! Please use resetprop -n instead.
    • Only run scripts in this mode if necessary.
  • late_start service mode
    • This stage is NON-BLOCKING. Your script runs in parallel with the rest of the booting process.
    • This is the recommended stage to run most scripts.

In Magisk, there are also 2 kinds of scripts: general scripts and module scripts.

  • General Scripts
    • Placed in /data/adb/post-fs-data.d or /data/adb/service.d
    • Only executed if the script is set as executable (chmod +x script.sh)
    • Scripts in post-fs-data.d runs in post-fs-data mode, and scripts in service.d runs in late_start service mode.
    • Modules should NOT add general scripts during installation
  • Module Scripts
    • Placed in the module's own folder
    • Only executed if the module is enabled
    • post-fs-data.sh runs in post-fs-data mode, and service.sh runs in late_start service mode.

All boot scripts will run in Magisk's BusyBox ash shell with "Standalone Mode" enabled.

Root Directory Overlay System

Since / is read-only on system-as-root devices, Magisk provides an overlay system to enable developers to replace files in rootdir or add new *.rc scripts. This feature is designed mostly for custom kernel developers.

Overlay files shall be placed in the overlay.d folder in boot image ramdisk, and they follow these rules:

  1. Each *.rc file (except for init.rc) in overlay.d will be read and concatenated AFTER init.rc if it does not exist in the root directory, otherwise it will REPLACE the existing one.
  2. Existing files can be replaced by files located at the same relative path
  3. Files that correspond to a non-existing file will be ignored

To add additional files which you can refer to in your custom *.rc scripts, add them into overlay.d/sbin. The 3 rules above do not apply to anything in this folder; instead, they will be directly copied to Magisk's internal tmpfs directory (which used to always be /sbin).

Starting from Android 11, the /sbin folder may no longer exists, and in that scenario, Magisk uses /debug_ramdisk instead. Every occurrence of the pattern ${MAGISKTMP} in your *.rc scripts will be replaced with the Magisk tmpfs folder when magiskinit injects it into init.rc. On pre Android 11 devices, ${MAGISKTMP} will simply be replaced with /sbin, so NEVER hardcode /sbin in the *.rc scripts when referencing these additional files.

Here is an example of how to setup overlay.d with a custom *.rc script:

text
ramdisk
โ”‚
โ”œโ”€โ”€ overlay.d
โ”‚   โ”œโ”€โ”€ sbin
โ”‚   โ”‚   โ”œโ”€โ”€ libfoo.ko      <--- These 2 files will be copied
โ”‚   โ”‚   โ””โ”€โ”€ myscript.sh    <--- into Magisk's tmpfs directory
โ”‚   โ”œโ”€โ”€ custom.rc          <--- This file will be injected into init.rc
โ”‚   โ”œโ”€โ”€ res
โ”‚   โ”‚   โ””โ”€โ”€ random.png     <--- This file will replace /res/random.png
โ”‚   โ””โ”€โ”€ new_file           <--- This file will be ignored because
โ”‚                               /new_file does not exist
โ”œโ”€โ”€ res
โ”‚   โ””โ”€โ”€ random.png         <--- This file will be replaced by
โ”‚                               /overlay.d/res/random.png
โ”œโ”€โ”€ ...
โ”œโ”€โ”€ ...  /* The rest of initramfs files */
โ”‚

Here is an example of the custom.rc:

text
# Use ${MAGISKTMP} to refer to Magisk's tmpfs directory

on early-init
    setprop sys.example.foo bar
    insmod ${MAGISKTMP}/libfoo.ko
    start myservice

service myservice ${MAGISKTMP}/myscript.sh
    oneshot

File: docs/install.md

Installation

If you already have Magisk installed, it is strongly recommended to upgrade directly via the Magisk app using its "Direct Install" method. The following tutorial is only for the initial installation.

Getting Started

Before you start:

  • This tutorial assumes you understand how to use adb and fastboot
  • If you plan to also install custom kernels, install it after Magisk
  • Your device's bootloader has to be unlocked

Download and install the latest Magisk app. In the home screen, you should see:

The result of Ramdisk determines whether your device has ramdisk in the boot partition. If your device does not have boot ramdisk, read the Magisk in Recovery section before continuing.

(Unfortunately, there are exceptions as some devices' bootloader accepts ramdisk even if it shouldn't. In this case, you will have to follow the instructions as if your device's boot partition does include ramdisk. There is no way to detect this, so the only way to know for sure is to actually try. Fortunately, as far as we know, only some Xiaomi devices are known to have this property, so most people can simply ignore this piece of information.)

If you are using a Samsung device, you can now jump to its own section.

If your device has boot ramdisk, get a copy of the boot.img (or init_boot.img if exists).
If your device does NOT have boot ramdisk, get a copy of the recovery.img.
You should be able to extract the file you need from official firmware packages or your custom ROM zip.

Quick recap, at this point, you should have known and prepared:

  1. Whether your device has boot ramdisk
  2. A boot.img, init_boot.img or recovery.img based on (1)

Let's continue to Patching Images.

Patching Images

  • Copy the boot/init_boot/recovery image to your device
  • Press the Install button in the Magisk card
  • If you are patching a recovery image, check the "Recovery Mode" option
  • Choose "Select and Patch a File" in method, and select the boot/init_boot/recovery image
  • Start the installation, and copy the patched image to your PC using ADB:
    adb pull /sdcard/Download/magisk_patched_[random_strings].img
  • Flash the patched boot/init_boot/recovery image to your device;
    for most devices, reboot into fastboot mode and flash with command:
    fastboot flash boot /path/to/magisk_patched_[random_strings].img or
    fastboot flash init_boot /path/to/magisk_patched_[random_strings].img or
    fastboot flash recovery /path/to/magisk_patched_[random_strings].img
  • (Optional) If your device has a separate vbmeta partition, you can patch the vbmeta partition with command:
    fastboot flash vbmeta --disable-verity --disable-verification vbmeta.img (note that it may wipe your data)
  • Reboot and launch Magisk app (you will see a stub Magisk app if you have wiped your data; use it to bootstrap to a complete Magisk app), and you will see a prompt asking for environment fix; click and wait for the reboot
  • Voila!

Warning: NEVER flash patched image shared by others or patch image on another device even if they have the same device model! You may need to do a full data wipe to recover your device. ALWAYS patch boot image on the same device where you want to install Magisk.

Uninstallation

The easiest way to uninstall Magisk is directly through the Magisk app. If you insist on using custom recoveries, rename the Magisk APK to uninstall.zip and flash it like any other ordinary flashable zip.

Magisk in Recovery

In the case when your device does not have ramdisk in boot images, Magisk has no choice but to hijack the recovery partition. For these devices, you will have to reboot to recovery every time you want Magisk enabled.

When Magisk hijacks the recovery, there is a special mechanism to allow you to actually boot into recovery mode. Each device model has its own key combo to boot into recovery, as an example for Galaxy S10 it is (Power + Bixby + Volume Up). A quick search online should easily get you this info. As soon as you press the key combo and the device vibrates with a splash screen, release all buttons to boot into Magisk. If you decide to boot into the actual recovery mode, long press volume up until you see the recovery screen.

As a summary, after installing Magisk in recovery (starting from power off):

  • (Power up normally) โ†’ (System with NO Magisk)
  • (Recovery Key Combo) โ†’ (Splash screen) โ†’ (Release all buttons) โ†’ (System with Magisk)
  • (Recovery Key Combo) โ†’ (Splash screen) โ†’ (Long press volume up) โ†’ (Recovery Mode)

(Note: You CANNOT use custom recoveries to install or upgrade Magisk in this case!!)

Samsung Devices

Before proceeding, please acknowledge that:

  • Installing Magisk WILL trip your Knox Warranty Bit, this action is not reversible in any way.
  • Installing Magisk for the first time REQUIRES a full data wipe (this is NOT counting the data wipe when unlocking bootloader). Please make a backup of your data.

Flashing Tools

Requirements

To verify whether or not Magisk can be installed in your Samsung device, you first must check the OEM Lock and KnoxGuard (RMM) status. To do so, go to Settings -> Device Care -> Maintenance Mode and enable it, then boot your device in Download mode with its key combo.

Possible OEM Lock values are the following:

  • ON (L): fully locked.
  • ON (U): bootloader locked, OEM unlocking enabled.
  • OFF (U): fully unlocked.

To unlock your bootloader, follow the instructions below. If no OEM Lock value is shown in Download mode, your device is probably not unlockable due to market limitations (USA/Canada devices).

Possible KnoxGuard values are the following:

  • Active, Locked: your device has been remotely locked by your telecom operator or your insurance company.
  • Prenormal: your device is temporarily locked, reaching 168h of uptime should trigger unlock.
  • Checking, Completed, Broken: your device is unlocked.

Having KnoxGuard active will prevent you from installing/running Magisk regardless of your bootloader lock state.

Unlocking the bootloader

  • Allow bootloader unlocking in Developer options โ†’ OEM unlocking
  • Reboot to download mode: power off your device and press the download mode key combo for your device
  • Long press volume up to unlock the bootloader. This will wipe your data and automatically reboot.
  • Go through the initial setup. Skip through all the steps since data will be wiped again in later steps. Connect the device to Internet during the setup.
  • Enable developer options, and confirm that the OEM unlocking option exists and is grayed out. This means KnoxGuard hasn't locked your device.
  • Your bootloader now accepts unofficial images in download mode

Instructions

  • Download the latest firmware package for your device, you can use one of the tools below to download it directly from Samsung servers:
  • Unzip the firmware and copy the AP tar file to your device. It is normally named as AP_[device_model_sw_ver].tar.md5
  • Press the Install button in the Magisk card
  • If your device does NOT have boot ramdisk, check the "Recovery Mode" option
  • Choose "Select and Patch a File" in method, and select the AP tar file
  • Start the installation, and copy the patched tar file to your PC using ADB:
    adb pull /sdcard/Download/magisk_patched_[random_strings].tar
    DO NOT USE MTP as it is known to corrupt large files.
  • Reboot to download mode. Open Odin on your PC, and flash magisk_patched.tar as AP, together with BL, CP, and CSC (NOT HOME_CSC because we want to wipe data) from the original firmware.
  • Your device should reboot automatically once Odin finished flashing. Agree to do a factory reset if asked.
  • If your device does NOT have boot ramdisk, reboot to recovery now to enable Magisk (reason stated in Magisk in Recovery).
  • Install the Magisk app you've already downloaded and launch the app. It should show a dialog asking for additional setup.
  • Let the app do its job and automatically reboot the device. Voila!

Upgrading the OS

Once you have rooted your Samsung device, you can no longer upgrade your Android OS through OTA. To upgrade your device's OS, you have to manually download the new firmware zip file and go through the same AP patching process written in the previous section. The only difference here is in the Odin flashing step: do NOT use the CSC tar, but instead use the HOME_CSC tar as we are performing an upgrade, not the initial install.

Important Notes

  • Never, ever try to restore either boot, init_boot, recovery, or vbmeta partitions back to stock! You can brick your device by doing so, and the only way to recover from this is to do a full Odin restore with data wipe.
  • To upgrade your device with a new firmware, NEVER directly use the stock AP tar file with reasons mentioned above. Always patch AP in the Magisk app and use that instead.

Custom Recovery

This installation method is deprecated and is maintained with minimum effort. YOU HAVE BEEN WARNED!

Installing using custom recoveries is only possible if your device has boot ramdisk. Installing Magisk through custom recoveries on modern devices is no longer recommended. If you face any issues, please use the Patch Image method.

  • Download the Magisk APK
  • Rename the .apk file extension to .zip, for example: Magisk-v24.0.apk โ†’ Magisk-v24.0.zip. If you have trouble renaming the file extension (like on Windows), use a file manager on Android or the one included in the custom recovery to rename the file.
  • Flash the zip just like any other ordinary flashable zip.
  • Reboot and check whether the Magisk app is installed. If it isn't installed automatically, manually install the APK.
  • Launch the Magisk app; it will show a dialog asking for reinstallation. Do the reinstallation directly within the app and reboot (if you are using MTK devices that lock the boot partition after boot, please patch the boot image and flash it by custom recovery or fastboot).

Warning: the sepolicy.rule file of modules may be stored in the cache partition. DO NOT WIPE THE CACHE PARTITION.


File: docs/ota.md

OTA Upgrade Guides

Magisk does not modify most read-only partitions, which means applying official OTAs is much simpler. Here are the tutorials for several different kind of devices to apply OTAs and preserve Magisk after the installation (if possible). This is just a general guide as procedures for each device may vary.

NOTE: In order to apply OTAs, you HAVE to make sure you haven't modified and read-only partitions yourself (such as /system or /vendor) in any way. Even remounting the partition to rw will tamper block verification!!

Prerequisites

  • Please disable Automatic system updates in developer options, so it won't install OTAs without your acknowledgement.

  • When an OTA is available, first go to (Magisk app โ†’ Uninstall โ†’ Restore Images). Do not reboot or you will have Magisk uninstalled. This will restore partitions modified by Magisk back to stock from backups made at install in order to pass pre-OTA block verifications. This step is required before doing any of the following steps written below!

Devices with A/B Partitions

It is possible to have the OTA installed to the inactive slot and have the Magisk app install Magisk onto the updated partitions. The out-of-the-box OTA installation works seamlessly and Magisk can be preserved after the installation.

  • After restoring stock images, apply OTAs as you normally would (Settings โ†’ System โ†’ System Update).

  • Wait for the installation to be fully done (both step 1: "installing update", and step 2: "optimizing your device", of the OTA), do not press the "Restart now" or "Reboot" button! Instead, go to (Magisk app โ†’ Install โ†’ Install to Inactive Slot) to install Magisk to the updated slot.

  • After installation is done, follow the final instructions at the end of the Magisk installation on how to reboot into the new slot, currently involving going back to the regular system update and hitting "restart now" (previous method of using reboot within Magisk App may not result in rebooting to new slot). Under-the-hood, the Magisk app tracks your device switch to the updated slot, bypassing any possible post-OTA verifications.

"Non A/B" Devices

Unfortunately, there are no real good ways to apply OTAs on these devices. The following tutorial will not preserve Magisk; you will have to manually re-root your device after the upgrade, and this will require access to a computer. These are simply "best practices".

  • To properly install OTAs, you must have your stock recovery installed on your device. If you have custom recovery installed, you can restore it from your previous backup, or dumps found online, or factory images provided by OEMs.
    If you decide to start by installing Magisk without touching your recovery partition, you have a few choices, either way you will end up with a Magisk rooted device, but recovery remains stock untouched:
    • If supported, use fastboot boot <recovery_img> to boot the custom recovery and install Magisk.
    • If you have a copy of your stock image dump, install Magisk by using the Magisk app's "patch images" feature
  • Once you restored back to stock recovery and other images, download the OTA. Optionally, once you have downloaded the OTA update zip, find a way to extract the zip (as it usually involved root)
  • Apply the OTA and reboot your device. This will use the official stock OTA installation mechanism of your device to upgrade your system.
  • Once it's done you will be left with an upgraded, 100% stock, un-rooted device. You will have to manually flash Magisk back. Consider using the methods stated in step 1. to flash Magisk without touching the recovery partition if you want to receive stock OTAs frequently.