Magisk icon indicating copy to clipboard operation
Magisk copied to clipboard

Nothing installed in Lineage /system/addon.d/ via Magisk app Direct Install + fix_env

Open mdoggydog opened this issue 4 years ago • 98 comments

I installed Magisk by using the "patch boot.img and flash with fastboot" method, since the installation instructions say that using the installer zip via a custom recovery is no longer recommended. On the next LineageOS OTA update, Magisk was not preserved, and I had to manually patch the boot.img and flash with fastboot again.

I discovered that /system/addon.d/99-magisk.sh was never installed, thus the OTA update would have no way to preserve Magisk.

Digging through the code, it appears that /system/addon.d/99-magisk.h is only installed when a Magisk installer zip is used via a custom recovery.

A related problem: even if Magisk is initially installed via installer-zip/custom-recovery, it appears that updating Magisk via the MagiskManager app will never update an existing /system/addon.d/99-magisk.sh either.

This issue is basically a duplicate of #3782, which I think got prematurely closed because I did not explain the problem well enough the first time. Please see my last comment in #3782 for more analysis of this problem.

mdoggydog avatar Feb 04 '21 21:02 mdoggydog

It's supposed to install at some point via the app Direct Install too: https://github.com/topjohnwu/Magisk/blob/cd96454886852917a6fcbe1e4da4246e2aaffac6/app/src/main/java/com/topjohnwu/magisk/core/tasks/MagiskInstaller.kt#L133-L134

There was a plan to remove the unneeded installer code duplication and have everything run and maintained in one place via the shell scripts, but I'm not sure where that's at now.

osm0sis avatar Feb 05 '21 13:02 osm0sis

Yep... all the bits are there. This probably needs just a one- or two-line fix MagiskInstaller.kt, along the lines of cp /data/adb/addon.d.sh /system/addon.d/99-magisk.sh spelled the correct way (well, after testing if the /system/addon.d/ directory exists). But maybe there is some tricky subtlety involving security contexts or file ownership or something; this android system-level stuff is all new to me.

Half of the lines of code in https://github.com/topjohnwu/Magisk/blob/b6643b7bfcb05b81fc10dc786bc7ad073e581d69/scripts/flash_script.sh#L78-L85 are just ensuring that the target directory exists and is writable; I don't know if the writeability is an issue outside of the recovery environment.

mdoggydog avatar Feb 10 '21 06:02 mdoggydog

So looks like this was intentional. John said "I do not want to involve system rw at anytime during boot. This just opens up a whole can of worms..."

I won't close this as #wontfix since he may still change his mind. It would just need to use Magisk's own system mirror and rw it if the addon.d directory exists. 🤞

osm0sis avatar Feb 15 '21 14:02 osm0sis

I'm sorry if I'm missing something, but I just don't understand that comment in the context of this bug report, which is about install-time not boot-time. The essential core of this issue is:

  • If your device's OS has a /system/addon.d/ directory, then:
    • If Magisk is installed via installer .zip in recovery, then 99-magisk.sh is installed.
    • If Magisk is installed via Magisk app (MagiskInstaller.kt), then 99-magisk.sh is not installed.

That means that some devices out there are getting 99-magisk.sh and some are not, and it only depends on how the user decided to install Magisk (and in neither case does this installation happen at boot time).

How does "system rw at anytime during boot" come into this?

mdoggydog avatar Feb 16 '21 19:02 mdoggydog

(To rephrase again: logically, either 99-magisk.sh should be installed, or it shouldn't, so either MagiskInstaller.kt has a bug, or the .zip installer has a bug. And people installing via the .zip do not seem to be complaining....)

mdoggydog avatar Feb 16 '21 19:02 mdoggydog

He means "while booted", hopefully that clears up the context for you.

osm0sis avatar Feb 16 '21 19:02 osm0sis

Ohhhhhhh! Yes, that clears it up a lot! Thank you! I now understand why it is the way it is right now.

It would be really nice if this difference between the two installation methods was mentioned in the installation documentation (https://topjohnwu.github.io/Magisk/install.html), because it is a pretty significant difference in behavior for a ROM that supports addon.d. One way, Magisk magically survives future OTA updates; the other way, the user has to manually intervene before the next reboot....

(In any case, at least the next confused schmuck like me that is trying to figure out what is going on will have this bug report to stumble upon. :^))

mdoggydog avatar Feb 16 '21 20:02 mdoggydog

Could this issue appear as well when updating magisk through the app, after having initially installed via zip?

And is the only result that Magisk is not installed after the update?

Context: Me and other users of my device (beryllium) recently started getting bootloops after each system update. Reflashing the same system update (1), opengapps (2) and Magisk zip (3) fixes it, I'm trying to rule out Magisk.

I'm thinking maybe we were getting the bootloops because of an outdated 99-magisk.sh, since it was never updated during magisk update via magiskmanager.

Tremolo4 avatar Feb 23 '21 13:02 Tremolo4

please re-open issue #3908 , I think it's different issue with this.

twu2 avatar Feb 24 '21 15:02 twu2

Hi. Just reporting that the survival script worked through manual LineageOS zip flashing after a fresh install of Magisk 22. Previously since several weeks (I think maybe 5-6) ago the survival script had stopped working on my device, even after uninstalling and re-flashing Magisk's latest 21. LineageOS version is 17.1.

outloudvi avatar Mar 01 '21 08:03 outloudvi

I think I'm also seeing this on LOS: https://github.com/topjohnwu/Magisk/issues/4394 Magisk doesn't install on LOS 18.1 and 17.1 unless an old zip is used.

ElCoyote27 avatar May 29 '21 20:05 ElCoyote27

Digging through the code, it appears that /system/addon.d/99-magisk.h is only installed when a Magisk installer zip is used via a custom recovery.

But I did install Magisk by flashing the ZIP (even though it's reported as not being supported, however the boot patching is just too much of a palaver IMHO -- #4172) from TWRP on my Oneplus 6 (A/B device) running LineageOS 18.1 and Magisk did not survive the OTA update.

Given that I have an A/B device and OTA updating LineageOS on that also updates the recovery to use the LineageOS recovery, can the Magisk apk->zip be flashed with Lineage recovery? I'm not at all familiar with Lineage recovery and have always used TWRP.

brianjmurrell avatar Jun 08 '21 13:06 brianjmurrell

addon.d-v2 is only guaranteed to work from a booted OTA. Lineage intentionally didn't want it working in recovery and TWRP only has it working in the _9 branch with some hacks I suggested currently.

osm0sis avatar Jun 08 '21 16:06 osm0sis

@osm0sis I'm afraid I'm not up-to-speed enough to know what all of that means.

What are my options for installing Magisk on my LineageOS 18.1 flashed Oneplus6 (A/B device)? Only TWRP and Patching Images?

Will either survive a LineageOS Updater OTA update?

brianjmurrell avatar Jun 08 '21 19:06 brianjmurrell

For Magisk addon.d script to install it must currently be installed from recovery, then if you have an A/B device (i.e. addon.d-v2) then the only way to be sure the addon.d script runs is to do the OTA through the system settings updater app.

osm0sis avatar Jun 08 '21 20:06 osm0sis

@osm0sis That's what I did the last time. Almost. :-) However I used TWRP recovery instead of Lineage Recovery. Are you saying that if I flash with Lineage Recovery (i.e. adb sideload Magisk-v23.0.zip) it will survive future OTA updates?

brianjmurrell avatar Jun 08 '21 20:06 brianjmurrell

Hmm I believe either recovery should work. It can still install the addon.d script to /system in Lineage Recovery last time I checked.

But the Magisk apk must be flashed in recovery for the addon.d script to be installed. If it's not working after that then there's something else weird going on, separate from this issue.

osm0sis avatar Jun 08 '21 20:06 osm0sis

Non A/B device (Xiaomi Mi 5 - gemini) and unsure how relevant my case is, my recent experience is that starting from Magisk flashed through recovery (following the official supported install procedure), it survives through OTA with TWRP as recovery, but not through OTA with LOS as recovery.

qouoq avatar Jun 08 '21 20:06 qouoq

So I did install via Lineage Recovery and adb sideload Magisk-v23.0.zip and while flashing it did do all sorts of stuff and said it was successful at the end but looking in the Magisk app on the device it says "Installed N/A" but also says "A/B No" but we know that's not true for a Oneplus 6.

In the Magisk app though, Check SafetyNet does seem to pass but Google Pay is still saying my device is not supported even after a force stop, clear cache, clear storage. Google Pay was working the last time I flashed with TWRP on LineageOS 18.1.

brianjmurrell avatar Jun 08 '21 20:06 brianjmurrell

My recent (a few hours) experience is that 22.x and 23.x do not survive an OTA update of LOS. In order to do that, I had to wipe and downgrade to 21.4 without updating Magisk after that.

ElCoyote27 avatar Jun 08 '21 21:06 ElCoyote27

on my klte (non-a/b), v23 (installed via TWRP) survives LOS 18.1 OTA updates.

ossilator avatar Jun 08 '21 22:06 ossilator

Not sure why regular addon.d (i.e. A-only devices) wouldn't work in LOS Recovery, but, again, that's a different issue from this.

Edit: Oh wait, I know why, LOS Recovery doesn't support decrypting /data. 😛

Well known if you check the logs: https://github.com/topjohnwu/Magisk/blob/master/scripts/addon.d.sh#L39-L40

So yeah probably TWRP only for A-only too.

osm0sis avatar Jun 08 '21 22:06 osm0sis

@osm0sis I'm afraid I'm not up-to-speed enough to know what all of that means.

What are my options for installing Magisk on my LineageOS 18.1 flashed Oneplus6 (A/B device)? Only TWRP and Patching Images?

Will either survive a LineageOS Updater OTA update?

Normally no but you have 3 options (ranked from easiest to hardest):

  1. open magisk manager before starting lineage os updater (important), minimize magisk manager and run lineage os updater do not reboot when prompted, go back to magisk manager click install magisk and click install after OTA and reboot when prompted (magisk should be present along with your modules and settings)

  2. Reflash the magisk apk (rename to APK to zip) via lineage recovery (same process of flashing gapps) or flash with TWRP

  1. Download and extract the boot.img from lineage os repatch with magisk manager, enter fast boot and flash (this is the most time consuming method and I personally use it as a last resort for updates).

All three methods will retain magisk preferences and modules. Hope this helps (tested lineage os 18.1 OnePlus 8)

Additional recourses:

https://topjohnwu.github.io/Magisk/install.html

Rihcus avatar Jun 14 '21 22:06 Rihcus

Normally no

That's a pity.

  1. open magisk manager before starting lineage os updater (important), minimize magisk manager and run lineage os updater do not reboot when prompted, go back to magisk manager click install magisk and click install after OTA and reboot when prompted (magisk should be present along with your modules and settings)

What do you mean exactly by "magisk should be present along with your modules and settings"? Present where?

brianjmurrell avatar Jun 20 '21 02:06 brianjmurrell

Facing same issue, I need to repeatedly pull boot.img patch and flash after Lineage OS OTA each week. Isn't anything possible to do like previous methods where we don't need to re-path boot image after each update?

2shrestha22 avatar Jun 21 '21 00:06 2shrestha22

open magisk manager before starting lineage os updater (important), minimize magisk manager and run lineage os updater do not reboot when prompted, go back to magisk manager click install magisk and click install after OTA and reboot when prompted (magisk should be present along with your modules and settings)

@Rihcus I didn't see any options like Install after OTA in recent Magisk Manager version.

2shrestha22 avatar Jun 21 '21 01:06 2shrestha22

open magisk manager before starting lineage os updater (important), minimize magisk manager and run lineage os updater do not reboot when prompted, go back to magisk manager click install magisk and click install after OTA and reboot when prompted (magisk should be present along with your modules and settings)

@Rihcus I didn't see any options like Install after OTA in recent Magisk Manager version.

https://i.imgur.com/FPznfOU.png

https://i.imgur.com/wj2RHvd.jpg

Are you using the latest build of magisk manager and magisk? Also does your device support A/B?

Rihcus avatar Jun 21 '21 04:06 Rihcus

Normally no

That's a pity.

  1. open magisk manager before starting lineage os updater (important), minimize magisk manager and run lineage os updater do not reboot when prompted, go back to magisk manager click install magisk and click install after OTA and reboot when prompted (magisk should be present along with your modules and settings)

What do you mean exactly by "magisk should be present along with your modules and settings"? Present where?

Basically all your settings in magisk will remain intact as will any other add-ons (in magisk manager and magisk hide).

In other words you won't have to set up magisk every time from scratch when updating with install after OTA (sorry if not clear)

Rihcus avatar Jun 21 '21 04:06 Rihcus

What do you mean exactly by "magisk should be present along with your modules and settings"? Present where?

Basically all your settings in magisk will remain intact as will any other add-ons (in magisk manager and magisk hide).

Understood. But that doesn't answer the actual question asked, which I left quoted above. Does "present" mean the manager app is installed, or does it mean the .apk is available somewhere? Is it left .apk or should it be renamed .zip?

In other words you won't have to set up magisk every time from scratch when updating with install after OTA (sorry if not clear)

Again, also understood. What is not understood is what the phrasing "magisk should be present along with your modules and settings"? Present where and in what form?

brianjmurrell avatar Jun 21 '21 11:06 brianjmurrell

What do you mean exactly by "magisk should be present along with your modules and settings"? Present where?

Basically all your settings in magisk will remain intact as will any other add-ons (in magisk manager and magisk hide).

Understood. But that doesn't answer the actual question asked, which I left quoted above. Does "present" mean the manager app is installed, or does it mean the .apk is available somewhere? Is it left .apk or should it be renamed .zip?

In other words you won't have to set up magisk every time from scratch when updating with install after OTA (sorry if not clear)

Again, also understood. What is not understood is what the phrasing "magisk should be present along with your modules and settings"? Present where and in what form?

By magisk I meant both the magisk manager app and the modified boot.img (the part which magisk manager uses to allow root access to other apps and magisk modules) will remain installed. You will not need to reinstall the magisk manager APK knor re modify the boot.img (whether that be through flashing the magisk managerAPK as . zip or flashing the boot.img via fast boot).

Infact all install after OTA does is reapply the modified boot.img which was overwriten by lineage OTA updater.

Rihcus avatar Jun 21 '21 16:06 Rihcus