[Guide]How to Root Your Pixel 3a and Install Magisk - Android 9, 10 or 11

Cancambo

Member
May 8, 2010
26
7
0
I think the issue is the order you are doing your steps. If you let Magisk modify the stock image prior to flashing the update, the update will overwrite the Magisk backup. You need to flash the update before you use Magisk to patch the stock boot.img.

You can confirm this by checking the location of the Magisk backup. It is located at /root/data in a file with the name "stock_boot_XXXXXXXXXXXX.img.gz". Using your current steps, if you check for the file after patching the boot.img, I think you will find it. However, once you flash the update, I'm sure that file will be erased. This is why Magisk is failing when you try to unistall it for an OTA.

To fix the problem, just "install" Magisk again. Open the Magisk manager app and press the Install button next to Magisk (even though it says it is up to date). Choose the "Select and patch a File" method and select the correct stock boot.img file that you previously extracted and moved to the phone. This will force Magisk to recreate the patched file and create a backup. Once that is complete, you can stop. You shouldn't need to actually reflash the modified boot image again because Magisk is already installed.
So I just tried this. I took the stock boot.img for November and patched it in Magisk. It said "backing up stock boot image", but there is no new file in /data. I see old boot.img backups in that folder that Magisk made, but not the one it supposedly just backed up.

If I attempt to use Uninstall > Restore images it says no stock boot image exists.

I also just restored Magisk Manager to the default apk, and that didn't work either.

I'm using Magisk 20.1.

EDIT: Thanks to this post I was able to find the backed up stock boot image. It's in /data/user_de/0/<package name>/install/. I copied this backup to /data/ and I am now able to uninstall Magisk and restore the stock boot image. I should be able to take the next OTA now (hopefully).
 
Last edited:
  • Like
Reactions: sic0048

TT_Vert

Senior Member
Sep 11, 2010
1,799
226
0
Quick question for you guys. I had originally installed TWRP w/ a perm install using Dank's LZMA compression kernel and rooted via that. I just dirty flashed the latest Q image and then created a patched boot.img file. I flashed the patched magisk_patched.img via fastboot but I now get a bootloop. Am I doing something wrong here? Does the dirty flash revert the kernel back to stock or is the fact I have Dank's kernel the cause of this? From what I've read this should work just fine but no love for me.

If i do another dirty flash of the newest Q image i am back to booting but unrooted obviously.


Any input would be very appreciated.

Thanks much,

Dave
 
Last edited:

sic0048

Senior Member
Jun 25, 2010
910
465
83
Quick question for you guys. I had originally installed TWRP w/ a perm install using Dank's LZMA compression kernel and rooted via that. I just dirty flashed the latest Q image and then created a patched boot.img file. I flashed the patched magisk_patched.img via fastboot but I now get a bootloop. Am I doing something wrong here? Does the dirty flash revert the kernel back to stock or is the fact I have Dank's kernel the cause of this? From what I've read this should work just fine but no love for me.

If i do another dirty flash of the newest Q image i am back to booting but unrooted obviously.


Any input would be very appreciated.

Thanks much,

Dave
Flashing an image will replace the boot.img. Doing this from anything but an OTA taken through the phone will result in the loss of root. All you need to do is follow the directions in the first post to get root back.

If you end up in a boot loop, it's usually because you really aren't using the latest boot.img to modify, or you are not moving the latest modified_image back to the computer to reflash it. I ran into the same issue this last round because for some reason, Windows Explorer did not see the latest modified image right away and I ended up moving the modified image from the previous update. I knew the modified date was wrong, but the correct file simply did not show up for some reason. After boot looping and reflashing the stock boot.img, the correct modified image did show up in Windows Explorer and I was able to transfer it just fine.

Of course TWRP does not work fully in Android 10, so do not use it at all to root right now.
 
  • Like
Reactions: Completely_Clueless

ctfrommn

Senior Member
May 25, 2011
6,968
10,394
263
Minnesota
Just checking again - has anyone been able to mount /system rw?
Not possible on Android 10

---------- Post added at 12:39 PM ---------- Previous post was at 12:39 PM ----------

I have magisk install but no permission came out with any root app that ask for it.
Any sugestión:eek:
Update to latest Canary build Magisk and uninstall all Magisk modules.
 
  • Like
Reactions: caballon

till22

Senior Member
Jul 30, 2014
712
480
0
34°5'S, 58°5'W
Hi, I just did the sideload to December update and am trying to root my phone again, but can't complete step 1 somehow (obtaining the boot.img). I have the full zip (sargo-ota-etc...zip), when I extract the zip I have a folder (META-INF) with no .imgs and another zip (compatibility.zip) which does not contain any images either (just 4 xml files, system_manifest & -matrix and vendor_manifest & -matrix).

The full OTA zip I download should be OK since I was able to successfully sideloat the OTA, right? I' mfeeling very stupid, but I don't understand what I'm doing wrong.
 

Royalfox

Senior Member
Jul 17, 2011
1,533
231
0
Guadalajara
Hi, I just did the sideload to December update and am trying to root my phone again, but can't complete step 1 somehow (obtaining the boot.img). I have the full zip (sargo-ota-etc...zip), when I extract the zip I have a folder (META-INF) with no .imgs and another zip (compatibility.zip) which does not contain any images either (just 4 xml files, system_manifest & -matrix and vendor_manifest & -matrix).

The full OTA zip I download should be OK since I was able to successfully sideloat the OTA, right? I' mfeeling very stupid, but I don't understand what I'm doing wrong.
maybe you're downloading the OTA sideload instead of the factory image, in the latter is the one you extract the boot.img
 
  • Like
Reactions: till22

Completely_Clueless

Senior Member
Dec 21, 2011
51
7
28
Question About Sideloading & Recovery

I ordered a brand new Pixel 3a (coming from a Nexus 5X) and am planning to root it, so I'm reading through all this documentation to prepare.

I was reading the part in the OP about taking OTAs, and a (potentially stupid) question I haven't explicitly found the answer to is: will I need to restore my data, as if I clean flashed a factory ROM (full wipe), or instead just need to restore root/Magisk? I've never used a sideload method before (always clean flash), so I'm kind of ignorant about it. Based on the two OTA methods in the OP -- normal method vs. sideloading -- do both methods keep your data intact?

Also, I don't yet know which version of Android my Pixel 3a has, but I suspect it'll be version 10. I've read that TWRP isn't available for this version (yet). So I assume that means I won't be able to make Nandroid backups, right? In this case, what's the next best/recommended backup option for those who are rooted? Titanium Backup?
 

AndDiSa

Senior Member
Dec 2, 2009
3,381
4,410
263
Heidelberg
@Completely_Clueless you can apply OTA without wiping, you can also apply a new factory image without wiping, so all your data will be kept in that way. When updating to a new version, I always do it in the following way:
- fastboot flash boot.img <unpatched_boot.img for your current version
- fastboot reboot (now you are no longer rooted (!))
- then I do apply the OTA (in parallel Iam downloading the new factory image and do extract the boot.img for that version)
- after the OTA is applied and the device restarted the new version (you are still unrooted) I am transferring the new boot.img to the device
- patch the new boot.img with MagiskManager
- get the patched_boot.img
- fastboot flash boot patched_boot.img
- fastboot reboot
and you are rooted again ..

These are some (quite easy) steps but I never had problems in updating the phone yet.

For having a backup solution, I started Android Backup and Restore Tools which gives me the chance to do a backup (and restore) even without having TWRP available and without the need to store data on the device twice (original and backup).
 

sic0048

Senior Member
Jun 25, 2010
910
465
83
I was reading the part in the OP about taking OTAs, and a (potentially stupid) question I haven't explicitly found the answer to is: will I need to restore my data, as if I clean flashed a factory ROM (full wipe), or instead just need to restore root/Magisk? I've never used a sideload method before (always clean flash), so I'm kind of ignorant about it. Based on the two OTA methods in the OP -- normal method vs. sideloading -- do both methods keep your data intact?
Just as AndDiSa said, taking an OTA update via the normal phone system update method, or by manually using the sideload update process will both result in an updated phone with all of your data intact. It does not do a factory reset using these methods.

The only method that will factory reset/wipe (erase all of your data) by default is when you manually flash a factory image. This requires an unlocked bootloader. You can also edit the script to (removing the "-w" portion of the script) to prevent the phone from wiping the data, but that isn't the default action.
 
  • Like
Reactions: Completely_Clueless

sic0048

Senior Member
Jun 25, 2010
910
465
83
@Completely_Clueless
For having a backup solution, I started Android Backup and Restore Tools which gives me the chance to do a backup (and restore) even without having TWRP available and without the need to store data on the device twice (original and backup).
Thanks for posting this. I haven't paid attention to this and honestly didn't even know it existed. It definitely looks interesting.

If I'm reading the OP correctly, it is Linux (Ubuntu) only? I guess it is time to create a virtual machine again.....
 

AndDiSa

Senior Member
Dec 2, 2009
3,381
4,410
263
Heidelberg
Thanks for posting this. I haven't paid attention to this and honestly didn't even know it existed. It definitely looks interesting.

If I'm reading the OP correctly, it is Linux (Ubuntu) only? I guess it is time to create a virtual machine again.....
I am using Ubuntu and I tested it on Ubuntu only, but having a different Linux or Windows with either Cygwin or WSL (Windows Subsystem for Linux) installed, it should work, too ... probably with some slight modifications. If I find the time I'll probably try to adapt it for Windows, too. Unfortunately I do not have much experience with Powershell.
 

Completely_Clueless

Senior Member
Dec 21, 2011
51
7
28
Re: Question About Sideloading & Recovery

@Completely_Clueless you can apply OTA without wiping, you can also apply a new factory image without wiping, so all your data will be kept in that way. When updating to a new version, I always do it in the following way:
- fastboot flash boot.img <unpatched_boot.img for your current version
- fastboot reboot (now you are no longer rooted (!))
- then I do apply the OTA (in parallel Iam downloading the new factory image and do extract the boot.img for that version)
- after the OTA is applied and the device restarted the new version (you are still unrooted) I am transferring the new boot.img to the device
- patch the new boot.img with MagiskManager
- get the patched_boot.img
- fastboot flash boot patched_boot.img
- fastboot reboot
and you are rooted again ..

These are some (quite easy) steps but I never had problems in updating the phone yet.
Thanks a lot for your response! When you say "boot.img", like in the first step, when you type
Code:
fastboot flash boot.img
you're referring to the "boot.img" for Pixel 3a from Google's Factory Image webpage, right? Every time you say "boot.img", that file refers to the one from the factory image, is that right?

Even if I choose to use the sideload method for OTA, I still use the factory images and not the Pixel 3a OTA Sideload images, is that right? The two webpages look similar, so I just want to make sure I get the right files when it comes time to update.

It's going to feel really weird not using a recovery to (full) wipe to install/update a ROM; I've been using a that method for so long (since the ClockworkMod Recovery days). This new way is going to feel like I'm dirty flashing :eek:.


For having a backup solution, I started Android Backup and Restore Tools which gives me the chance to do a backup (and restore) even without having TWRP available and without the need to store data on the device twice (original and backup).
Thanks for linking this. I'll go check it out!
 

AndDiSa

Senior Member
Dec 2, 2009
3,381
4,410
263
Heidelberg
@Completely_Clueless yes, I am referrring to the boot.img extracted from the factory image. For the OTA it is not guaranteed that it contains a full boot.img but proably only some patches.
Yes, using CWM or TWRP one felt more secure as it was possible to do a nandroid backup and you were able to restore to the last working version but having the factory images and the possibility to backup / restore the whole phone I do feel almost beeing back in the old times ;)
 
  • Like
Reactions: Completely_Clueless

Completely_Clueless

Senior Member
Dec 21, 2011
51
7
28
Successfully Rooted!

My new Pixel 3a just arrived a few hours ago. I just wanted to post here to provide positive feedback to the OP for his guide, as I followed it and was able to successfully root my Pixel 3a! :)

When I booted my phone for the first time, I noticed it was running Android 9 (Pie). I unlocked the bootloader, which wiped my phone (there wasn't anything on it anyway, since it was brand new). Then I used the built-in OTA update to install Android 10. From there, I followed each step of the "Boot Image Patching Installation Method" in the first post, and now I have Magisk installed and passing all the SafetyNet checks!

Hopefully applying OTA updates in the future will be this easy ;).
 
  • Like
Reactions: Ditamae and AndDiSa

radensb

Senior Member
Oct 22, 2013
65
19
0
Current Best Option

Great thread! I just got my unlocked Pixel 3a last night and unlocked the bootloader this morning. I activated on Verizon and finished the basic setup. I notices that my current OS is Android 9 Pie, so it seems like I have some options to root. I am familiar with TWRP and initially thought that would be the option I would use as it is the most straight forward, but now that I understand TWRP isnt available for Android 10, so I am reconsidering. I am also familiar with ADB, so not really worried about having to flash patched images to gain root, but I am unclear what would happen if I flashed TWRP on my Android 9 device and used it to root with regards to updates. Would the TWRP method make my phone incompatible with Android 10 unless I flashed back to stock recovery? With TWRP flashed, would I only be able to update to the latest Android 9 OTA? That's how I understand it currently and I see that I have the option to update to Android 10 in the system update section of the settings.

Is Android 10 still causing issues and are there any recommendations to wait for it to mature further to upgrade? It seems that the best time to upgrade to Android 10 on the 3a is when TWRP is available for it - or is that not a valid justification to wait?

I am thinking that I will just flash TWRP, root Android 9 and stick with 9 until 10 has more support. Thoughts?

Thanks!
 
Last edited: