yashsingh1/xdaforums huggingface dataset:
[Magisk] pndwal:
Just tried patching unpatched/stock boot.img on Xiaomi RN8T and can confirm same issue:

So seems the original fix that adds basic ramdisk CPIO inc. magiskinit for our devices (added in Feb 2019, https://github.com/topjohnwu/Magisk/commit/e72c6685edf81706617a3444575c4500b9b8fe6c ) is broken w/ 26103...

However looks like this fix

for A13, A14 GKIs might also fix our issue...

... When the fix for failing A13 GKI patching was made, IIRC incompatible compression format used when repacking CPIO etc was responsible... Seems CPIO created from scratch was also needed for these devices, but I don't fully understand why since late Pixels use boot into initramfs and use recovery ramdisk in /boot (already exists) for both booting system normally (officially called USES_RECOVERY_AS_BOOT) and for Magisk patching, so I'm not sure how 'does not exist' can apply to these devices. 🤔

Anyway, the same issue has now shown up again in Pixel A14 betas and is apparently fixed...

If the fix works also works for our legacy SAR A-only (original create-CPIO-from-scratch for Magisk patching case), this CI build should work:

Fix backup fails when ramdisk does not exist Magisk Build #3339: Pull request #7111 synchronize by yujincheng08

Interesting... Trying to think how this could be related, but, unless you inadvertently tried direct install w/ Recovery mode selected (which would mess with recovery ramdisk in /recovery where TWRP resides on this device), there's no obvious connection AFAICS... And especially as you already reflashed recovery... Also I've forgotten how TWRP configuration works / where config data resides, and how it accesses system for password/pattern keys for decryption, but I know decryption is system dependant...

Seems to me that this anomaly, which is common enough apparently, may have been triggered by this misadventure, but the fix may have nothing to do with the Magisk issue (ie failure to add ramdisk CPIO)...

Some with the issue have fixed variously by repairing data partition (may be possible without wiping it?), by dirty flashing ROM again, by fastboot flashing ROM/TWRP, by reflashing stock recovery then TWRP recovery, by flashing an alternative custom recovery (some had issue with TWRP but not with 🦊 or red wolf), by mounting then choosing decrypt data, and so forth.

In short, decryption FBE data in TWRP seems fickle/prone to breaking with various causes/triggers... But I know which of the above fixes I'd try first... 😜 PW
[Magisk] DaOldMan:
Well I will try to see Magisk-Debug. The errors in logcat involve some hard to understand errors that end crashing a main library.,

The dev is interested as the dev of the rom is ME :-) . But I can't remember if I changed anything in the code to make Magisk pass Safetynet in the older version that may be not compatible now.

Cheers.
[Magisk] DaOldMan:
Yes I ment this bug in the latest Canary where I can't use direct install to patch boot.img. And yes, I still call it old school kernel which is what boot.img mostly contains (unless you have also recovery packed in).

So I patched boot.img manualy and then flashed it in twrp, but as I said I still can't use denylist at all.

Tnx mate.
[Magisk] pndwal:
It's on main page under Downloads... Devs will only accept issues with logs from latest Debug (linked); Debug is synced with Canary, but the latter is now built as release... Logs in debug builds are verbose...

Haha... Then you've certainly got more clues than me. 😜... But the Devs I meant were Magisk Devs of course!... Hope you submit comments; might help...

Welcome. PW
[Magisk] pndwal:
Yeah, I understood you meant 'patched boot image' rather than 'kernel', specifically ramdisk in /boot... But technically Magisk doesn't (generally at least) touch the kernel; it patches ramdisk with magiskinit... Ramdisk and kernel are distinct parts of a boot image...

In latest devices launched w/ Android 13+, GKI means that kernel is in boot.img but generic ramdisk is seperated out to init_boot.img, so kernel clearly cannot be patched as Magisk now necessarily patches init_boot.img. 🤪 PW
[Magisk] DaOldMan:
Kernel can't be patched as it's pre-compiled and device specific. So it would be very complicate to hex-patch them on the fly (when each is totaly different). On the oposite the boot init is a text file. Which is easely patched/changed. You need to unpack it, repack and reflash. This is how most things are done I guess.

Cheers.
[Magisk] pndwal:
Yup... Most things Magisk...

But new KernelSU is becoming increasingly popular...

- https://kernelsu.org/

- https://github.com/tiann/KernelSU

Nb modules run, Zygisk on KernelSU is available:

https://github.com/Dr-TSNG/ZygiskOnKernelSU

and Shamiko (root hiding) is also now compatible... 👀 PW
[Magisk] zgfg:
Boot.IMG is binary image, not text. That one must be patched
[Magisk] DaOldMan:
Wrong (well partially). boot.img is indeed a binary image file. But you can unpack it and get the Ramdisk with it's text files to patch.
[Magisk] zgfg:
At the end of the day you need patched boot image (not just patched Ramdisk) to flash it by Fastboot (Fastboot does not flash Ramdisk alone)

Also, if using the Magisk provided script (as Magisk does when patching):

/data/adb/magisk/boot_patch.sh

then the usage is:

boot_patch.sh <bootimage>

Internally, it unpacks boot.img to obtain Ramdisk and to patch it, but at the end it repacks the patched binary boot IMG:

/data/adb/magisk/magiskboot <bootimage>

Hence ok (wording), you do internally patch (textual) Ramdisk, but for installing Magisk you indeed need the whole binary boot .img

From another da old man
[Magisk] pndwal:
But he didn't mention boot.img!

Of course he knows all that...

We were simply discussing what is patched inside boot image, which is ramdisk, not kernel in the case of Magisk... He said boot init (not boot.img) in ramdisk is easy to alter/patch as opposed to anything in kernel which will be more difficult.

And it was only for technical clarity since many (traditionally?) refer to whole boot image as kernel... 👀 PW
[Magisk] zgfg:
If you have the full log, please (re)open/update the issue on GitHub about "Failed to process cpio" for arm64-v8a, Ramdisk No case

Regarding to TWRP:

There is only twrp-3.7.0_9-0-davinci.img to download and flash - therefore re-installing TWRP did not help since something must be scr*-up on /data (directory unencrypted (?))

However, as mentioned, only TWRP now does not attempt to decrypt as it should be (screenshots), ROM still boots properly asking for the unlock pin hence I doubt that dirty flash would help (to TWRP). Maybe I will try just to be 100%

Since a week ago I had Factory reset with my daily driver, I'm not ready to do it now with his spare phone-double

Edit:

I will try tomorrow to disable unlock pin and/or to change it to pattern - tried all three combo but with no success to fix TWRP
[Magisk] ipdev:
As pndwal (and others) mentioned.

Newer devices, patching the boot.img will not work. 😉

We have to patch one of the other boot images.

Currently it is init_boot on newer Pixel(s).

I am not sure of other devices.

Some might need to patch vendor_boot? :unsure:​

Cheers. :cowboy:

PS.

Spoiler content hidden.

Spoiler content hidden.
[Magisk] pndwal:
Guess you mean this:

https://github.com/topjohnwu/Magisk/issues/7109

still open one?... I'll probably add another issue soon just to cover this soon as I can as description doesn't really fit... Existing fix title seems to cover it though, when symptoms are considered...

Yup, I have TWRP only on unencrypted Mi Pad 4 tablet as Devs last unofficial LOS didn't encrypt, otherwise I might have tested a bit, but guess there's an issue getting/seeing encryption keys... I recall I put something on FBE keys etc here:

https://xdaforums.com/t/magisk-general-support-discussion.3432382/post-87456041

... I don't know TWRP mechanism, but if you do dirty flash incl. stock recovery, then install TWRP again my guess is that that (actually swapping recovery then swapping back) is what may be needed to initialise FBE encryption key calling or setting... Just a guess, or I'm stumped...

Best clue may be just to restore images (remove Magisk) and install TWRP again to see if latest Magisk is in fact causing/affecting this... Just guessing though really... PW
[Magisk] pndwal:
FWIW, I recall even Magisk Devs tried/speculated about patching vendor_boot since it does (always?) contain vendor ramdisks, however I believe this never worked...

Vendor ramdisks are not genetic ramdisk needed for Magisk... Generally that's only found in boot.img or lately in init_boot.img, but I recall Huawei did also use alternatively named boot partitions (w/ patchable ramdisk) in the past, and there may be other obscure boot partitions too. PW
[Magisk] zgfg:
Restoring images - I tried with stock boot.img and it didn't help

As I'm saying, something very messy was done (I don't see any other cause than Canary v26103) that affected TWRP

And again, TWRP by itself is good. it worked/decrypted Storage for almost two years until the last week
[Magisk] pndwal:
So if fully restored images and then TWRP, it seems it's either not Magisk or Magisk changed something in /data to me... Not sure what in /data/adb would affect TWRP seeing encrypted data, or what else Magisk might change. 🤔 Mystery...

I'd try flashing stock recovery or complete ROM before trying TWRP again however... PW
[Magisk] pndwal:
Done...

Patching fails with stock boot.img on legacy SAR A-only devices #7123

Feel free to add comments there... PW
[Magisk] zgfg:
I never said that I fully restored images

I didn't (yet) dirty reflash ROM, I only flashed TWRP to recovery.img - but that cannot fix anything if messed up on Data partition about the Storage encryption params

And cannot restore backup from TWRP, neither I have recent Data backup that I would like to use. And not ready for Factory reset

So, thanks for the care but no need to discuss further
[Magisk] pndwal:
Ah, ok... Of course I should have said 'So if fully restored images other than /recovery...' 🤷

(Guessing you don't flash /vbmeta or other.)

... So typical response from a Magisk dev.

At least it confirms what the fix should be.

So, thanks for the care but no need to discuss further. PW
[Magisk] mad4some:
So I have a samsung tablet (tab s6) that I have flashed lineage 20 on and also flashing magisk zip. After installing the magisk apk and opening I see this prompt (pic). If I let it do it's thing then the tablet will bootloop and I have to start all over. The reason 25.2 is showing is because I tried 26.1 last time and figured I would change to the older reliable version to see if it fixed my problem. Anyone have an idea what is going wrong? Thanks
[Magisk] J.Michael:
Is this the first time you have installed Magisk on this device?

If you had an earlier version of Magisk installed, and any Magisk modules, one of the old moduled could be incompatible with the newer Magisk.

You say you "flashed" magisk.zip. Does that mean you installed TWRP? Or does Lineage come with a recovery capable of flashing zip files?

Did you ever use Odin? Is Lineage distributed as a set of tar files?
[Magisk] mad4some:
Yeah I could have offered more details, and I know better :sneaky: . I've only tried 26.1 and 25.2 but the tablet was formatted and fully wiped between those times. There is TWRP available for this tablet and it is 3.7.0 and I flashed a GSI image thru TWRP to the system partition. No modules used except the systemless hosts offered within the app. The bootloop happened when I had tried 26.1 and now that I have the rom up and running using 25.2 I have not allowed the app to do the additional setup and reboot for fear it will bootloop again. Also need to mention that the tablet is rooted properly even though I am still getting that prompt every time I open it.
[Magisk] pndwal:
25200 still had this major regression:

Zygisk kills root regression #6095... Zygisk caused root loss but not bootloop AFAIK...

Fix was first built in 25202...

Many fixes since... Personally, I'd be trying latest Canary considering all the major refactoring going on... 🤠 PW
[Magisk] Arese75:
Hi everyone, I'm trying to root a Xiaomi Mi9. Phone is stock, I just unlocked the bootloader just now and now I'm a bit confused with how to install Magisk.

I downloaded the latest TWRP, Android SDK, fastboot.zip and universal ADB drivers.

I think I know how to install TWRP but then when it comes to Magisk I'm confused.

This page more specifically confuses me https://topjohnwu.github.io/Magisk/install.html

The tutorial I'm looking at doesn't mention ramdisk, vbmeta partitions etc.

The tutorial only says to install TWRP, then download magisk, move it to the phone's storage and install and the magisk.zip file through TWRP.

Can someone clarify for me what those VBmeta and ramdisk things are and what I should do?

Thanks
[Magisk] J.Michael:
You do not need to install TWRP in order to install Magisk.

Having installed TWRP, you do not need to use TWRP to install Magisk.

The reference to "vbmeta" is as a partition that requires special attention on some devices. You need to read a lot to determine whether your device is one of the special ones.

"ramdisk" is something that might force a special approach to installing Magisk. It might preclude having TWRP installed. The name of your device makes me think it's at least in the same family as that used by @pndwal and @zgfg. If it is, don't worry about ramdisk, they've done very well with the standard installation.

If you have collected all the necessary pieces to get "adb" and "fastboot" running on your Windows PC, you might be able to use @badabing2003's PixelFlasher, if only in its "dry run" mode so you can see the steps laid out for you.
[Magisk] zgfg:
Don't need to worry about VBMeta. Ignore the VB Meta story

Since it's an old phone with the available TWRP, you can download and flash Magisk app (on the newer TWRP even without the need to rename the apk to zip) and reboot

Otherwise, take your ROM OTA zip, extract boot.img and patch from Magisk app (it will show Ramdisk No - just ignore on Xiaomi - do not tick Recovery option as you can find in some guides) and flash by Fastboot to Boot partition (old Mi 9 does have Boot and Recovery options separated, no A/B, etc, all simple) or flash as the image to Boot partition from TWRP

Instead of extracting boot.img from OTA ROM Zip (you can find packages for various Xiaomi phones, localizations, MIUI versions on Xiaomi related sites but out of scope here - you MUST take the ROM zip corresponding to your currently installed ROM, wrong boot.img will brick the phone), you can make a backup of your Boot partition from TWRP and use that boot.emmc.win backup file (I think it's the name TWRP will give it) instead of patching the boot img file

Suggesting to use latest official TWRP from TWRP.me

Also, Magisk Stable is named "stable' but Canary is always newer with some newer fixes (and unfortunately newer bugs)

Eg, with latest Canary 26103, it will likely fail to patch your original boot img for your phone (discussed last week in some posts above, not specially for your Mi 9 but eg for my Mi 9T), but Canary 26102 will correctly patch your boot img. Months old Magisk Stable will also correctly patch but it might have some other bugs related ro certain modules (maybe you don't care about at the time), and once you install Stable you can easily upgrade to Canary (and for that you will avoid that problem with patching the original boot img with Canary 26103 by simply taking the Direct update option)
[Magisk] Arese75:
Hi @zgfg, thanks for taking the time to write a detailed answer.

That's a lot of information so bear with me.

If I understand correctly you've given me multiple methods to install Magisk.

Do you think we could focus on 1 method, the easiest to make things easier for me? By the look of it, the first method you mentioned was to install the latest TWRP version and then flash Magisk app and reboot.

Using TWRP seems easier than having to go and get my rom image file and patch etc.

So if I was to use TWRP, can you tell me if the below steps are the right way to proceed?

I downloaded the latest TWRP available for the mi 9 here https://twrp.me/xiaomi/xiaomimi9.html

And I'm also following the installation instructions (fastboot mode) displayed on the TWRP site

- dl Android SDK platform tools

- dl universal ADB drivers

- Run command from platform tools folder

- run ADB command to reboot in fastboot and then flash the twrp image file.

- fastboot reboot and hold down on my phone power + volume down to boot straight into TWRP so my stock rom doesn't overwrite TWRP.

Then from there I should do the following:

- download Magisk.zip from github

Can you confirm I should download the zip file and not the APK because I'm installing via TWRP correct?

- Move the downloaded zip file from my PC to the phone's storage

- Use the install menu from TWRP to install MAgisk zip file

Do the above steps seem correct to you?

Thank you again

EDIT: Actually in your message, you said that on the new TWRP I don't need to rename the .apk to .zip, so I just download Magisk apk file and I will be able to flash it as is with the latest TWRP?
[Magisk] zgfg:
I see now that for your Cepheus, TWRP.me has no v3.7.0 but a few years old TWRP v3.5.2

What are your MIUI and Android versions (screenshot from your Settings / My phone) - to compare against the TWRP (your official MIUI is probably also old)

There are might be unofficial newer TWRP, SHRP or OrangeFox custom recoveries for your phone - you can check what the other Cepheus users reccomend/use:

https://xdaforums.com/c/xiaomi-mi-9.8588/

If you have A10 that old TWRP might be good (and better you don't use custom recoveries for A11, A12 and specially A13), but for A11 or A12 (if you have) you may need a newer custom recovery

Btw, you first need to unlock Bootloader on your phone. There are lot of how-to guides for Xiaomi on the Net, you will need to wait 7 days that Xiaomi allows you since you send a request
[Magisk] Arese75:
Yes latest TWRP for my phone is twrp-3.5.2_9-0-cepheus

I just unlocked bootloader earlier so I'm good to go

What seems to be the issue with twrp 3.5.2? Can't install the Magisk.apk file? I will need to rename it to .zip? It's not a major isssue

I can see on the Mi9 forum an unofficial TWRP 3.4.0-10

https://xdaforums.com/t/recovery-3-...official-twrp-for-xiaomi-mi-9-stable.3905825/

By A10 you mean Android 10 right? In that case it seems I'm running A11. So you're saying I cannot flash the old TWRP 3.5.2?

Well luckily You told me that, haven't seen this mentioned anywhere
[Magisk] J.Michael:
The zip you indicated in the screenshot is the Magisk source -- it is not an alternative to the apk; it is not what is meant by a zip that can be flashed in TWRP. If you end up with a TWRP that will not flash an apk, then you make a copy of magisk.apk and change the copy's name to magisk.zip, then hand *that* to TWRP.

Instead of lining up every step before doing anything, I would suggest doing one thing and seeing if that works.

If you want to use TWRP to install Magisk, start by installing TWRP, and see if it works.

Come back when you can report that TWRP has been installed. (Maybe ask somebody if you need some "disabler" as part of installing an old TWRP on an old phone.)
[Magisk] Arese75:
Ok that's good to know with regards to the zip file I indicated above.

Ok so how it works is I download the .apk file, rename the extension to .zip and feed it to TWRP

That's what I suggested above, so it's not a big deal if I flash TWRP 3.5.2 correct?

I won't be able to flash the apk file, I'll rename it to .zip and then flash Magisk right?

If having to rename the filemame is the only "downside" to using TWRP 3.5.2, I can live with that
[Magisk] Arese75:
Done, I've installed TWRP 3.5.2

After flash complete I typed commanded "fastboot reboot"

Phone reboots and I pressed and hold down volune up + power and it booted up in TWRP

Any idea if I should select keep read only?

Which option to avoid TWRP being replaced by the stock rom?

Now the most important part, i've downloaded magisk-v26.1.apk

Should I simply rename the filename to magisk-v26.zip?

Move the file to my phone's storage and flash the zip file with TWRP?
[Magisk] jons99:
tik the never show me this again then swipe to allow modification then flash the magisk apk in twrp then boot to system and do a direct install from the magisk app and your done
[Magisk] u_no_fr:
How do you find mi 9 in TWRP site because I do not see it 😵‍💫 I was on Redmi note 4x and would like to install TWRP on my new Redmi note 11 Pro 5G
[Magisk] J.Michael:
When TWRP says "system", does it mean the whole device, or just the "system" partition?

I would have thought @Arese75 should choose "do not modify system". He can change his mind later, but I've read of cases where just mounting a read-only partition read-write one time permanently poisons something.
[Magisk] zgfg:
Try both with System read-onky or not (you must play yourself 😁)

That part shall not be important for installing Magisk (installation will need to write to Boot and Data partitions, not to System)

But TWRP must (then - or even before) ask you for unlock pin. You have to provide your pin you use to unlock the screen on Android

Only with that, TWRP will be able to temporarily decrypt Data and Internal memory

If it doesn't ask, actually if you then open eg Download folder (or other folders on Internal memory) and you see scrambled file names, then no use

Either you didn't provide correct pin (play with, change and/or disable pin in Android and try again in TWRP, try.even with the unlock pattern instead)

Or (if you cannot make TWRP to properly read Internal memory), them that TWRP is not good for your A11 (that's what distinguishes custom recoveries, are they able to decrypt Data and Int memory for the particular Android version - Google always makes new changes and that requires TWRP developers to break and port)

In that case you would not be able to use that TWRP:

- it will not find the Magisk renamed zip (although, you could put the Magisk zip file to USB stick, it's not encrypted and TWRP will read from there, hence maybe will work that way)

In that case, search for another TWRP for your device that supports Storage decryption for A11

Or be ready to patch and flash the boot.img file.

You could still use TWRP to backup Boot partition but you must use USB stick to save (since your TWRP cannot decrypt Internal memory) or SD card in the unused SIM slot (if your phone supports)
[Magisk] zgfg:
He CANNOT Direct install as long as not rooted yet!

Magisk app needs root to be allowed to flash the patched boot img (that's what Direct install basically does)
[Magisk] jons99:
he'll be half rooted after he flash the magisk apk in twrp and after a direct install he'll be fully rooted
[Magisk] jons99:
means the whole device