• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[Guide]How to Root Your Pixel 3a and Install Magisk - Android 9 - 12

Search This thread

AndDiSa

Senior Member
Dec 2, 2009
3,583
4,766
Heidelberg
@Uzephi well, without having Magisk installed it's very unlikely that a bad module is preventing the flashing / booting. But you are right that this might have led to this situation: as soon as there is a boot image with Magisk starting it will try to initialize the bad module -> boot will fail -> boot slot will be marked as "failed"
On reboot the other slot will be used and if there is also a Magisk patched boot image the same procedure will happen ... and finally both slots are no longer bootable.
 

Uzephi

Recognized Contributor
Apr 20, 2012
3,439
1,890
Phoenix
Google Pixel 3a
@Uzephi well, without having Magisk installed it's very unlikely that a bad module is preventing the flashing / booting. But you are right that this might have led to this situation: as soon as there is a boot image with Magisk starting it will try to initialize the bad module -> boot will fail -> boot slot will be marked as "failed"
On reboot the other slot will be used and if there is also a Magisk patched boot image the same procedure will happen ... and finally both slots are no longer bootable.

They could be in the predicament I am in. I have flashed full factory images since Android 10, so my slot B is still Android 9.
 
  • Like
Reactions: AndDiSa

daddylonglegs

Senior Member
Oct 23, 2009
506
104
Vermont
It could be a bad module also. I would suggest using the below command when booting with Magisk and reinstall your modules one by one.

adb wait-for-device shell magisk --remove-modules

I appreciate the reply but I can't boot with Magisk at all.

After flashing the OTA, do you let the system boot at least once without installing Magisk? I would suggest you to at least do one reboot before you try to flash a new boot.img. The bootloader holds flags which slot was used the last time when booting and in addition whether booting was successful or not. If both boot slots are marked as "unbootable" I suppose you will get this error message ...

Yes I let it boot fully. Every single time I flash the patched Magisk boot image I get NO VALID SLOT TO BOOT error :(
 

daddylonglegs

Senior Member
Oct 23, 2009
506
104
Vermont
If you get the Google G, that adb command will work. It is a failsafe in Magisk in case you have a module causing a no boot scenario.

I appreciate it but every time I type that ADB command it looks like it's doing something and nothing happens. I let my phone sit there for an hour and the command prompt window just stays at "adb wait-for-device shell magisk --remove-module"

At this point I am not sure how it can be a module anyway. Why would a bad module refuse to let my phone boot with a NO VALID SLOT TO BOOT error?
 

Uzephi

Recognized Contributor
Apr 20, 2012
3,439
1,890
Phoenix
Google Pixel 3a
I appreciate it but every time I type that ADB command it looks like it's doing something and nothing happens. I let my phone sit there for an hour and the command prompt window just stays at "adb wait-for-device shell magisk --remove-module"

At this point I am not sure how it can be a module anyway. Why would a bad module refuse to let my phone boot with a NO VALID SLOT TO BOOT error?

Is your phone trying to boot? Does it go to the Google G? The adb command will wait for the phone to allow usb debugging (which happens during boot phase. Magisk is designed to not load modules until usb debugging is enabled for this specific command). If you never set that PC to "always allow" before, the command won't work. What you could do is boot without Magisk and run "adb reboot bootloader" command, tick the "always allow" check box. Once in bootloader, just boot the Magisk boot image and run that remove module command again.

If you are getting a no valid slot to boot error, that could be a magisk module as it will still try to load the module on either slot since the module resides in /data. I had this issue with AccA on an update before.
 
  • Like
Reactions: daddylonglegs

daddylonglegs

Senior Member
Oct 23, 2009
506
104
Vermont
Is your phone trying to boot? Does it go to the Google G? The adb command will wait for the phone to allow usb debugging (which happens during boot phase. Magisk is designed to not load modules until usb debugging is enabled for this specific command). If you never set that PC to "always allow" before, the command won't work. What you could do is boot without Magisk and run "adb reboot bootloader" command, tick the "always allow" check box. Once in bootloader, just boot the Magisk boot image and run that remove module command again.

If you are getting a no valid slot to boot error, that could be a magisk module as it will still try to load the module on either slot since the module resides in /data. I had this issue with AccA on an update before.

Thanks so much for the reply.

My phone does not even make it to the google G.

USB Debugging is always enabled.

I can't boot the magisk boot image. If I try to flash it, I get NO VALID SLOT TO BOOT
If I try to boot it instead of flash it I get stuck on the Google G and nothing happens.

Any ideas? :(
 

daddylonglegs

Senior Member
Oct 23, 2009
506
104
Vermont
Alright so huge update; everything now works! How did I do it?

I switched from using Command Prompt to PowerShell. I don't even know what made me figure out to give that a try, but it worked!

Mystery solved for anyone else that ever has this problem!
 
  • Like
Reactions: Uzephi

Uzephi

Recognized Contributor
Apr 20, 2012
3,439
1,890
Phoenix
Google Pixel 3a
Alright so huge update; everything now works! How did I do it?

I switched from using Command Prompt to PowerShell. I don't even know what made me figure out to give that a try, but it worked!

Mystery solved for anyone else that ever has this problem!
Gotta love windows. Cmd works for me running that command, which is why most of us would recommend a bootable linux usb drive for adb and fastboot because in Linux, it just works. 😉

Glad you're up and running, though and disabling modules fixed the issue.
 

sic0048

Senior Member
Jun 25, 2010
962
503
Google Pixel 6

Can someone explain me if this new release of TWRP can be installed on Android 11 and how? There is no changelog or instructions.......

TWRP is dead. The quicker you accept that, the quicker you can move on with your life.

The TWRP team hasn't even successfully gotten it working on all Android 10 devices - just a select few.

(Please don't take this as a knock against the TWRP team. They did miracles for years, but their luck ran out with the changes Google made with Android 10 and 11. I totally respect that team and I wish them well).
 

BlueShanka

Member
Mar 22, 2021
6
2
I think I messed up when updating OTA.
Previously running LineageOS 17.1, I recently updated to a recent nightly build. Before the update installed, I disabled the modules, as per Magisk Instructions, then installed the update and booted to system.
Now in Magisk, I am unable to patch any boot.img or recovery.img! Wondering what to do? Completely uninstall/reinstall Magisk? If so how? It was a while back I originally did it and hours of searching isn't giving me the right info. I have Lineage's recovery, but can't figure out what to do from here to get Magisk working again.
Any ideas? Thanks.

EDIT: Nevermind, I needed to go into the LineageOS Recovery -> Update -> ADB.
then run 'adb sideload magisk.zip' in cmd.
 
Last edited:

Ansshkki

Member
Dec 30, 2019
7
0
I have no OTA update available for security patches, only for android upgrades, no problem with that... I am updating my android with sideload way, and everything goes well.
but today, I were updating to April security patch, by a mistake, I flashed magisk_patched.img file before installing ota file 😅
After that, the system booted normally, so I installed ota file then magisk boot image file, after that I have the error "cannot load android system your data may be corrupt" and the system isn't booting.
Installing ota file another time solved the problem but without root access.
What can I do?
 
I have no OTA update available for security patches, only for android upgrades, no problem with that... I am updating my android with sideload way, and everything goes well.
but today, I were updating to April security patch, by a mistake, I flashed magisk_patched.img file before installing ota file 😅
After that, the system booted normally, so I installed ota file then magisk boot image file, after that I have the error "cannot load android system your data may be corrupt" and the system isn't booting.
Installing ota file another time solved the problem but without root access.
What can I do?
Magisk is both a .apk and .zip with a simple rename. Sideload the Magisk.zip from recovery and it will patch your boot partition. (same solution as previous post)
TWRP is dead. The quicker you accept that, the quicker you can move on with your life.

The TWRP team hasn't even successfully gotten it working on all Android 10 devices - just a select few.

(Please don't take this as a knock against the TWRP team. They did miracles for years, but their luck ran out with the changes Google made with Android 10 and 11. I totally respect that team and I wish them well).
'Move on' as in a Linux phone? What OS has endured without a partition level backup solution? The future is pocket sized modular all-in-ones. My next phone will likely run Phosh.
 
Last edited:
  • Like
Reactions: Ansshkki

Ansshkki

Member
Dec 30, 2019
7
0
Magisk is both a .apk and .zip with a simple rename. Sideload the Magisk.zip from recovery and it will patch your boot partition. (same solution as previous post)

'Move on' as in a Linux phone? What OS has endured without a partition level backup solution? The future is pocket sized modular all-in-ones. My next phone will likely run Phosh.
So... This entire post on how to root Pixel 3a can be shortened to this simple step?

And some another question please, latest releases of magisk have combined the apk and zip into one single apk with the same version... Where can I get the zip file now?
 
Last edited:

purgy

Senior Member
Aug 29, 2013
104
17
Sydney
I'm having the same issue with magisk 22.1 patched may boot image failing to no valid boot slot error.
I tried the win 7 version of powershell, with the same result. flashing a stock boot image lets the device boot normally.

I was kind of apprehensive about the upgrade to 11, and now this :/

Now im just wondering if i have the necessary permissions without root to delete stuff from the magisk dir that could be causing issues

adb wait-for-device shell magisk --remove-modules has no effect with the magisk patched boot image in place
 
Last edited:

Vinotas

Senior Member
Jan 5, 2012
112
21
Anyone know if our Pixel 3a is getting Android 12? If so, same installation process for rooted phones?
 

sic0048

Senior Member
Jun 25, 2010
962
503
Google Pixel 6
Just a note about Android 12 betas: I can confirm that the regular root method (Boot Image Patching method) does work on the Android 12 Beta 1 release. You must be using the Canary builds of Magisk (and select the Canary Update channel in settings), but other than that there is no special steps to take.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    @sic0048 for pixel 3a and pixel 3a XL rooting Android 12 is the same as for Android 11, no further steps required especially no flashing / changing vbmeta.
    1
    @sic0048 for pixel 3a and pixel 3a XL rooting Android 12 is the same as for Android 11, no further steps required especially no flashing / changing vbmeta.
    Thanks. I've noted this in the OP.
    1
    @Vinotas I never take the OTA but do the update manually, i.e. I download the factory image, extract the boot.img patch the boot.img with Magisk installed on the phone and push it back to my pc.
    After that I unhide Magisk-Manager and boot to bootloader. I modify the flash-all script by removing the -w and disable rebooting after flashing is finished and execute the flash-all script.
    After flashing is finished I manually boot to bootloader again and flash the prepared patched boot.img and finally do the boot of the system.
    Last step is hiding Magisk-Manager again ... I think hiding/unhiding is not even needed.
    1
    @Vinotas well, I do want to be secure to have a working phone without loosing root a single moment, that's the reason I am doing the updates manually.
    1
    @Vinotas Well, "fastboot flash ..." is flashing into the current selected slot and overwrites everything installed already there. But I agree the process is a bit longer and one needs to get familiar with it.
  • 43
    Edit - just an FYI for complete transparency. I have moved from the Pixel 3a XL to the Pixel 6. I no longer own my Pixel 3a XL. While I've been told (thanks @AndDiSa) that the root process for Android 12 is the same as it historically has been, I no longer can test things myself. (The root process for the Pixel 6 is different and more complicated than this phone). If you run into any problems or issues, please post in this thread and someone will hopefully be able to answer them.

    I'm assuming you understand how to use ADB on your computer. If you need assistance with installing or using ADB, please refer to this XDA article for more information. However, here are some common issues that people have with ADB if it doesn't work initially for you. 1) Check the Android System Notification that appears in your phone's notifications after you plug in your USB cord. Your phone probably defaults to "No data transfer" and you need to change it to "file transfer" to allow the phone to connect. 2) Make sure you have USB debugging turned on in the Settings/System (advanced)/Developer options. 3) If this is your first time using this phone/computer combination, you will have to accept the connection when it pops up on your phone.

    You also need an unlocked bootloader to complete these steps. If you need assistance with unlocking your bootloader, here is decent set of instructions. Those instructions are based on the Pixel 3 phone, but the steps are the same for the 3a devices.

    Here are the official Magisk installation instructions. I will walk through them to help everyone understand them. Please note that while TWRP does work with Android 9 (Pie), it does not work currently with Android 10 or 11. If you are still on Pie for some reason you can choose either installation option, but if you have moved to a later Android version, you must use the "Boot Image Patching" installation method.

    Custom Recovery Installation Method - (available for Android Version 9/Pie only because TWRP does not work currently with the Android 10/11)
    This is the easier installation method IMHO, but it does require using TWRP. If you don't know how to get TWRP for the Pixel 3a, please refer to the official TWRP for Pixel 3a thread
    Step 1 - Download and install the Magisk manager app on your phone. (link to the latest stable version can be found here).
    Step 2 - Using the Magisk manager app, select "Install Magisk" and select the "Download Zip Only" option. This simply downloads the installation zip to your phone's download folder. It doesn't attempt to install anything.
    Step 3 - Boot into TWRP - (because TWRP is not permanent on the stock Pie OS, we must follow these instructions each time we want to boot into TWRP).
    Step 3a - Download the latest TWRP image for the 3a to your computer (not your phone) from the official TWRP for 3a thread.​
    Step 3b - Connect to your phone via ADB on your computer. You should see the device listed if you type the command "adb devices".​
    Step 3c - Boot your phone into the bootloader (type the command "adb reboot bootloader").​
    Step 3d - Boot into TWRP using this command, "fastboot boot twrp-3.x.x-x.img" (where "twrp-3.x.x-x.img" = whatever the name of the TWRP download is). Please note you are not using the "flash" command as we are not permanently installing TWRP.​
    Step 4 - Once the device boots into TWRP, select "Install" and then find the Magisk.zip download from step 2. Swipe to confirm the installation
    Step 5 - After the installation is complete, simply reboot system.
    Step 6 - Enjoy your rooted phone and install any Magisk modules that appeal to you
    Step 7 - Be sure to turn off the "Automatic System Updates" setting found in Developer settings (Settings /System (advanced) /Developer Options). This will prevent the phone from automatically installing an OTA update and instead allow you to follow the steps listed under the "Taking an OTA Update" section below

    The Boot Image Patching Installation method - (the only method currently available under Android 10, 11 or 12, but it also works with Pie).
    Use this method if you are on Android 10 or 11 or you are on Android 9/Pie but you don't want to or can't use TWRP.
    Step 1 - Obtain a stock boot.img file for the OS version/update that you are currently on. The easiest method is probably to download the applicable full stock image directly from Google. Unzip the files and unzip the second folder and you should find the boot.img file inside.
    Step 2 - Copy the stock boot.img file to your phone's storage - probably to /sdcard or to /sdcard/downloads
    Step 3 - Download and install the Magisk manager app on your phone. (link to the latest version can be found here). If you are early in the Android 12 cycle, you probably need to use a Canary build of Magisk.
    Step 4 - Using the Magisk manager app, press "Install --> Install --> Select and Patch a File" - select the stock boot.img file that you put on your phone in step 2.
    Step 5 - Magisk will modify the stock boot.img file and create a patched boot image file. It will save this modified file at "sdcard/Download/magisk_patched.img"
    Step 6 - Connect to your phone via ADB on your computer. You should see the device listed if you type the command "adb devices".
    Step 7 - Copy the patched boot image from your device to your PC and the adb folder. If you can’t find the file on your phone via MTP or Windows Explorer, you can pull the file by typing the command "adb pull /sdcard/Download/magisk_patched.img" - Please note, I would suggest double checking the "file modified date" prior to moving the file. Be sure to only move the file if it was last modified on the date you are doing this. I've had a strange situation before where the newly modified file didn't immediately show up and the file showed a modified date of the previous month. If you flash an old version, your phone will bootloop.
    Step 8 - Boot your phone into the bootloader (type the command "adb reboot bootloader").
    Step 9 - Flash the patched boot image to your device using this command, "fastboot flash boot magisk_patched.img"
    Step 10 - Reboot (using command "fastboot reboot").
    Step 11 - Enjoy your rooted phone and install any Magisk modules that appeal to you
    Step 12 - Be sure to turn off the "Automatic System Updates" setting found in Developer settings (Settings /System (advanced) /Developer Options). This will prevent the phone from automatically installing an OTA update and instead allow you to follow the steps listed next.......

    Taking an OTA update in the future (if you used this method to install Magisk).
    Taking OTA updates is very easy with the Pixel devices because of their A/B partition system. It allows us to uninstall Magisk, take the OTA update, and reinstall Magisk - all from the phone and all without rebooting during the process. Here are the offical Magisk OTA instructions. I will go through the steps to help explain them.

    Step 1 - In the Magisk manager app: Click “Uninstall” then “restore images”. DO NOT REBOOT or press the reboot button.
    Step 2 - Download and install OTA (in your phone's Settings/System/System Update). DO NOT REBOOT or press the reboot button.
    Step 3 - Open the Magisk manager app and click “Install” next to Magisk (usually it says "Magisk is up to date") then “Install to second/inactive slot (After OTA)”
    Step 4 - Press the Reboot button in Magisk.

    That should be all it takes to install an OTA and keep root.

    Please note, we are getting reports that users are getting notifications that an OTA update has been installed even when they have "Automatic Updates" turned off. If this happens to you, don't reboot the phone which is suppose to be the final step in the update process. Instead, follow the above instructions on taking an OTA update, but start in step 3. In other words, you shouldn't have to uninstall Magisk because the update has already been installed. All you need to do is install Magisk to the "second/inactive slot (After OTA)”. After completing that step, you can reboot your phone to complete the update process. Be sure to post your experiences in this thread to let us know if this process works or not.

    Just remember that many custom parts (like kernels and Magisk modules) may need to be updated to any new OTA version. Please be sure to check out the forums for each custom kernel or module that you may want to install to ensure it has been updated to the lastest OS version. Don't assume anything or you may find yourself in a bootloop.

    If you find yourself in a bootloop after upgrading an already rooted phone
    If you find yourself in a bootloop after updating to a new OS version and flashing the magisk_modified boot.img again, it is likely due to an installed Magisk module not being compatible with the new update. To uninstall all Magisk modules to fix the bootloop, follow these steps:

    Step 1 - Connect your phone to the computer you use ADB on.
    Step 2 - In ADB type the command "adb wait-for-device shell magisk --remove-modules"
    Step 3 - Start your phone again or wait for it to go through another bootloop cycle.
    Step 4 - as soon as ADB is available (which occurs even during a bootloop) the command will activate, the modules will be removed, and the phone will reboot.

    If the normal OTA method isn't working - sideload the OTA update
    Taking an OTA update should be as easy as the above instructions. However there is another option available to install an OTA update called sideloading. Sometimes the update doesn't appear on the phone in a timely manner and you may want to manually install the update. Other times the OTA update seems to fail for some reason. In the end, you may decide to sideload the OTA instead of trying get it via the update feature on the phone. Surprisingly, it's actually faster to install the update via sideloading than it will be to take the OTA normally. I'll walk through the sideloading steps.....

    Optional Step 1 - Uninstall Magisk (so that it restores the stock boot.img). If you find yourself unable to boot into recovery, you will have to restore the stock boot.img. I've run into this issue on a couple Android 10 images, but most do not require this step.
    Step 2 - Download to your computer the correct OTA image from here
    Step 3 - Connect to your phone via ADB on your computer. You should see the device listed if you type the command "adb devices".
    Step 4 - Boot your phone into recovery (type the command "adb reboot recovery").
    Step 5 - The phone will have a green android robot with a red sign over it's open access panel. Press the power button and then the volume up button while still holding down the power button.
    Step 6 - Select "Apply update from ADB" using the volume buttons to highlight the choice and the power button to select it to enter the sideload mode.
    Step 7 - Using your computer, type "adb sideload ota_file.zip" where ota_file.zip is the name of the OTA file you downloaded in step 2.
    Step 8 - Once the update finishes, reboot the phone to complete the update process. (See note below about initial boot times).
    Step 9 - To obtain root again, please use one of the two root methods listed above

    Please note, while the initial boot is usually pretty quick, it can take longer. I've occasionally seen the process take upwards of 20 minutes and longer. I think part of the reason it can take so long is that sometimes it optimizes the apps during this boot process. The more apps you have, the longer the process may take. When you take an regular OTA update, the phone will change to a screen where is specifically tells you it is optimizing the apps and counts up as the apps are optimized to give you status updates. When you use the side-load method, it all happens with just the regular boot animation running and without any status updates. Because of this, it is easy to assume something has gone wrong with the boot process while in fact the phone is working through the process normally. If it isn't boot looping (showing the initial power screen before moving back to the boot animation), everything is fine and you just need be patient and let the phone complete the process.

    My rant about using these "Pre-patched Boot image" files
    I started this thread during a period of time where there was a another thread on this forum started by pbanj that showed users how to root their phone by using some pre-patched boot image files. This method is not the generally accepted method and while it works, there are major shortcomings with it (see explanation below). Because it was the only root thread available at the time and he only showed the "pre-patched boot image" method, many people blindly followed his directions only to be confused when it came time to update the software on their phones. I wrote this thread in an effort to show people the official Magisk installation method. Pbanj has since updated his thread and it now includes the preferred method as well. With his edits, the two threads are sharing the same information now, although Pbanj thread still offers people the "pre-patched boot image" method (which I don't recommend people using).

    EDIT - Yet another thread pushing a pre-patched root method has been started. It suffers the same issues as listed below.

    Shortcomings with using the "pre-patched boot image" method.
    As I already mentioned, there is a huge shortcoming with using the "pre-patched boot image" method described in the other root thread. Because he provides a pre-patched boot.img file, you skip some normal installation steps. In the end you have the exact same patched file (which is why his method works), but you cripple the system when it comes to taking any future OTA. That's because the first step in taking an OTA update is having Magisk reflash the stock boot.img effectively uninstalling itself. This step fails if you used his pre-patched boot image method because you skip the step where Magisk creates the backup of the stock boot.img that it needs to uninstall itself.

    I already used the "pre-patched boot image" method to gain root. What can I do?
    First, let me clarify and say that there is nothing wrong with your phone or root privileges. Your phone will work exactly as expected and root and Magisk will work exactly as expected. That being said, in the near future you will want to update your phone to the latest Android update and this is where the "pre-patched boot image" method is much more cumbersome. The best option is to simply undo his root method and re-root using the method described above. To do this, flash the correct stock boot.img file to your boot partition and then follow the steps above to reinstall Magisk. Jbanj has confirmed this method will work. The other option is just wait until you need to take an update and then sideload the OTA update following the instructions above. This will remove root and you can then follow one of the two methods to obtain root as outlined in this thread.

    Notes
    - Please be sure you are on the latest adb and drivers which can be found here.
    - You do not need to keep the stock boot.img file (from step 2 of the Boot Image Patching method) on your phone after completing these steps. Magisk saves the stock boot.img backup at /root/data in a file with the name "stock_boot_XXXXXXXXXXXX.img.gz"

    Thanks to.......
    @ZVNexus for getting TWRP working on the 3a and 3a XL phones
    @topjohnwu for making Magisk what it is today
    4
    @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).
    4
    @sic0048 I've updated my thread
    3
    You know there are more ways to skin a cat, right? This is another method to acquire root. I don't think you need to bash the work that pbanj has done. He provides modified boot.img and also offers help on getting it working. I think acting like your method is the only acceptable way to gain root is extremely pompous and arrogant.

    Sent from my Pixel 3a using Tapatalk
    3
    You know there are more ways to skin a cat, right? This is another method to acquire root. I don't think you need to bash the work that pbanj has done. He provides modified boot.img and also offers help on getting it working. I think acting like your method is the only acceptable way to gain root is extremely pompous and arrogant.

    Sent from my Pixel 3a using Tapatalk

    I don't think that this method is the only way to get root, nor is this "my method". It is however the method spelled out by the Magisk developers and it is the only method that uses Magisk strengths when trying to take an OTA update.. I'll simply leave it at that......