[CLOSED][OUTDATED][2017.2.7][GUIDES & DOCS] Magisk All-In-One Wiki

Status
Not open for further replies.
Search This thread

Didgeridoohan

Retired Senior Moderator
May 31, 2012
12,300
1
14,850
Gone
Google Nexus 4
Nexus 6
Hi all, im a bit new with Magisk, i've instaled on my s7 a custom rom which had pre-installed an Magisk version, now that i have some days with this rom i got an update notification, how does update work? i just hit "download&install"? and before doing so i have to check the two lines : force encrypt amd dm-verify. Thanks in advance! :)

Wrong thread for support questions, but just press install...

If you need further help go here:
https://xdaforums.com/apps/magisk/mod-magisk-v1-universal-systemless-t3432382
 
  • Like
Reactions: alb.boy

Telperion

Senior Member
Feb 20, 2011
697
369
I'm working on a module for systemlessly replacing stock Huawei apps with Google versions (or other alternatives) and I'm running into a bit of a problem. I started off small by replacing Gallery2.apk with QuickPic. It overwrites the stock gallery as intended, but crashes when it attempts to load.

Update: It looks like the library folders under the application folders in /priv-app/ were the problem, when I explicitly listed those folder paths in config.sh to replace the whole directory the applications work now. I'm leaving this post up so that if anybody else has a similar problem they can find it.
 
Last edited:

Jack'O

Senior Member
Aug 13, 2011
1,875
815
One of many.
Hi, is there a way to install Magisk via fastboot or adb in order to not need to unlock devices bootloader and flashing a third party recovery?
 

Jack'O

Senior Member
Aug 13, 2011
1,875
815
One of many.
I'm pretty sure you can't modify anything other than data, cache, and sdcard if your bootloader is locked so probably no
Thanks for reply, I would like to install just an ad blocker, don't know if it needs to manage /system or other restricted partitions.

Edit: Unfortunately yes, those are AdAway requirements (from AdAway official site):
Requirements

Android version: 2.1
ROOT required
Read/Write access on system-Partition
 
Last edited:

Zackptg5

Recognized Developer
Sep 18, 2014
4,148
7,005
zackptg5.com
Google Pixel 4a
Google Pixel 5a
Thanks for reply, I would like to install just an ad blocker, don't know if it needs to manage /system or other restricted partitions.
Most adblockers that require root modify system (and most require root). So if you don't want to unlock the bootloader/root your phone (magisk is a root solution among other things), you'll need to find an adblock that doesn't require root. The only ones I know of just route your network traffic through the filters via VPN
 
  • Like
Reactions: Jack'O

Attachments

  • Screenshot_20170409-221906.png
    Screenshot_20170409-221906.png
    195.8 KB · Views: 853
  • Like
Reactions: Jack'O
7

7am

Guest
Magisk All-In-One Wiki

Table of Contents
  • Module Creation And Online Repos
    • Create your first Magisk Module; Submit to Magisk Module Repo
    • Notes Regarding Magisk Module Repos
  • Magisk Guides and Tricks
    • How Do Magic Mount Behave
    • Manipulate system props (build.prop)
    • Remove files / folders
    • Cache mounts
  • Magisk Details (DEV)
    • sepolicy-inject tool
    • Work flow
    • File structure
    • Boot stages

Module Creation And Online Repos

Create your first Magisk Module; Submit to Magisk Module Repo
Details are all listed in the module template on Github.​

Notes Regarding Magisk Module Repos
Magisk module can be different kinds, for example it can be used to debloat your system; it can be used to install your favorite application into system to give it the privilege of system apps.; it can be a full custom rom; it can also be cool mods like Xposed and root. However I view the "Magisk Module Repo" as a platform to share modules that can be used on lots of devices, preferably universal to all Android devices. Device specific modules are OK if stated clearly in the descriptions, and actually doing something that is non-trivial.
I will moderate the "Magisk Module Repo" in my personal preference and standard, here are some that will not be included:
  • Modules that are too large. A full custom rom, for example, is too large to be hosted on Github effectively. You can share them on XDA forums in your device specific forums
  • Modules that are too trivial. For example: mods that simply just add apps to system; debloating selective apps; doing things that can be done in simple boot scripts. I'll add more here if when I face requests that I consider "trivial"
  • Modules that contains copyright property (unless given permission)
  • Modules that violates XDA rules
this application it's meant to self auto installing after removed from system ?
 

AzzidReign

Member
Apr 4, 2011
36
6
I get nothing but bootloops with Magisk.

I'm on Note 3 (sprint), Android 5.0. I've been rooted for years and am currently on the newest 2.79 systemless su.

Here's what I've tried:
Recovery > flash magisk 12.0 (and unofficial 13.0) > reboot ---> bootloop
Recovery > flash magisk 12.0 > flash supersu 2.79 > reboot ----> bootloop
Recovery > flash supersu 2.79 > reboot (so now I'm stock rom + supersu and I do have xposed, looks like v85.0, it was hard to find a working one for note3 about a year ago) > launch magisk manager > install magisk ---> error quickly flashes about saving or storage (too quick for me to read, isn't in any log iirc)

Am I doing something wrong? Should I flash a specific ROM to get this to work? TIA!
 
Status
Not open for further replies.

Top Liked Posts

  • There are no posts matching your filters.
  • 58
    This thread is outdated and will never be updated
    Please check the official Magisk documentation on Github!



    Magisk All-In-One Wiki

    Table of Contents
    • Module Creation And Online Repos
      • Create your first Magisk Module; Submit to Magisk Module Repo
      • Notes Regarding Magisk Module Repos
    • Magisk Guides and Tricks
      • How Do Magic Mount Behave
      • Manipulate system props (build.prop)
      • Remove files / folders
      • Cache mounts
    • Magisk Details (DEV)
      • sepolicy-inject tool
      • Work flow
      • File structure
      • Boot stages

    Module Creation And Online Repos

    Create your first Magisk Module; Submit to Magisk Module Repo
    Details are all listed in the module template on Github.​

    Notes Regarding Magisk Module Repos
    Magisk module can be different kinds, for example it can be used to debloat your system; it can be used to install your favorite application into system to give it the privilege of system apps.; it can be a full custom rom; it can also be cool mods like Xposed and root. However I view the "Magisk Module Repo" as a platform to share modules that can be used on lots of devices, preferably universal to all Android devices. Device specific modules are OK if stated clearly in the descriptions, and actually doing something that is non-trivial.
    I will moderate the "Magisk Module Repo" in my personal preference and standard, here are some that will not be included:
    • Modules that are too large. A full custom rom, for example, is too large to be hosted on Github effectively. You can share them on XDA forums in your device specific forums
    • Modules that are too trivial. For example: mods that simply just add apps to system; debloating selective apps; doing things that can be done in simple boot scripts. I'll add more here if when I face requests that I consider "trivial"
    • Modules that contains copyright property (unless given permission)
    • Modules that violates XDA rules
    51
    This thread is outdated and will never be updated
    Please check the official Magisk documentation on Github!



    Magisk Guides and Tricks

    How Do Magic Mount Behave
    • Magic Mount by default merges the files in $MODPATH/system into the real /system. You can think as it dirty flashes the contents into /system.
      Existing files will be replaced; new files will be added; will not remove any files
    • Directories under $MODPATH/system that contains a file named ".replace" will NOT merge into the system. It will directly replace the correspond directory in /system.
      In the module template, you can list them in "config.sh", the scripts will create the ".replace" file automatically for you.
      You can think as it wipes the existing folder, and then adds contents to that folder in /system.
      The directory that contains ".replace" will replace the one in /system, all contents originally in the folder will be discarded
    • Adding items to system is relatively expensive, Magisk would need to do many under-the-hood tasks to achieve it (thus, called "Magic Mount")
      Furthermore, the higher level the file is added, the more it effects the overall system
      Only add new items if necessary! Think twice before adding items to /system root!
    • Replacing a whole folder is recommended if viable, it reduces the complicated process and speed up the booting time

    Manipulate system props (build.prop)
    Since the early days of XDA, people love "build.prop" mods. It can bring cool effects to our devices.
    build.prop files are loaded early in the boot process, and once read-in, the values cannot be modified... in theory.
    Magisk included a tool called "resetprop", it can modify any system props you want easily.
    In the module template, you can set PROPFILE=true, then add your props into the file common/system.prop
    Magisk by default reads the system.prop of each module and set the props.
    Further resetprop options:
    Code:
    usage: /data/magisk/resetprop [-v] [-n] [--file propfile] [--delete name] [ name value ] 
       -v :
          verbose output (Default: Disabled)
       -n :
          no event triggers when changing props (Default: Will trigger events)
       --file propfile :
          Read props from prop files (e.g. build.prop)
       --delete name :
          Remove a prop entry

    Remove files / folders
    • It is complicated to actually remove a file (possible, not worth the effort). Replacing it with a dummy file should be good enough
      Add an empty file with the same name and path into your module (easy way), or add this code to the updater-script to create it at flash time
      Code:
      # Example: you want to remove /system/media/audio/alarms/Argon.ogg
      # Note: mktouch is a function defined in my updater-script, it is not a standard command!
      mktouch $MODDIR/system/media/audio/alarms/Argon.ogg
    • It is complicated to actually remove a folder (possible, not worth the effort). Replacing it with an empty folder should be good enough
      Add the folder to the replace list in "config.sh" in the module template, it will replace the folder with an empty one

    Cache mounts
    Some files requires to be mounted much earlier in the boot process, currently known are bootanimation, and some libs (most users won't change them).
    You can place your files into the corresponding location under /cache/magisk_mount, Magisk will automagiskally manage selinux contexts, permissions and the mounting for you. For example, you want to replace /system/media/bootanimation.zip, copy your new boot animation zip to /cache/magisk_mount/system/media/bootanimation.zip, Magisk will mount your files in the next reboot​

    More to come ...
    23
    This thread is outdated and will never be updated
    Please check the official Magisk documentation on Github!



    Magisk Details (DEV)

    sepolicy-inject
    • Before starting, check the complete document from Chainfire
      SELinux Policy Section in How-To SU
    • The included sepolicy manipulation tool is called "sepolicy-inject", it supports live patching, and also supports policy statements following the same syntax as supolicy:
      Code:
      sepolicy-inject [--live] [--minimal] [--load <infile>] [--save <outfile>] [policystatement...]
      
        --live: directly load patched policy to device
        --minimal: minimal patches for boot image to let Magisk live patch on boot
      
      Supported policy statements:
      
      "allow #source-class #target-class permission-class #permission"
      "deny #source-class #target-class permission-class #permission"
      "auditallow #source-class #target-class permission-class #permission"
      "auditdeny #source-class #target-class permission-class #permission"
      "create #class"
      "permissive #class"
      "enforcing #class"
      "attradd #class #attribute"
      "typetrans source-class target-class permission-class default-class (optional: object-name)"
      
      source-class and target-class can be attributes (patches the whole group)
      All sections (except typetrans) can be replaced with '*' to patch every possible matches
      Sections marked with '#' can be replaced with collections in curly brackets
      e.g: allow { source1 source2 } { target1 target2 } permission-class { permission1 permission2 }
      Will be expanded to:
      allow source1 target1 permission-class permission1
      allow source1 target1 permission-class permission2
      allow source1 target2 permission-class permission1
      allow source1 target2 permission-class permission2
      allow source2 target1 permission-class permission1
      allow source2 target1 permission-class permission2
      allow source2 target2 permission-class permission1
      allow source2 target2 permission-class permission2

    Work flow

    Code:
                      --------post-fs---------                        
    (Device Boots) -> Mount Magisk cache files -> (build.prop and persist prop loads) ->
    
    
       -----------------------------post-fs-data---------------------------------
    -> Live patch sepolicy -> mount magisk.img -> Preparation -> 5 stage of tasks ->
    
                            --------------late_start--------------
    -> (System Start Up) -> run all service.sh -> Start Magisk Hide
                         -> (Parallel with other processes....)
    • (Preparation) Magisk will travel through all enabled module directories to collect info
    • (1st stage) Mount system (vendor) mirrors. This is used to revert dummy files
    • (2nd stage) Clone the system structure, and mount the dummy directories to provide a dummy skeleton
    • (3rd stage) Mount module items into the system (and dummy skeletons)
    • (4th stage) Execute scripts
    • (5th stage) Mount the mirror items back to the remaining dummy files

    File Structures
    • A "Magisk Module" is a subfolder under magisk root directory
    • The structure of a Magisk Module do not have a strict restriction. However, here are some key files / folders:
      Code:
      /magisk
        |
        |-.core               <--- Magisk auto-generated files. Do not mess with them :)
        |  |
        |  | 
        |  |-hosts            <--- This file will be mounted to /system/etc/hosts to enable 
        |  |                       systemless support for AdBlocker apps.
        |  |-magiskhide       <--- This folder holds the hide list and add/rm/list/enable/disable scripts 
        |  |  |                    Include the magiskhide binary
        |  |  |-magiskhide
        |  |  |-hidelist
        |  |  |-add
        |  |  |-rm
        |  |  |-list
        |  |  |-enable
        |  |  |-disable
        |  |
        |  |-su               <--- This folder holds the MagiskSU binaries and scripts
        |  |  |                    Include the magiskhide binary
        |  |  |-su
        |  |  |-magisksu.sh
        |  |  |-sbin_bind     <--- This folder will bind mount to /sbin
        |  |    |-.....
        |  |
        |  |-post-fs-data.d   <--- Place scripts that should be executed at post-fs-data here
        |  |  |-.....
        |  |
        |  |-service.d        <--- Place scripts that should be executed at late_start service here
        |     |-.....
        |
        |
        |-other_module
        |  |-.....
        |
        |-your_module
        |  |
        |  |-auto_mount       <--- If this file exists, auto mount is enabled
        |  |
        |  |-disable          <--- If this file exists, the module is disabled
        |  |
        |  |-remove           <--- If this file exists, the whole module folder
        |  |                       will be removed in the next reboot
        |  |-module.prop      <--- This files stores the info of your module
        |  |
        |  |-system.prop      <--- This file will be read by resetprop
        |  |
        |  |-post-fs-data.sh  <--- This script will be executed in post-fs-data
        |  |
        |  |-service.sh       <--- This script will be executed in late_start service
        |  | 
        |  |-system           <--- If auto mount is enabled, Magisk will "Magic Mount" this folder 
        |  |  |-....
        |  |  |-....
        |  |  |-....
        |  |  |-....
        |  |
        |  |-vendor           <--- Auto generated. A symlink to $MODID/system/vendor 
        |  |                       Dealing with separate vendor partitions
        |  |-.....            <--- Any other files/folders are allowed
        |
        |-another_module
        |  |-.....
        |-...
    • Other important folders (under /dev), these will be created every boot
      Code:
      /dev/busybox    <--- Busybox applet symlinks will be created here
           |-....          Will be bind mounted to /system/xbin if enable busybox in Magisk Manager
           |-....
           |-....
      
      
      /dev/magisk
        |
        |-dummy       <--- Lies all cloned dummy structures
        |  |               Folders in here will be mounted to /system
        |  |-.....
        |
        |-mirror      <--- Lies all mirrors
        |  |
        |  |-system
        |  |  |-....
        |  |
        |  |-vendor   <--- Could be a symlink to /dev/mirror/system/vendor
        |     |-....
        |
        |-mnt         <--- Lies all mounting info
           |
           |-dummy    <--- Lists all dummy mounts
           |  |-....
           |
           |-mirror   <--- Lists all mirror mounts
           |  |-....
           |
           |-system   <--- Lists all /system mounts
           |  |-....
           |
           |-vendor   <--- Lists all /vendor mounts
              |-....

    Boot Stages
    If you are working on complicated projects, you shall need more control to the whole process.
    Magisk can run scripts in different boot stages, you can fine tune exactly what you want to do.
    • post-fs mode:
      • This stage is BLOCKING. Boot process will NOT continue until everything is done, or 20 seconds has passed
      • Happens after most partitions are mounted, except /data
      • Magisk will bind mount items in: /cache/magisk_mount/system (*1)
    • post-fs-data mode:
      • This stage is BLOCKING. Boot process will NOT continue until everything is done, or 60 seconds has passed
      • Happens after /data is ready (including encrypted data)
      • Happens before Zygote is started (which means pretty much everything)
      • /data/magisk.img will be mounted to /magisk
      • Magisk will bind mount items in: /magisk/$MODID/system (*2)
      • Magisk will run script: /magisk/$MODID/post-fs-data.sh
      • Magisk will run scripts in: /magisk/.core/post-fs-data.d
    • late_start service mode:
      • This stage is NON-BLOCKING, it will run parallel with other processes
        Put time consuming but non time critical tasks here. In other modes, the boot process will be stuck if it took too long to finish your tasks.
      • Happens when class late_start is started . Most things are are loaded/loading in this case.
      • Magisk will run script: /magisk/$MODID/service.sh
      • Magisk will run scripts in: /magisk/.core/service.d
    (*1) Bind mounting in post-fs only support simple bind mounts, which mean you cannot add files or replace directories.
    It will only mount files that exist in the current system.
    (*2) Bind mounting in post-fs-data support complex bind mounts. Please refer to the "Magic Mount" section
    4
    Just Install SuperSU from PlayStore problem solved.
    Which is a totally appropriate response in the Magisk forum. Before anyone mentions it I know SuperSU can work with Magisk, but seriously, if the OP wanted to install SuperSU then he wouldn't be asking why Magisk isn't working for him.
    3
    Hi...all,
    I want to build Magisk from source.
    Please Guide link me.

    •••

    It's literally in the README... https://github.com/topjohnwu/Magisk/blob/master/README.MD