LightBlog

dimanche 16 octobre 2022

How to install OTA updates and keep root on your Google Pixel phone

Part of the beauty of owning a Google Pixel phone comes through the proper availability of firmware images that can be used to return the device to a factory state. Even if you unlock the bootloader, root the phone, or tinker a bit too much, you may find yourself looking for a last resort to restore the stock configuration before taking the monthly security updates. While many hardcore Android fans will know exactly what to do, not everyone is as adept at getting their phone updated without losing root.

If you have access to a PC/Mac and are happy to take matters into your own hands, you can easily keep root access by performing a few extra steps in addition to sideloading the OTA update on your Google Pixel. In this tutorial, we’re going to show you how.

Navigate this article:

Pixel 6 Pro with bloom wallpaper on window sill



How rooting affects the capability of installing OTA updates

Rooting involves modifying parts of the Android boot image so as to gain superuser access. A regular monthly OTA or “over-the-air” update is incremental in nature, which means it can’t apply the delta patch to upgrade the stock boot image due to an obvious binary mismatch in a rooted environment. While opting for the full update package is a viable solution to this problem, it will eventually overwrite the bits and pieces required for root access from the boot partition.

So for those of you who plan to get dirty with your Pixel and may need a savior down the road, we thought we’d make sure you know how to keep root access across monthly security updates. The process isn’t difficult, but it does require a few ADB and Fastboot commands.


How to keep root and take OTA updates on your Pixel

Before starting, note that this tutorial assumes you have an unlocked bootloader and are already rooted with Magisk. Moreover, make sure that you have the latest ADB and Fastboot binaries installed on your PC/Mac and that the target device can be detected by these tools.

There are a few ways to get your Pixel update to the latest official Android build while keeping root. You can restore the stock boot image of the base version, wait until your phone gets a notification that will prompt you to download any waiting updates to your phone (or sideload the update manually), then patch the updated boot image and flash it. This is a bit slower but recommended method for beginners.

A relatively quicker method to get the very latest update on your Google Pixel while keeping root is to flash the official factory image with a pre-patched boot image. Keep in mind that both methods rely on access to a PC or Mac. None of them requires you to wipe the device, but it’s good practice to backup any irreplaceable data in case something goes wrong.

  1. Locate the exact version number of the currently installed software on your Google Pixel phone. Navigate to Settings > About phone and note down the text under the Build number section.
  2. Now we need to restore the untouched boot image corresponding to the installed build. As a precautionary measure, open Magisk, switch to the Modules tab, disable the active modules, and restart once before doing so.
    • Depending on the method of patching, the Magisk app might keep a backup of the stock boot image. In that case, you should be able to restore them through the Restore Images option under the after the Uninstall menu of the Magisk app. Nonetheless, we recommend flashing the untouched boot.img from the factory image to avoid any unforeseen issue.
  3. Download the fastboot-flashable factory image corresponding to the current Android build number for your Google Pixel phone on your PC/Mac. It should be named as <device codename>-<build number>-factory-<hash value snippet>.zip.
  4. Open the factory image using your favorite archive manager, locate the image-<device codename>-<build number>.zip file (yes, there’s a ZIP within a ZIP), and extract the boot.img file from it.
    Google Pixel 6a firmware stock boot image
  5. Install the stock boot.img for the current Android build number:
    1. Make sure USB debugging is enabled on the phone and the adb devices command on the computer returns the phone’s serial number.
    2. Reboot to the phone to the bootloader mode: adb reboot bootloader
    3. Flash the stock boot image: fastboot flash boot <full patch of the stock boot.img>
    4. Reboot: fastboot reboot
  6. You can now force your phone to pull any waiting updates by heading to Settings > System > System update > Check for updates. Alternatively, download the latest recovery-flashable full OTA image for your model and sideload it manually.
    • Don’t choose the latest factory image for upgrading, as the inbox flashing script will wipe the device by default.
  7. Now that you’re on the latest build, it’s time to patch the boot image with Magisk for regaining root access. We have a dedicated tutorial for how to install Magisk, so take a look at it if you need any help.
  8. Once your phone has rebooted after flashing back the patched boot image, you should be safely updated with the very latest OTA with root access.

Quick method

  1. Download the factory image corresponding to the latest update for your Pixel phone on your PC/Mac. You can either do it from Google’s download portal or from our Android 13 download index.
  2. Unpack the factory image using your favorite archive manager, locate the image-<device codename>-<build number>.zip file, and extract the boot.img file from it.
  3. Patch the stock boot image using Magisk, but don’t flash it on your phone yet.
  4. Copy the Magisk-patched boot image from your phone to your PC/Mac and rename it to boot.img.
  5. Open the image-<device codename>-<build number>.zip file from step 2 with the archive manager of your choice and replace the stock boot image file in it with the one from step 4.
    • Windows users are suggested to use 7-Zip, so that a simple drag-and-drop should be enough to push the patched file into the archive.
    • Linux and macOS users can use the built-in zip utility to replace the stock boot image with the patched boot image in the factory firmware:
      zip image-<device codename>-<build number>.zip boot.img
  6. In order to remove the data wipe routine, modify the flashing script like the following:
    • If you’re on Windows, then open the file named “flash-all.bat” with Notepad (or your favorite text editor), remove the “-w” parameter from the fastboot flashing segment, and save the file.
      Google Pixel 6a October 2022 flash-all.bat original Google Pixel 6a October 2022 flash-all.bat modified
    • For Linux and macOS, open the file named “flash-all.sh” with your favorite text editor, remove the “-w” parameter from the fastboot flashing segment, and save the file.
  7. Reboot your Pixel phone to the bootloader mode and perform the flashing operation using Fastboot.
  8. If everything goes right, the phone should reboot automatically into the latest OS version — that too with a pre-rooted boot image.

Google Pixel 6a running Android 13 October 2022 build rooted with Magisk

Don’t have access to a computer? While it is possible to direct Magisk to install itself to the inactive slot before taking an incremental OTA and keep root after the update, you might stumble on some unexpected roadblocks in this process. Thus, we recommend patching the boot image yourself and flashing it using a PC.


Verification

A simple way to check if you have followed all of these steps correctly is to head to Settings > About phone > Android version. You should see the exact patch and build number that you have sideloaded on your Google Pixel device.

Next, open the Magisk app from app drawer and the Magisk build number should be listed beside the “Installed” parameter, indicating that you’ve successfully managed to complete the process.



If you have any questions regarding rooting your Google Pixel phone, make sure to leave them in the comment section below.

The post How to install OTA updates and keep root on your Google Pixel phone appeared first on XDA.



from XDA https://ift.tt/3IQhcVq
via IFTTT

Aucun commentaire:

Enregistrer un commentaire