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

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.

Related

[KERNEL][M 6.0] US Unlocked / Developer Edition [Normal/Systemless Root][03 DEC 2015]

**** The posted systemless kernel is only compatible with SuperSU 2.56!!! ****
*** Starting with SuperSU 2.60+ kernel can now be auto-patched for systemless root. ***
**As of 06 December 2015 flar2 has released ElementalX 6.02 for Sense Marshmallow **
* If you still desire a stock kernel with systemless root but want to use newer SuperSU see below *​
Messed around with the boot.img from today's Marshmallow update and have made it compatible with systemless root.
Systemless root in general is experimental and so is the kernel. I've literally just made it and tested it enough to that it boots and apps are able to be granted root access, so flash at your own risk.
Kernel has been running without issue.
Other than systemless root compatibility, this kernel is completely stock and no other modifications made.
Intructions - Systemless:
Download kernel from here.
Download SuperSU 2.56 beta from this post (only one that works with this method of root).
Copy both to phone
Flash the image directly using TWRP (toggle from ZIP to IMG under install)
Immediately flash SuperSU-v2.56-20151030013730.zip afterwards.
Reboot
TWRP will notify of no SU when you reboot, click DO NOT INSTALL as TWRP needs to be updated to detect this root method (it only looks in /system)
Instructions - Traditional:
Download kernel from here.
Download SuperSU 2.52 beta from this thread (it's the M compatible version)
Copy both to phone
Flash the image directly using TWRP (toggle from ZIP to IMG under install)
Immediately flash BETA-SuperSU-v2.52.zip afterwards.
Reboot
Keeping stock kernel with updated SuperSU:
If you prefer running the stock kernel with systemless root and want to stay current on SuperSU versions you need a stock kernel when you update SuperSU. When SuperSU installs it tries to restore a backup it made of your boot.img from the last time SuperSU was installed. Since this was made before auto patching there won't be a backup. Also, in newer versions it detects if your device needs systemless or if it can modify /system. If TWRP hasn't been told to keep system read-only it will likely default to a /system install. So, if you want to keep stock kernel and systemless root there are two things you are going to need:
Stock Kernel: You can actually use the kernel provided for traditional root as a stock kernel for the purpose of these instructions.
Systemless Override: To guarantee that SuperSU gives you the systemless install over /system you need to create a file called ".supersu" with the line "SYSTEMLESS=true" and place it in /data in TWRP before you install (eg. /data/.supersu). Alternatively, you can download this one (extract from the ZIP and place in /data).
When the file is placed in /data flash the boot.img in TWRP and then flash SuperSU. It will make a backup when it installs so don't remove it as it will look for this backup again when you install an updated version.
Note: These are only to tide us over until HTC releases source allowing awesome devs like flar2 to work their kernel magic.
Not checked yet, but is systemless the only way to do it on 6.0 ?
Electronic Punk said:
Not checked yet, but is systemless the only way to do it on 6.0 ?
Click to expand...
Click to collapse
No, you can still do it by modifying /system, but Marshmallow made it so kernels had to be modified as well to allow root. @Chainfire took it a step further, since we already have to modify the boot.img we can modify it a little more and remove the need to alter /system and make it easier to accept OTA updates. The link I put in the OP explains it a little more, but here it is again.
Added root modified kernel for using "traditional" (modifies /system) root to the OP along with link to current Marshmallow compatible SuperSU.
I'm trying to do a systemless root. Just to confirm, I should flash the latest TWRP. Then from there flash the kernel then SuperSU both through TWRP?
mcta said:
I'm trying to do a systemless root. Just to confirm, I should flash the latest TWRP. Then from there flash the kernel then SuperSU both through TWRP?
Click to expand...
Click to collapse
If you still have stock kernel and no root you can just flash the latest SuperSU (v2.65).
If you're systemless already but don't have a backup you need to flash a boot.img that isn't already systemless modified as SuperSU will abort the install.
You can't flash the one in the OP for traditional (modifies /system) root and it will patch that one, but unless your set your /system partition to read-only, it will install using traditional root (this is the case with any unmodified boot.img not just this one because it's modified for traditional root). To make sure SuperSU installs using systemlesss you need to place the mentioned .supersu file in /data/ o make sure system is read-only in twrp. You also want to use latest SuperSU.
Just make sure you don't let TWRP install it's own SuperSU package that it includes. TWRP by default can't detect systemless root installs, so each time you reboot from TWRP it will warn that there is no root access on the device. It is important you make sure to click DO NOT INSTALL.
If you don't want to be bugged with the no root message in TWRP you can download this version which has the incompatible SuperSU package removed disabling the root check.
HAHAHAHAHA!!!!! Silly me...... it was written up there......
mcta said:
I'm trying to do a systemless root. Just to confirm, I should flash the latest TWRP. Then from there flash the kernel then SuperSU both through TWRP?
Click to expand...
Click to collapse
Okay, hopefully this is a stupid question, but I want to be sure before I flash something to boot.
I followed the instructions before the later versions of SuperSU betas came out, so I have the above linked custom boot image, but would like to be able to update to later versions. Can I safely assume that the boot_signed.img file I pulled out of ROM.ZIP in the Developer Edition Marshmallow RUU is the correct "stock" bootloader? Note that I ran the RUU, let it pause on accepting the license, then pulled the ROM.ZIP out of the temp folder to extract the binary.
Hi! Im pretty much new to rooting and I was wondering does the phone have to be S-OFF or S-ON. If it has to be S-OFF, how do you do it?
Thank you for help!

Does anyone have a guide for installing Magisk on Android x86_64 for PC?

As far as I know there is no TWRP for Android x86_64 for PC. How could I ever get Magisk 14 installed?
https://forum.xda-developers.com/apps/magisk/official-magisk-v7-universal-systemless-t3473445
I'm thinking on using it on Bliss which is running Nougat 7.2 x86_64. I really want root but some apps will not work with root.
Magisk manager has an option to install magisk without recovery, of course this means you will need some sort of root solution before hand
Xmaster24 said:
Magisk manager has an option to install magisk without recovery, of course this means you will need some sort of root solution before hand
Click to expand...
Click to collapse
No it doesn't. It means you'll need a copy of your device's boot image and some way to flash it to your device after the Manager has patched it. No root required...
Didgeridoohan said:
No it doesn't. It means you'll need a copy of your device's boot image and some way to flash it to your device after the Manager has patched it. No root required...
Click to expand...
Click to collapse
Well he is talking about a pc which does not use a boot image the same way a normal device does, anyways Bliss rom comes with root.
EDIT: actually now that you mention that I was not aware you could select a boot image to patch in magisk manager, if he does that he can just copy the boot image to wherever Bliss rom stores the emulated boot image
Xmaster24 said:
Well he is talking about a pc which does not use a boot image the same way a normal device does, anyways Bliss rom comes with root
Click to expand...
Click to collapse
I know... So in other words it's probably not gonna happen. Magisk relies entirely on patching the boot image.
My answer to your post was simply to prevent any future misunderstandings for anyone reading it. :good:
Well I think RMXtools or similar is used to mount the .img file and root it with SuperSU for Android x86 for PC. Could this also be done for Magisk?
I would need to know exactly where the files would need to go I guess and also which image to mount for Android x86 for PC
saulin78 said:
Well I think RMXtools or similar is used to mount the .img file and root it with SuperSU for Android x86 for PC. Could this also be done for Magisk?
I would need to know exactly where the files would need to go I guess and also which image to mount for Android x86 for PC
Click to expand...
Click to collapse
And that was made with the system or systemless type of install for SuperSU? Magisk can only be installed systemlessly...
If it's possible, you can probably find the info you need here: https://github.com/topjohnwu/Magisk
Android x86 has no boot partition. It contains kernel binary and initrd image.
Didgeridoohan said:
And that was made with the system or systemless type of install for SuperSU? Magisk can only be installed systemlessly...
If it's possible, you can probably find the info you need here: https://github.com/topjohnwu/Magisk
Click to expand...
Click to collapse
For PC installations of Android x86 you can edit the system and data images with that tool. I believe root is achieved by editing the system partition.
Bliss already comes pre-rooted or without root, depending on which *.iso is used for the installation. I picked the rooted image and tried to uninstall SuperSU which looks like I did successfully, however this app I have still detects that the device has been modified or is rooted it says.
I will install the non-root version today and see if the message goes away. If it does then I know there must still be traces of root on the other image. Now the ideal thing would be to get Magisk somehow installed because then I could hide the root which seems to work for the apps I have tried it on on my Shield Android TV Box.
**Edit**
Well Magisk on Android x86 sure seems possible judging by the posts and screenshots from youling 257
https://groups.google.com/forum/#!s...elevance/android-x86/omGg6QZlEGc/H4_QXjhQBwAJ
However this all seems way too complicated for me.
https://groups.google.com/forum/#!msg/android-x86/311n2ivCLYw/hfIZnqkXBwAJ
I was able to install Magisk V12.0 on Android x86 7.1.2 rc2, using this tools to create a "fake" boot.img using kernel and ramdisk.img files:
https://forum.xda-developers.com/showthread.php?t=2319018
But I had to make small modifications in the install script and magic_mask.sh to bypass some errors and correctly mount system to the magisk folder. Newer versions don't have magic_mask.sh anymore but a binary, so unless you modify the source and compile it yourself I think it won't work. Probably because v12.0 is somewhat old I can't install modules automatically using Magisk Manager tho...
https://forum.xda-developers.com/phoenix-os/phoenix-os-news-qa--development/magisk-15-3-t3735310

Magisk on custom rom

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.

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.

Is there a method to pre install magisk services when building a custom LineageOS ROM?

I'm trying to install Magisk on jetson nano LineageOS official image, but the normal method of patching recovery doesn't work (I receive "unsupported image format"). Also doesn't work to install via recovery.
I think Jetson Nano build uses a different scheme where the bootloader is only modifiable in download mode (https://wiki.lineageos.org/devices/porg/#special-boot-modes). Basically I had to jump a few board pins to be able to change the bootloader. So, while recovery is easy to update, bootloader is a bit more complicated.
But since I'm building my own image to add some extra kernel drivers, I wonder if there's a documented way to preinstall the required magisk services. Theoretically I could modify the build scripts to replace `init` by `magiskinit` at image build time.
Anyone have done something like this before?
*Update*: I just looked that Magisk reports "ramdisk: no", so patching boot image won't work for me. It seems the only way for me would be to embed magisk required binaries directly in the system image during build time.

Categories

Resources