How to repack Magisk boot image? (Magisk installed)
0
votes
0
answers
2093
views
everyone.
I have a OnePlus 5t, updated to Android 9 and Project Treble.
I have my own Magisk module for my own tweaks, but I am not satisfied. I found that I need a patched init.rc in order to have one script of mine run when I need it.
There is an official howto chapter dedicated to an "overlay.d" directory that can modify files on the root of the filesystem, say
/init.rc
, https://topjohnwu.github.io/Magisk/guides.html#root-directory-overlay-system
, however, this "howto" is terse and hard to understand for people not familiar with Magisk's internals.
There is also a script that should help to repack the boot image https://github.com/topjohnwu/Magisk/blob/master/scripts/boot_patch.sh
, but it is relying on certain commands not in that directory.
By trial and error I have found a way to extract "magiskboot
" from the magisk's install Magisk-*.zip
, and I also found that this magiskboot can unpack the /dev/disk/by-name/boot
partition. (I know, that is probably insane, a partition is not a file, but somehow magiskboot manages to navigate it by itself.) But that requires running that command on the phone itself (with magisk's su), and I am not sure how valid this is. Trying to run the "boot_patch.sh
" by first copying it to the phone, and using the extracted rootfs.cpio seems way beyond my ability, and I am also very unsure whether this can be done with the system booted, or I should do it from TWRP, or whatever.
So, a decent guide (for dummies) on how to patch the boot image would be appreciated. I only need to add two files: custom.rc
, with the service description, and a custom.sh
with the service code itself.
Help would be appreciated!
Asked by user10732
(46 rep)
Apr 13, 2022, 09:15 AM