magisk-files

Magisk Delta Internal Documentation

This document explains some of the advanced features of Magisk Delta, a systemless root solution for Android devices. Magisk Delta allows you to modify your device without altering the original boot image, and provides a unified interface for managing modules, root access, and more.

Early mount

Some files need to be mounted as early as possible in the boot process, before the init process is executed. Magisk Delta provides a way to mount files in the pre-init stage, using the early-mount.d directory.

EARLYMOUNTV2=false
if grep "$(magisk --path)/.magisk/early-mount.d" /proc/mounts | grep -q '^early-mount.d/v2'; then
    EARLYMOUNTV2=true
fi
$(magisk --path)/.magisk/early-mount.d

General

(*) Be careful when using persist or metadata for early-mount, as these partitions have very limited size. Filling them up might cause the device to fail to boot.

Module

Note: Early-init mount only supports simple mount, which means it can replace files but cannot add new files, folders or replace folders

init.rc inject

General

If you want to inject custom *.rc scripts into your device without repacking the boot image, Magisk Delta provides a way to do that systemlessly. You can use the initrc.d directory to store your custom scripts, and Magisk Delta will inject them into init.rc every boot.

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

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

service myservice ${MAGISKTMP}/.magisk/early-mount.d/myscript.sh
    oneshot

Module

Remove files and folders

It is complicated to actually remove a file (possible, not worth the effort). Replacing it with a dummy file should be good enough

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

ln -s "/xxxxx" /data/adb/modules/mymodule_id/system/vendor/etc/thermal-engine-normal.conf