Can I Modify boot.img to install Magisk in "Core Only"? - Google Pixel 3a Questions & Answers

I have a Google Pixel 3a (Google Store), bootloader unlocked, been on Magisk Canary since I got it. When I updated to Android 10, one of the modules I had installed (Miracast enabler) was/is not compatible and caused a bootloop (I know, I'm stupid). Flashing the stock boot.img of course solves the problem because root is gone. This is an A/B boot device an 10 so:
- TWRP cannot decrypt /data which means I cannot access /data/cache
- No access to /data/cache means I cannot add the 'disable_magisk' file to boot Core Only mode
- No data/cache access also means I cannot simply delete the module/s
- Magisk through TWRP command prompt or adb are useless because, again, I cannot access /data/cache
The only possible solution I can think of is to modify my boot.img to boot Magisk in Core Only mode so I can remove the module, then flash a proper modified boot.img to regain full Magisk capability. I have poured over online documentation and cannot seem to find the answer on how, if possible, I can do this. Magisk's own documentation seems to suggest the only solution is to wipe /data.
Is there any way I can modify a boot.img to boot Magisk in Core Only mode always? Thank you!

MichRT said:
I have a Google Pixel 3a (Google Store), bootloader unlocked, been on Magisk Canary since I got it. When I updated to Android 10, one of the modules I had installed (Miracast enabler) was/is not compatible and caused a bootloop (I know, I'm stupid). Flashing the stock boot.img of course solves the problem because root is gone. This is an A/B boot device an 10 so:
- TWRP cannot decrypt /data which means I cannot access /data/cache
- No access to /data/cache means I cannot add the 'disable_magisk' file to boot Core Only mode
- No data/cache access also means I cannot simply delete the module/s
- Magisk through TWRP command prompt or adb are useless because, again, I cannot access /data/cache
The only possible solution I can think of is to modify my boot.img to boot Magisk in Core Only mode so I can remove the module, then flash a proper modified boot.img to regain full Magisk capability. I have poured over online documentation and cannot seem to find the answer on how, if possible, I can do this. Magisk's own documentation seems to suggest the only solution is to wipe /data.
Is there any way I can modify a boot.img to boot Magisk in Core Only mode always? Thank you!
Click to expand...
Click to collapse
Here you go :
https://forum.xda-developers.com/showpost.php?p=80190577&postcount=554

Since then there was also a patch to magisk to resolve this kind of issue.
While you can't boot you can still use "magisk --remove-modules" through adb shell (or twrp I guess), which will automatically remove all your modules next time you boot.

reyqn said:
Since then there was also a patch to magisk to resolve this kind of issue.
While you can't boot you can still use "magisk --remove-modules" through adb shell (or twrp I guess), which will automatically remove all your modules next time you boot.
Click to expand...
Click to collapse
You have to use last magisk (above 19.4 if my memories are right).

HpNoTiQ said:
Here you go :
https://forum.xda-developers.com/showpost.php?p=80190577&postcount=554
Click to expand...
Click to collapse
This looks like it might work, so thank you! I found a similar, though different solution (below)
reyqn said:
Since then there was also a patch to magisk to resolve this kind of issue.
While you can't boot you can still use "magisk --remove-modules" through adb shell (or twrp I guess), which will automatically remove all your modules next time you boot.
Click to expand...
Click to collapse
I ran into the issue that while boot-looping with a magisk patched boot img, I wasn't able to run the command, adb wasn't finding the phone. I tried again after booting TWRP and it basically threw an 'error - command not found'.
HpNoTiQ said:
You have to use last magisk (above 19.4 if my memories are right).
Click to expand...
Click to collapse
I think you are right, in beta/canary channel
@Tulsadiver gave me a hand with this, see here: https://forum.xda-developers.com/showpost.php?p=80398385&postcount=35997
Thank you guys!

Related

Dilemma: Magisk and Xposed boot loop

Dear all,
I'm in quite a dilemma. I have an FRD-L09 with the following environment:
Oreo Firmware (FRD-L09C432B521)
Unlocked FRD and Bootloader
TWRP 3.2.1 from 7to.cn (the one which can mount /system writable) (this one: https://forum.xda-developers.com/ho...p-ish-twrp-3-2-1-honor-9-running-gsi-t3818442)
I did not go the "Fix DataEncryption" way because, to me, it's pretty convenient that nobody is able to access /data even with TWRP, so if the phone gets stolen, my data is protected
I installed Magisk 17.1 and Magisk Manager which worked perfectly fine.
Then I downloaded and installed the corresponding Xposed Module for Magisk (apparently system-less, so Xposed-Uninstaller.zip doesn't work). This resulted in a boot loop.
I'm not able to suppress Xposed loading with the usual "press a device button many times in a row".
If I uninstall Magisk (i.e. flash stock recovery.img extracted from update.app), the system boots up normally, so it's Magisk+Xposed that causes the boot loop
BUT: Now I'm unable to remove the Xposed module from /data/magisk.img because 1. of course I can't access /data from a booted system without root and 2. I can't access /data from TWRP because I want to leave it protected.
Also, the "Fix DataEncryption" option apparently wipes the /data partition which I'd really like to avoid.
With other TWRP releases, I cannot access /data even after entering my lockscreen PIN or the "default_password" as decryption password, so I'm pretty certain that the encryption key is derived by other means - I think I remember reading that it's stored somewhere in hardware, which is also why, for Custom ROMs, encryption on Honor 8 is always an issue.
So does anyone have any clue how I can either access /data from TWRP while keeping it encrypted, or delete magisk.img via any other way?
I'll be happy about any hint!
EdRoxter said:
Dear all,
I'm in quite a dilemma. I have an FRD-L09 with the following environment:
Oreo Firmware (FRD-L09C432B521)
Unlocked FRD and Bootloader
TWRP 3.2.1 from 7to.cn (the one which can mount /system writable) (this one: https://forum.xda-developers.com/ho...-ish-twrp-3-2-1-honor-9-running-gsi-t3818442)
I did not go the "Fix DataEncryption" way because, to me, it's pretty convenient that nobody is able to access /data even with TWRP, so if the phone gets stolen, my data is protected
I installed Magisk 17.1 and Magisk Manager which worked perfectly fine.
Then I downloaded and installed the corresponding Xposed Module for Magisk (apparently system-less, so Xposed-Uninstaller.zip doesn't work). This resulted in a boot loop.
I'm not able to suppress Xposed loading with the usual "press a device button many times in a row".
If I uninstall Magisk (i.e. flash stock recovery.img extracted from update.app), the system boots up normally, so it's Magisk+Xposed that causes the boot loop
BUT: Now I'm unable to remove the Xposed module from /data/magisk.img because 1. of course I can't access /data from a booted system without root and 2. I can't access /data from TWRP because I want to leave it protected.
Also, the "Fix DataEncryption" option apparently wipes the /data partition which I'd really like to avoid.
With other TWRP releases, I cannot access /data even after entering my lockscreen PIN or the "default_password" as decryption password, so I'm pretty certain that the encryption key is derived by other means - I think I remember reading that it's stored somewhere in hardware, which is also why, for Custom ROMs, encryption on Honor 8 is always an issue.
So does anyone have any clue how I can either access /data from TWRP while keeping it encrypted, or delete magisk.img via any other way?
I'll be happy about any hint!
Click to expand...
Click to collapse
Re-install EMUI 8 with eRecovery.
ThePS4Gamer said:
Re-install EMUI 8 with eRecovery.
Click to expand...
Click to collapse
Yeah, I really hoped I could do something without wiping my /data partition, but I guess I'll have to back up my data and do a factory reset and start over...
PS: eRecovery only offers EMUI 5 on the Honor 8 - EMUI 8 is only installable via HiSuite.
EdRoxter said:
Yeah, I really hoped I could do something without wiping my /data partition, but I guess I'll have to back up my data and do a factory reset and start over...
PS: eRecovery only offers EMUI 5 on the Honor 8 - EMUI 8 is only installable via HiSuite.
Click to expand...
Click to collapse
Solution is simple.
Requirement:
TWRP(which Twrp? honor view 10's. Research how to install)
Solution:
-install magisk pached boot img to ramdisk and twrp to recovery_ramdisk
-boot in Twrp
-then navigate to Advance->Terminal
-write below command:
touch /cache/.disable_magisk && chmod 0777 /cache/.disable_magisk && sync && reboot
Behind the scene: It will enable magisk core only mode, then uninstall malfunctioning modules from magisk manager and disable core only mode, reboot and mtv enjoy
spica1234 said:
touch /cache/.disable_magisk && chmod 0777 /cache/.disable_magisk && sync && reboot
Behind the scene: It will enable magisk core only mode, then uninstall malfunctioning modules from magisk manager and disable core only mode, reboot and mtv enjoy
Click to expand...
Click to collapse
Thank you so much! This was exactly was I was looking for, but googling for "disable Magisk boot" and the like didn't bring up any results other than a bunch of tutorials on how to remove Magisk modules from TWRP with uninmod, which obviously didn't work for me because I couldn't mount /data from TWRP.

Advanced OTA keeping Magisk and TWRP (needs a computer)

History...
I originally wrote this guide to upgrade from 10.0.4.0 to 10.0.7.0.
I have also used this same guide to install every OTA from 10.0.7.0 to 11.0.11.0.
This guide assumes you have both Magisk and TWRP, that Magisk cannot "uninstall" (because of TWRP installation) and that you want to keep both Magisk and TWRP after installation. Parts of this guide may still be useful if you aren't in this exact situation.
If you only have Magisk, you should be able to follow these much simpler instructions: https://forum.xda-developers.com/mi-a2-lite/how-to/guide-install-magisk-proper-support-ota-t3836952
Things to have on hand:
- vanilla_boot.img (for the version you currently have)
- patched_boot.img (your current boot image with Magisk)
- TWRP img and zip (see version info below)
I think that TWRP also causes the vendor partition to be modified. It may also touch system but I have a modified bootanimation.zip which modifies system, so I can't be sure. In any case, I also have a backup of system.img and vendor.img.
Because Magisk is installed after TWRP, Magisk's "backup" of the "stock boot image" is not vanilla. This means that in order to take the OTA, I have to flash the vanilla boot image.
0 - Update your patched_boot.img
If you don't have a patched_boot.img for your current Magisk (eg. my patched_boot.img was old, since I had installed several Magisk updates), you should build a new patched_boot.img so that when you boot it, the system will continue to work.
Push the vanilla image to the phone.
Code:
adb push vanilla_boot.img /sdcard
Then get Magisk to install using the "Select and Patch a File" method, select the file you uploaded. Then pull down the patched image.
Code:
adb pull /sdcard/Download/magisk_patched.img patched_boot.img
1 - Prepare to OTA
For some reason, my carrier does not like the OTA process so I always turn on Airplane mode + Wifi.
Get to fastboot and check the current slot.
Code:
adb reboot bootloader
fastboot getvar current-slot
My current slot was b
Flash the system and vendor partitions (if necessary).
Code:
fastboot flash system_b vanilla_system.img
fastboot flash vendor_b vanilla_vendor.img
Flash vanilla and boot the patched image (so that Magisk is active and the OTA can be applied).
Code:
fastboot flash boot_b vanilla_boot.img
fastboot boot patched_boot.img
2 - Do the OTA
Install OTA (DO NOT REBOOT)
If the OTA fails
If the OTA fails, you can find out which partitions it doesn't like from the logcat. If you have a fastboot image, you can reflash the affected partitions. As previously mentioned, I've had to flash all of boot, vendor and system for each OTA.
Code:
adb logcat | grep update_engine
...
07-01 06:52:38.470 E/update_engine(935): [0701/065238.470683:ERROR:delta_performer.cc(990)] The hash of the source data on disk for this operation doesn't match the expected value. This could mean that the delta update payload was targeted for another version, or that the source partition was modified after it was installed, for example, by mounting a filesystem.
07-01 06:52:38.470 E/update_engine(935): [0701/065238.470931:ERROR:delta_performer.cc(995)] Expected: sha256|hex = A4AD686D7BF628486668446221D0089BF5915DBC1158C83D30A06222FE7D2ACB
07-01 06:52:38.471 E/update_engine(935): [0701/065238.471002:ERROR:delta_performer.cc(998)] Calculated: sha256|hex = 4CADBE88EC1C019913A0B416EB9031840D4BA6B2287A3FC814A2B8B7F9871F7D
07-01 06:52:38.473 E/update_engine(935): [0701/065238.471072:ERROR:delta_performer.cc(1009)] Operation source (offset:size) in blocks: 0:5221,5461:405,5869:1,5873:343,6221:589
07-01 06:52:38.473 E/update_engine(935): [0701/065238.473233:ERROR:delta_performer.cc(1191)] ValidateSourceHash(source_hash, operation, source_fd_, error) failed.
07-01 06:52:38.473 E/update_engine(935): [0701/065238.473340:ERROR:delta_performer.cc(298)] Failed to perform BROTLI_BSDIFF operation 187, which is the operation 0 in partition "boot"
07-01 06:52:38.473 E/update_engine(935): [0701/065238.473411:ERROR:download_action.cc(337)] Error ErrorCode::kDownloadStateInitializationError (20) in DeltaPerformer's Write method when processing the received payload -- Terminating processing
07-01 06:52:38.739 E/SystemUpdate(15410): [Execution,NonStreamingAbApplyAction] Installation failed with error code: 20.
3 - Backup the vanilla boot image
Note that you need to pull from the other slot (in my case, a).
Code:
adb shell
su
dd if=/dev/block/by-name/boot_a of=/sdcard/vanilla_boot.img bs=1024k
Backup system.img and vendor.img too (if required).
Code:
dd if=/dev/block/by-name/system_a of=/sdcard/vanilla_system.img bs=1024k
dd if=/dev/block/by-name/vendor_a of=/sdcard/vanilla_vendor.img bs=1024k
4 - Magisk patch the other slot
Use Magisk to "Install to Inactive Slot (After OTA)" (DO NOT REBOOT)
5 - Backup the patched boot image
Note that you need to pull from the other slot (in my case, a).
Code:
dd if=/dev/block/by-name/boot_a of=/sdcard/patched_boot.img bs=1024k
exit
exit
# back on your computer
adb pull /sdcard/vanilla_boot.img
adb pull /sdcard/patched_boot.img
Pull down system and vendor images too (if required).
Code:
adb pull /sdcard/vanilla_system.img
adb pull /sdcard/vanilla_vendor.img
Now you can let Magisk reboot. This is the moment of truth...
At this point you should have an upgraded, Magisk-enabled system and backups of the vanilla and patched boot images. Congratulations on completing the OTA!
If the system fails to boot
There's a few things to try before giving up if the system fails to boot...
1) Boot without Magisk (fastboot boot vanilla_boot.img). Probably indicates that a Magisk module you have is no longer compatible.
2) Boot TWRP (fastboot boot twrp.img) and poke at things. As an example, I used the /sdcard/mm program (part of Magisk Manager for recovery) to disable EdXposed when the OTA to Android 10 failed to boot.
6 - Restore TWRP
It is possible to boot TWRP from fastboot so you don't strictly need to install TWRP. I like to have it available anyway.
Old version info...
I had been using the official TWRP 3.2.3, which worked great up until 10.0.9.0. With 10.0.9.0, I couldn't get to TWRP, I just got the system destroyed screen. I could fastboot boot it, but it couldn't mount /data (a problem it has always had).
I figured out that TWRP 3.3.1-dees_troy (from the official TWRP site) works with 10.0.9.0 and up. What's more, it works (can decrypt /data) if you fastboot boot it, not just after install. So you could in theory simply not install TWRP and fastboot boot if in the event that you actually need it.
I know that people have their own favourite versions, with the offain version being popular (didn't work for me). There's OrangeFox too (also didn't work for me).
In summary, I recommend Official TWRP 3.3.1-dees_troy but if you have a favourite alternative, feel free to use it instead.
TWRP thread: https://forum.xda-developers.com/mi-a2-lite/development/official-twrp-daisy-t3855396
Download link: https://dl.twrp.me/daisy/
Restoring TWRP is the same as installing it the first time. This is the process that I use.
Flash vanilla boot, then install TWRP to it.
Code:
adb reboot bootloader
fastboot boot twrp-3.3.1-dees_troy-daisy.img
Install TWRP
Code:
adb push twrp-installer-3.3.1-dees_troy-daisy.zip /sdcard
Use TWRP to install twrp-installer-3.3.1-dees_troy-daisy.zip
I install my modified bootanimation.zip at this time.
Mount System from TWRP (it is normally already mounted for me).
From a shell:
Code:
adb shell
cd /sdcard
cp bootanimation.zip /system/system/media/bootanimation.zip
Umount System
You must re-install Magisk after installing TWRP.
Code:
adb reboot bootloader
fastboot boot patched_boot.img
Use Magisk to "Direct Install (Recommended)"
Reboot
For some reason, my carrier does not like the OTA process so at this point I normally power off the phone rather than just rebooting. When the phone boots, I can turn off airplane mode and check that a mobile data connection can be made.
7 - Confirm that everything works
Make sure the system comes up and Magisk Manager says that Magisk is installed.
Make sure you can get to TWRP. Boot while holding VOL+ or
Code:
adb reboot recovery
Make sure TWRP can see your files.
Congratulations! You have installed an OTA while keeping Magisk and TWRP!
8 - Backup boot.img with TWRP + Magisk (optional)
If you want a copy of the boot.img with both Magisk and TWRP. This pulls from the now-current slot (in my case, a). I'm not totally sure of the value of this, since I can't get fastboot to boot this image. It may come in handy if you upgrade TWRP and that breaks (since you can flash this back rather than having to install the old TWRP again).
Code:
adb shell
su
cd /sdcard
dd if=/dev/block/by-name/boot_a of=twrp_boot.img bs=1024k
exit
exit
# back on the computer
adb pull /sdcard/twrp_boot.img
Thanks. Could you upload or indicate where we can get the necessary files?
Will i loose all user data and internal storage wiped if i do this?
Thanks for sharing, looks complicated, also i think you should use a fixed twrp, since the official dont have acces to sdcard.
rossarnie said:
Thanks. Could you upload or indicate where we can get the necessary files?
Click to expand...
Click to collapse
If you have Magisk, you should already have the vanilla and patched boot.img files.
Of you don't already have Magisk, just follow the install procedure here. https://forum.xda-developers.com/mi-a2-lite/how-to/guide-install-magisk-proper-support-ota-t3836952
If you're running 10.0.4.0 without magisk and need to extract your vanilla boot.img. Use fastboot to boot into twrp and then you can do the DD command to extract boot. Use adb pull to save it to PC.
I used official TWRP from here.
https://forum.xda-developers.com/mi-a2-lite/development/official-twrp-daisy-t3855396
Apparently there's a different twrp that can access the external SD card. I don't have an external SD card so I don't need it.
dr.bahaeddin said:
Will i loose all user data and internal storage wiped if i do this?
Click to expand...
Click to collapse
I didn't lose any data.
I've never had a problem with Magisk. TWRP does tend to bootloop after install, which is why I install magisk again.
You should be able to flash the patched or vanilla boot if twrp is boot looping to fix it too. Just won't have twrp anymore.
a1291762 said:
I didn't lose any data.
Click to expand...
Click to collapse
Mind you. I have a backup of my apps and data that's off of my phone so even if I do need to factory reset I can get it back. That's a longer and more complicated guide.
Txatxiquesi said:
looks complicated.
Click to expand...
Click to collapse
Before I had twrp the standard Magisk ota process was enough. But that loses twrp and with twrp in my magsik backup, the uninstall didn't work. So extra steps are needed. Plus some extra steps to make backups of important files for the next OTA
a1291762 said:
If you have Magisk, you should already have the vanilla and patched boot.img files.
Click to expand...
Click to collapse
Hmm... This may not be the case. I'm careful to make backups but it's easy to skip this.
If you don't have a patched boot image you can backup your current boot partition from a root shell. You need to find out if you are booting a or b slot. Then
dd if=/dev/block/by-name/boot_a of=/sdcard/patched_boot.img bs=1024k
Magisk puts old stock backups into /data. I had 4 files in there which makes it hard to know what each file is.
That's why I made sure to backup my vanilla boot image immediately.
If you're stuck without a vanilla 10.0.4.0 boot you can't do the OTA. I can upload mine somewhere when I get home tonight if it's not already online.
a1291762 said:
...If you're stuck without a vanilla 10.0.4.0 boot you can't do the OTA. I can upload mine somewhere when I get home tonight if it's not already online.
Click to expand...
Click to collapse
This would be very helpful, please
FunkmasterC said:
This would be very helpful, please
Click to expand...
Click to collapse
Here is the backup I made of the 10.0.4.0 vanilla boot.img. You'll need to decompress this before flashing.
URL REMOVED
What's new on 10.0.7.0 bro? Should me wait for 10.1 update if im on 10.0.4.0 rooted?
10.0.7.0 has the March security patches. I haven't noticed any actual changes.
Thank you, your Linux commands are sick, I never know I can get the vanilla and patched boot.img like that.
Cheer~
is there an update for file version 10.0.8.0??
I only just got the notification this morning. I'll do the upgrade tonight but I expect the same process will work.
I just used the same process to go from 10.0.7.0 to 10.0.8.0. This time I was installing to slot b instead of slot a, but otherwise, things were the same.
A side note... I hadn't got around to installing TWRP 3.3.0 so I did that but it couldn't mount /data. TWRP 3.2.3 can mount /data, so I installed that again.
a1291762 said:
I just used the same process to go from 10.0.7.0 to 10.0.8.0. This time I was installing to slot b instead of slot a, but otherwise, things were the same.
A side note... I hadn't got around to installing TWRP 3.3.0 so I did that but it couldn't mount /data. TWRP 3.2.3 can mount /data, so I installed that again.
Click to expand...
Click to collapse
I have successfully updated to 10.0.8.0 with Magisk 18.1, now on Magisk 19.1, everything is running fine. I'd like to also install TWRP but refrain from doing so because of the problems (bootloops, crashes, etc) the official TWRP 3.2.3 shows with decryption in Pie and mounting external or even internal sdcard. I wonder if the latter is fixed in the inofficial fixed version. I think the benefit of TWRP is not worth the effort of repeating a1291762 wonderful tricky procedure on the monthly OTA update basis.
However the procedure is very smart, a back-to-the-roots approach of former days... great, I like it.
But I don't understand how a patched_boot.img can be created from an empty file (boot_a)?
[dd if=/dev/block/by-name/boot_a of=patched_boot.img bs=1024k] Locating the boot_a in </dev/block/by-name/> reveals a boot_a file with 0 bytes. Moreover, to unzip the zipped stock boot Image in </data/stock_boot*.img> or </sbin/.magisk/mirror/data/> I am looking for a command that just returns the boot file rather than expanding it to the full partition. Weird, can anybody help?
Thanks again to a1291762
grufty47
It appears that it is not possible to add some boot.img as attachment
grufty47 said:
I'd like to also install TWRP but refrain from doing so because of the problems (bootloops, crashes, etc) the official TWRP 3.2.3 shows with decryption in Pie and mounting external or even internal sdcard.
Click to expand...
Click to collapse
I use official TWRP 3.2.3. Only really to fix bootloop problems.
I don't have a SD and no problems mounting data.
Lots of people following the TWRP install guide seem to get bootloop. I solve that by patching boot with Magisk. Some people recommend installing an old about image.
If you have a backup of boot you can at least restore that if you have problems.
grufty47 said:
But I don't understand how a patched_boot.img can be created from an empty file (boot_a)?
Click to expand...
Click to collapse
Welcome to Unix, where nearly everything is a file.
Hard disk? /dev/sda
Partition? /dev/sda1
File? /mnt/sda1/file.txt
In this case, boot_a is a way to access a partition on the phone's flash. Actually a link (shortcut) to /dev/mmcblk0p52. Partition number 53 on flash chip 1. The size can't be seen because it's a device and not a file.
grufty47 said:
I am looking for a command that just returns the boot file rather than expanding it to the full partition.
Click to expand...
Click to collapse
dd is a command to read a device. The partition is 64M big so that's the size of the file. gzip can compress well because the actual image is only 24M big and the rest is empty.
Magisk knows how to do it. A tool called magiskboot but I don't know where it lives or how to run it.
I found this header from magiskboot. It shows how the boot.img is structured.
https://github.com/topjohnwu/Magisk/blob/master/native/jni/magiskboot/bootimg.h
I just did the 10.0.9.0 OTA. I added a section of updating your patched_boot.img (since the Magisk updates I did made my old one useless) and I changed the backup instructions due to changes in Magisk 19. If you know where the stock boot lives before reboot, please let me know.

[solved]Q Beta 6 Magisk lost

I'm using the canary version of Magisk for the Q beta 6. Yesterday I tried to install a self made module to get rid of screenshot sounds (the one on the rep isn't working because Google changed the path. But as I installed it, I can only remember that the last line was "Magisk manager will be removed and your device will reboot in a moment" or something like that
Well, the manager is still installed, but Magisk itself got uninstalled. Besides the fact that I have no clue why that happened, now I can't install it. TWRP doesn't support Q. So I got the Q image from Google, extracted the boot.img and let Magisk Manager patch it (with preserve force encryption and Preserve AVB 2.0/dm-verity turned on) and flash it through Fastboot (fastboot flash boot magisk-boot.img) but it's still not installed. And without TWRP of course I can't flash the uninstaller zip (no clue what was actually removed).
Is there a way through adb or fastboot to find out what's left of the Magisk installation and remove that? Or any other solution I didn't think of?
Ok, via adb is not an option since both /data and /cache refuse permissions so I can't even get logs to find out what happened.
Does anyone have a working pre-patched boot.img? I don't know if that Manual method isn't working because patching isn't really working or because the Magisk files are still present and the module is still conflicting with Magisk. And I don't want to do a factory reset
Nevermind. It was a faulty Magisk database, I had to uninstall and reinstall it to solve the problem

Magisk & Lineage = No wifi

Goodmorning everyone. I have a problem with magisk and lineageos 18.1
I have a xiaomi mi mix 2 unlocked
Premise: I've never had any problems with magisk and lineage until now.
I installed magisk scrupulously following the official instructions and using both the boot.img patch system and the direct installation via recovery (adb sideload & lineage recovery)
In both cases magisk appears as not installed when looking from magisk manager and the wifi stops working (the phone connects to the various networks I have tried but reveals them as without internet.)
clearing cache does nothing
resetting network connections does nothing
Updating to the latest version of the radio firmware does nothing
restore boot.img OR reinstall lineage corrects the problem
In all cases I don't get root ...
Honestly, everything is beyond my understanding .. can you help me?
Ork_77 said:
Goodmorning everyone. I have a problem with magisk and lineageos 18.1
I have a xiaomi mi mix 2 unlocked
Premise: I've never had any problems with magisk and lineage until now.
I installed magisk scrupulously following the official instructions and using both the boot.img patch system and the direct installation via recovery (adb sideload & lineage recovery)
In both cases magisk appears as not installed when looking from magisk manager and the wifi stops working (the phone connects to the various networks I have tried but reveals them as without internet.)
clearing cache does nothing
resetting network connections does nothing
Updating to the latest version of the radio firmware does nothing
restore boot.img OR reinstall lineage corrects the problem
In all cases I don't get root ...
Honestly, everything is beyond my understanding .. can you help me?
Click to expand...
Click to collapse
It seems to me like you aren't properly flashing the patched boot.img. What method are you using to flash the patched boot.img?
Droidriven said:
It seems to me like you aren't properly flashing the patched boot.img. What method are you using to flash the patched boot.img?
Click to expand...
Click to collapse
I used both the method I'm aware of
1) I install magisk manager, extract the boot.img from lineage zip, upload it to the phone, patch it with magisk manager (operation ends fine), pass the modified version back to the pc reboot the phone in recovery and install the new boot with adb (installation ends correctly).
2) I rename the magisk app as .zip and then I install it through recovery
The result is the same.
In the past (with lineage 17) i always used the second method and I lived happy and with root for years.
Ork_77 said:
I used both the method I'm aware of
1) I install magisk manager, extract the boot.img from lineage zip, upload it to the phone, patch it with magisk manager (operation ends fine), pass the modified version back to the pc reboot the phone in recovery and install the new boot with adb (installation ends correctly).
2) I rename the magisk app as .zip and then I install it through recovery
The result is the same.
In the past (with lineage 17) i always used the second method and I lived happy and with root for years.
Click to expand...
Click to collapse
Since you have TWRP, you don't need the patched boot.img.
The Magisk Manager app has the root binaries built in now, all you should need to do is a Magisk Manager flashable zip.
Read this:
The Magisk Manager APK can now be flashed from within TWRP
Magisk is now distributed as part of the Manager APK, meaning you no longer need to flash a separate ZIP file from a custom recovery.
www.xda-developers.com
...
Droidriven said:
Since you have TWRP, you don't need the patched boot.img.
The Magisk Manager app has the root binaries built in now, all you should need to do is a Magisk Manager flashable zip.
Read this:
The Magisk Manager APK can now be flashed from within TWRP
Magisk is now distributed as part of the Manager APK, meaning you no longer need to flash a separate ZIP file from a custom recovery.
www.xda-developers.com
Click to expand...
Click to collapse
Yes...this is exatcly what I did.
Method 2.
Ork_77 said:
Yes...this is exatcly what I did.
Method 2.
Click to expand...
Click to collapse
You said that you converted the apk into a flashable zip. I think you should be able to find a MagiskManager.zip that is prepackaged for you to download and flash.
Also, if you use the patched boot.img method, you should rename the patched boot.img to "boot.img", then place the boot.img in your fastboot folder on PC. Then right click inside the fastboot folder and choose the option to open a cmd terminal, then boot your device into fastboot mode, connect your device to PC, type the following command:
fastboot devices(press enter)
If it returns a serial number, you are connected. Next, type the following command:
fastboot flash boot boot.img(press enter)
This should flash the patched boot.img correctly. Then reboot the device to system and try installing the Magisk Manager apk file from your internal storage instead of flashing it as a zip in recovery. If that doesn't work, try flashing the apk as a zip in recovery, wipe cache and dalvik cache after flashing the zip(DO NOT FACTORY RESET OR FORMAT ANYTHING), then reboot to system and see if it works correctly.
Droidriven said:
You said that you converted the apk into a flashable zip. I think you should be able to find a MagiskManager.zip that is prepackaged for you to download and flash.
Also, if you use the patched boot.img method, you should rename the patched boot.img to "boot.img", then place the boot.img in your fastboot folder on PC. Then right click inside the fastboot folder and choose the option to open a cmd terminal, then boot your device into fastboot mode, connect your device to PC, type the following command:
fastboot devices(press enter)
If it returns a serial number, you are connected. Next, type the following command:
fastboot flash boot boot.img(press enter)
This should flash the patched boot.img correctly. Then reboot the device to system and try installing the Magisk Manager apk file from your internal storage instead of flashing it as a zip in recovery. If that doesn't work, try flashing the apk as a zip in recovery, wipe cache and dalvik cache after flashing the zip(DO NOT FACTORY RESET OR FORMAT ANYTHING), then reboot to system and see if it works correctly.
Click to expand...
Click to collapse
Hi Droidriven, thank you for your answers. Perhaps, synthesizing my steps too much, I gave the impression of not being particularly capable in computer science (you even tell me to press "enter" after commands ...). Well, let's say it's not my case.
All steps are performed correctly.
all steps end without errors.
No matter what I do, in the end Magisk appears as n / a, I don't have root, and the data connection doesn't work. Small addition about the latter aspect: when rebooting the wifi connection works for a variable time between 10 and 20 seconds, after which the network appears as without internet (or intranet) but the phone remains connected.
At the reboot, history repeats itself
Restoring the original boot everything returns to normal.

Install magisk using ONLY adb root shell

/* excuse windows person in advance for poor grammar */
TL;DR:
LG V20 H918
bootloader unlocked
bootable LOS19.1
no fastboot available
no recovery available
Goal: setup magisk using adb root shell
Is it possible?
What happend:
On stock LG V20 H918 no flashing was available in fastboot, probably done by manufacturer.
No stock recovery available as well.
I was able to unlock bootloader and install TWRP using "lafsploit".
Then I installed LOS 18.1 and Magisk with TWRP.
Everything worked perfectly.
Later I decieded to update to LOS 19.1, and probably forgot some step in the process.
LOS 19.1 boots and works OK, but without root/magisk. TWRP now stucks in splash screen.
I unable to install Magisk or restore backup without TWRP.
I unable to reflash TWRP without fastboot.
But I have acces to adb root shell!!!
So I thought it should be possible to repeat all changes Magisk does when patches boot.img, right?
I examined boot_patch.sh from magisk.akp, then compared original and patched img-s.
Waht I concluded magisk does:
1: create ".backup" folder in root
put there original "init" file
put there ".rmlist" file with what to remove on uninstall
put there ".magisk" file with checksum and other variables
2: create "overlay.d" folder in root
create "sbin" folder in "overlay.d"
put there same ".xz" files mentiond in ".rmlist"
3: perform some modifications to "init" file in root
Will it work if i repeat all this changes through shell?
Or do i need to do something else, like changing that checksum somwhere?
I have all this files from patched "boot.img", including that "init" file.
Is this a guide, or a question?
If this is a guide, you need to write it in such a way that others can easily follow it.
I don't know enough about LG devices to tell you whether you can accomplish what you're trying to do. From what I can see, rooting is extremely complicated. This is why I have a Pixel.
This is a question, I just atempted to give as much information as possible.
IMHO this sitiation should not be specific to this particular device.
In other words, is it possible to install magisk by "patching files" on booted system? (without re-flashing boot.img?)
I had to flash the lineage recovery to replace twrp when i installed the 19.1 rom. You can still install magisk using the lineage recovery.
If I recall however you can also patch the bootloader to install magisk through the installed magisk app itself aswell. As for the specifics of your question of installing it without patching of some way to the bootloader... ive no clue.
I was unable to install recovery, and there was no recovery when I got this phone with "stock ROM". thought it was done this way by oem.
Atempting to boot into recovery results in "brocken android icon" with "no command" text.
Yes, this is how I installed magisk first time: install app -> patch boot image in app -> then re-flash patched image with twrp.
My idea is to do all reqired changes manually, as we have root acces from adb shell:
As for now I mimicked difference betwen patched and original 'boot.img', which coresponds to "Ramdisk Patches" section of Magisk's "boot_patch.sh":
'.backup' and 'root/overlay.d/sbin' folders and their contents, init file and all permissions
Phone boots but no changes in magisk
Also added '99-magisk.sh' to /system/addon.d
It seem to launch, but no changes in magisk too.
Posting in case somebody will search for this.
For magisk to work some changes in kernel may be reqired. If kernel in patched boot image is different from original, then there is no solution this way.
Wiping cache and userdata can possibly fix TWRP bootloop, but If your fastboot unable to flash anything, then it probably also will be unable erase/format cache and userdata.
>>>!!! Backup first if you can, this will erase all your files and apps !!!<<<
Try to do hard factory reset this way, it helped in my case:
- Turn the phone off.
- Press and hold "Vol. down" + "Power btn"
- When LG logo appears, release "Power btn" for ~0.5sec. then push again
- Hold "Vol. down" + "Power btn" until hard reset menu appears.

Categories

Resources