Magisk on custom rom - Xiaomi Redmi 4X Questions & Answers

How do I build a custom rom with Magisk? I've tried googling it, but all I could find was how to install it on custom ROMs. But what I want is to BUILD a custom ROM which will install Magisk automatically. Is there a tutorial available for that?
ps.: I'm not entirely sure if this is the best place to ask this question, so moderators pls move if it's in the wrong section

You have to patch your boot image first. Afaik you can do it manually while building. Check updater-script and sh files from common on magisk zip. And integrate magisk apk to system.

Related

Magisk addon.d script?

Is there anyway someone can make an addon.d script for both magisk and the phh root? There's a similar script that you can find here that does this for xposed. Also, the Gapps use it. This would be very helpful so we don't have to reflash the scripts everytime.
Link_of_Hyrule said:
Is there anyway someone can make an addon.d script for both magisk and the phh root? There's a similar script that you can find here that does this for xposed. Also, the Gapps use it. This would be very helpful so we don't have to reflash the scripts everytime.
Click to expand...
Click to collapse
Ummm...
That makes no sense...
The magisk.img is in data... Survives dirty flash... The magical part of magisk... Is injected into the boot.img... Which, afaik, isn't possible via addon.d
Link_of_Hyrule said:
Is there anyway someone can make an addon.d script for both magisk and the phh root? There's a similar script that you can find here that does this for xposed. Also, the Gapps use it. This would be very helpful so we don't have to reflash the scripts everytime.
Click to expand...
Click to collapse
That makes no sense like the other guy said & only works with ROMs that have implemented that function (generally update-script that calls a script in root of the zip in CyanogenMods). If you install any ROM that have not that function, then nothing is backed up & /system is replaced as regular.
Addon.d is simply a folder with .sh scripts that are run when flashing a new rom update. Obviously, this won't work with stock roms but it should work for Lineage OS and similar roms I think. Sadly I don't know how to write .sh scripts.
Link_of_Hyrule said:
Addon.d is simply a folder with .sh scripts that are run when flashing a new rom update. Obviously, this won't work with stock roms but it should work for Lineage OS and similar roms I think. Sadly I don't know how to write .sh scripts.
Click to expand...
Click to collapse
Learn Bash, is easy to do like check how works other .sh scripts or if you are lazy search tutorials in Google xD...
Old thread, but I just discovered this "Flash After Update" script (actually @osm0sis pointed it out to me) which will flash any zip in a designated folder after flashing rom update.
osm0sis said:
99-flashafterupdate.sh addon.d script (many devices) - attached
For ROMs that don't have "Flash After Update" support built into their delta/update process. During an upgrade, this script will flash zips from a sdcard directory after all other addon.d backup/restore actions have completed. This can be used to flash SuperSU and then an AnyKernel2 kernel on CyanogenMod, for example. Remove the .txt extension once downloaded and place in /system/addon.d/ with rwxr-xr-x (755) permissions.
Click to expand...
Click to collapse
Especially handy if you keep your device unrooted, and can't use a tool such as this:
https://play.google.com/store/apps/details?id=se.davison.autoflasher
Link_of_Hyrule said:
Is there anyway someone can make an addon.d script for both magisk and the phh root? There's a similar script that you can find here that does this for xposed. Also, the Gapps use it. This would be very helpful so we don't have to reflash the scripts everytime.
Click to expand...
Click to collapse
Have a look at this:
https://github.com/topjohnwu/Magisk/issues/175
So is he integration the feature directly into Magisk?
Why don't you submit the changes as a pull request?
Edit: Tested the script. I can use the official Lineage OS updater now! No need for a third party app to auto flash Magisk want update.
Sent from my Nexus 7 using Tapatalk

[MODULE] Magisk Kcal changer Script by

Android Kcal changer​​get perfect screen colour on any Android device(with kernel support) running Android 5.0+!​
Hi all,
This is my first Magisk module, and with a very simple purpose
Prerequisites
Magisk v11.6 or higher, in case of using the Magisk Module.
A working custom recovery (TWRP, PhilZ, etc.)
Tested on
Both module and flashable Zip had been tested on AEX4.6, AICP 7.1.2 and RR_N, working perfectly in the three
Downloads
Download from the attachments[/URL], in the future in the Magisk Manager repository (once topjohnwu adds it!),
Installation instructions
Magisk Module (via Custom Recovery) - Download it from the attachments or from my server. Reboot your device into recovery mode, then choose Install, locate the downloaded Zip and flash it.
Flashable Zip - Download it from the attachments or from my server. Reboot your device into recovery mode, then choose Install, locate the downloaded Zip and flash it.
Troubleshooting
I've seen some people that wiped their /data partition (aka Wipe Data/Factory reset), and thus losing their magisk.img and all their modules, since they're stored there.
This means: If you factory reset your device and didn't flash Magisk flashable Zip again, none of the modules will be able to work.
To fix it, flash Magisk flashable zip again, then flash all your modules, and it should all be working again.
Upgrade Notes : When upgrading from one module version to another make sure to remove the existing module first to avoid any conflicts during installation.
Change Log :
v1.0 - Initial Release

			
				
Hello, thanks for the module. But may i know how should i modify the value of the kcal? I am using stock kernel, I thought this suppose to work without custom kernel or it needs custom kernel that support kcal customisation to support this? tq.
.

Questions about installing Magisk on Tablet

Hello, I need help installing and configuring Magisk on my tablet. Here is why and what I'm trying to do:
On my Samsung SM-T350, I originally installed TWRP and then installed a custom ROM which has root access (as far as I know, stock recovery is no longer on device). I recently installed a particular app and it indicates the program will not run all of the features because it has detected 'root' access. The suggestion online to work around this problem has been to install Magisk.
From this, I first went to the Magisk Manager website and download the 5.4.3apk and installed it. Then when I open the Magisk Manager app, it asks me if I want to 'Install Magisk-v14.0.zip now'. If I click 'install', a list of choices pop up (Download Zip Only, Patch Boot Image File, Direct Install). Which should I choose? I don't remember which of these I tried, but I recall it didn't work or didn't do anything.
So in the mean time, I downloaded the Magisk-v14.0.zip file locally to my tablet (Downloads folder). I 'think' the proper way to install is to boot into TWRP, then select 'Install', then navigate to the Magisk-v14.0.zip and then install image? Is that correct, or will this attempt to install over my custom ROM? What is the proper way to finish the installation?
Thanks in advance!
Does anyone have any suggestions?? Thanks
First - the "Magisk Manager website" is not a place you want to visit. It is not an official source for anything Magisk and should not be trusted. Only download from xda or @topjohnwu's GitHub.
Second - if you're already rooted you need to first unroot. Read more on installing Magisk in the release thread and the Installation and troubleshooting thread. Most, if not all your queries should be answered there.

[DEV][Help][pre-Magisked] Integrating Magisk into kernel

Hi, I am trying to make some kind of "pre-Magisked" kernel, so that, when I flash that kernel already contains the necessary files to Magisk Superuser, avoiding the need to flash Magisk after each kernel flash.
I know the current script patches the ramdisk image when installing it, but I cant see which changes are executed exactly. Tried some of them resulting in bootloop
So, is there a way to create a pre-Magisked kernel or, at least, integrate basic files and later manually install Magisk Manager APK? There was a way to do it in Nougat with SuperSU which doesnt work with Oreo anymore...
bamsbamx said:
Hi, I am trying to make some kind of "pre-Magisked" kernel, so that, when I flash that kernel already contains the necessary files to Magisk Superuser, avoiding the need to flash Magisk after each kernel flash.
I know the current script patches the ramdisk image when installing it, but I cant see which changes are executed exactly. Tried some of them resulting in bootloop
So, is there a way to create a pre-Magisked kernel or, at least, integrate basic files and later manually install Magisk Manager APK? There was a way to do it in Nougat with SuperSU which doesnt work with Oreo anymore...
Click to expand...
Click to collapse
No its not possible to have a pre magisk'd kernel as magisk sets up files in /data/adb which you cannot do later on otherwise magisk will be non functional, you must flash the zip after wiping your data.

Question How To Update System While Keeping Magisk

I have several modules in Magisk app and couple of apps having root authority after get root with Magisk (like Tasker). Now I want to update system while keeping my magisk apps and root-to-use apps working without any risk of stucking in reboot after install a new ROM.
Could I just firstly patch the boot.img of objective ROM in Magisk, replace the boot.img with magisk_pathed_XXXX.img and flash all the .img files needed? Will this way work? Or any other ways?
while flashing a newer rom version, the magisk modules are not deleted. After flashing the new version install magisk again and everything is working well. Before updatating the rom version "restore hide magisk by itself" if you have enabled it.
If you have modules like SmaliPatcher - These will cause a bootloop after update.
Disable all modules before any update and make sure to Restore the Magisk App if its hidden.
zuize411 said:
I have several modules in Magisk app and couple of apps having root authority after get root with Magisk (like Tasker). Now I want to update system while keeping my magisk apps and root-to-use apps working without any risk of stucking in reboot after install a new ROM.
Could I just firstly patch the boot.img of objective ROM in Magisk, replace the boot.img with magisk_pathed_XXXX.img and flash all the .img files needed? Will this way work? Or any other ways?
Click to expand...
Click to collapse
I take from your description that you are flashing a fastboot ROM. In that case you are correct, i.e.
take boot.img from new ROM, patch in Magisk and copy back into the original installation folder. Simplest is to rename the original boot image and name the new magisk boot image: boot.img
now you can simply start the installation batch and it will automatically install the magisk-patched boot.img
If you are using TWRP to flash the ROM this is not needed, just flash the corresponsing magisk installation ZIP/APK in TWRP right after the system update and BEFORE rebooting.
In addition @JazonX gave a good advice , but it really depends on which modules you use.

Categories

Resources