Magisk 20.4 can't be uninstalled completely in LOS 17

Created on 15 Jun 2020  路  13Comments  路  Source: topjohnwu/Magisk

After installing Magisk 2.40, I (who likes to play around with stuff) wanted to remove it again, via in-app Uninstaller. Now, when I go back to recovery (LOS 17.1 recovery) and update the firmware or opengapps this happens during installation:

************************
Magisk addon.d failed 
************************

! Cannot find magisk binaries - was data wiped or not decrypted?
! Reflash OTA from decrypted recovery or reflash Magisk

Tested this on 2 phones both running latest LOS 17.1 firmware:

  1. Samsung Galaxy S4 (jfltexx) (crypted, requires PIN to start)
  2. Motorola Moto X Play (lux) (crypted, requires PIN to start)

The provided uninstaller-zip (Magisk-uninstaller-20200323.zip) throws an error as well:

*******************
Magisk Uninstaller
*******************
! unable to mount partitions
- unmounting partitions
E:Error in /sideload/package.zip (status 1)

I'm pretty sure all of this is not intended behaviour. When uninstalling software, all of it should get removed, right? So, what to do now? Thanks for your help in advance.

confirmed

All 13 comments

Should work: https://github.com/topjohnwu/Magisk/blob/master/scripts/magisk_uninstaller.sh#L146-L149

Not sure why it wouldn't be able to mount system rw where the installer was clearly able to to put the addon.d script there in the first place.

I'll investigate.

Should work: https://github.com/topjohnwu/Magisk/blob/master/scripts/magisk_uninstaller.sh#L146-L149

Not sure why it wouldn't be able to mount system rw where the installer was clearly able to to put the addon.d script there in the first place.

That's why I wondered as well. Makes no sense IMHO to be able to mount/install but not to mount/remove.

In SAR (System as root) Recovery addon.d is not /system/addon.d/99-magisk.sh but /system/system/addon.d/99-magisk.sh at least it's the case on my TWRP Recovery since root folder is occuped by the recovery ramdisk.

Maybe adding this could help fix Uninstall on SAR via recovery.

if [ -f /system/system/addon.d/99-magisk.sh ]; then
  mount -o rw,remount /system
  rm -f /system/system/addon.d/99-magisk.sh
fi

Just took a look and noticed the scripts are indeed located inside /system/addon.d/ (Both phones):

/system/addon.d/
50-lineage.sh
70-gapps.sh
99-magisk.sh

So the above solution might not help a lot in this case (I suppose). This makes it not easier to track down what's causing this.

No no, mount_partitions from util_functions.sh sets everything up with /system_root and a bind mount to /system so everything should be fine with that.

At this point sounds like some LOS Recovery thing to work around. It would likely work fine in TWRP.

Okay, loaded twrp.img via fastboot boot, issued adb sideload of the magisk-uninstaller.zip - works. One step further, at least.

Maybe it has something to do with encryption?

So the easiest way to uninstall magisk is basically to download the .zip from the los page and install it as update. I had to do this quite often - thats how often i broke my phone w/ root lol
Did it via los recovery btw. cant recommend twrp, even though it has far more uses...

Okay, loaded twrp.img via fastboot boot, issued adb sideload of the magisk-uninstaller.zip - works. One step further, at least.

Maybe it has something to do with encryption?

Ah, yup! LOS Recovery doesn't decrypt, so the installer can't do everything it needs to and aborts early: https://github.com/topjohnwu/Magisk/blob/master/scripts/magisk_uninstaller.sh#L38

So it is intentional, and the issue is more on LOS' side than Magisk's, but perhaps it would be better not to abort that early, and instead let it abort later at https://github.com/topjohnwu/Magisk/blob/master/scripts/magisk_uninstaller.sh#L50 where it will show the more accurate and detailed "! Cannot access /data, please uninstall with Magisk Manager"

Okay, loaded twrp.img via fastboot boot, issued adb sideload of the magisk-uninstaller.zip - works. One step further, at least.
Maybe it has something to do with encryption?

Ah, yup! LOS Recovery doesn't decrypt, so the installer can't do everything it needs to and aborts early: https://github.com/topjohnwu/Magisk/blob/master/scripts/magisk_uninstaller.sh#L38

So it is intentional, and the issue is more on LOS' side than Magisk's, but perhaps it would be better not to abort that early, and instead let it abort later at https://github.com/topjohnwu/Magisk/blob/master/scripts/magisk_uninstaller.sh#L50 where it will show the more accurate and detailed "! Cannot access /data, please uninstall with Magisk Manager"

Wait, I tried to uninstall Magisk via the in-app uninstaller - but - although it seemed to have run correctly, the very same leftovers from my 1st post remain. The in-app uninstaller only can be used when all filesystems are decrypted, during runtime of the system, so there must be something else to this or else there wouldn't be Magisk leftovers when flashing firmware etc. in LOS recovery.

The only way working for me is using TWRP, okay, but why?

I think I know why, I managed to grab a log from the Manager uninstall before it rebooted and it doesn't look like system-as-root is accounted-for.

- Removing Magisk files
mount: can't find /system in /proc/mounts
rm: can't remove '/system/addon.d/99-magisk.sh': Read-only file system

I'll add that to my PR

My PR is merged now, so it should be good once the next uninstaller gets built (usually with stable builds).

My PR is merged now, so it should be good once the next uninstaller gets built (usually with stable builds).

Just for understanding if I got this right: Despite of using LOS recovery we can completely uninstall/cleanup all traces of Magisk via Manager-Uninstall during runtime (not via recovery, because reasons^^)?

Yes.

Was this page helpful?
0 / 5 - 0 ratings