jeudi 20 mai 2021

How to Root your Android smartphone

Welcome to the XDA-Developers Root Directory. Here, you can find root tutorials for most devices that are on the XDA Forums. Learn how to root any Android device, even the best Android phones! If you don’t see your device listed or you see a misplaced link, send a message to Skanda Hazarika (SkandaH on the forums) with the device details.

Table of Contents:


What is Root?

For those new to the world of rooting, acquiring root access essentially grants you elevated permissions. With root access, you are able to alter or replace system applications and settings, run specialized apps that require administrator-level permissions or perform other operations that are otherwise inaccessible to a normal Android user. And by proxy, you may also be able to access certain “hidden” device features or use existing features in new ways.

DISCLAIMER: Rooting a device may void the warranty on the device. It may also make the device unstable or if not done properly, may completely brick the device. XDA-Developers or the author does not take any responsibility for your device. Root at your own risk and only if you understand what you are doing!


How to root a popular Android smartphone

We can go on about the virtues of root access ad infinitum, but we’ll stop for now because we sense you salivating at the prospect of root access and what you can do with your device once root is achieved. Head to the following section to begin the journey. You should find device-specific root guides for latest flagship models from every major OEM below.

ASUS

Sr. No. Device Codename and Device Forum Root Guide
1. ASUS ROG Phone 5 I005D Click Here

For other ASUS devices, kindly check out the ASUS section of our forums. You should be able to find similar fine-tuned guides for your device under the device sub-forums. You can also follow the generic rooting guide from this tutorial.

Google

Sr. No. Device Codename and Device Forum Root Guide
1. Placeholder Placeholder Click Here

For other Google devices, kindly check out the Google section of our forums. You should be able to find similar fine-tuned guides for your device under the device sub-forums. You can also follow the generic rooting guide from this tutorial.

Motorola

Sr. No. Device Codename and Device Forum Root Guide
1. Motorola G100 / Edge S nio Click Here

For other Motorola devices, kindly check out the Motorola section of our forums. You should be able to find similar fine-tuned guides for your device under the device sub-forums. You can also follow the generic rooting guide from this tutorial.

OnePlus

Sr. No. Device Codename and Device Forum Root Guide
1. OnePlus 9 lemonade Click Here
2. OnePlus 9 Pro lemonadep Click Here

For other OnePlus devices, kindly check out the OnePlus section of our forums. You should be able to find similar fine-tuned guides for your device under the device sub-forums. You can also follow the generic rooting guide from this tutorial.

Samsung

For other Samsung devices, kindly check out the Samsung section of our forums. You should be able to find similar fine-tuned guides for your device under the device sub-forums. You can also follow the generic rooting guide from this tutorial.

Sony

Sr. No. Device Codename and Device Forum Root Guide
1. Sony 1 III pdx215 Click Here
2. Sony 5 III pdx214 Click Here

For other Sony Xperia devices, kindly check out the Sony section of our forums. You should be able to find similar fine-tuned guides for your device under the device sub-forums. You can also follow the generic rooting guide from this tutorial.

Xiaomi

For other Mi, Redmi, and POCO branded devices, kindly check out the Xiaomi section of our forums. You should be able to find similar fine-tuned guides for your device under the device sub-forums. You can also follow the generic rooting guide from this tutorial.


How to root any Android device

Nowadays, Magisk is the de-facto rooting solution that lets you have root access by leaving the system partition untouched and modifying the boot partition. This is why it’s referred to as a “systemless” root method.

Before getting started with Magisk, make sure that:

  1. You have access to a PC/Mac with adb and fastboot installed.
  2. The bootloader of the target Android device is unlocked.
    • For Samsung devices, unlocking the bootloader will trip KNOX.

Step 1: Identifying the type of the boot image

Download the latest version of the Magisk app from the project’s GitHub repository. Since the APK of Magisk is hosted outside of the Google Play Store, you may need to allow sideloading apps from unknown sources first and then manually install the downloaded package.

After installing, open the Magisk app. You should see a screen like this:

Magisk main app window

Now, we need to note down the values of the following parameters:

  1. Ramdisk
  2. A/B
  3. SAR

Step 2: Locating the boot image

In order to patch the boot image for your device, you need to extract it from the official firmware packages. In case you’re using a custom ROM like LineageOS, then the flashable ZIP file contains the boot image.

Case I: You have access to the recovery-flashable ZIP file

If you have a device that still uses the A-only partition scheme, then you can find the boot.img right inside the recovery-flashable ZIP file. Just extract it using a suitable archiver program.

POCO M3 boot.img inside recovery ZIP

Notice the boot.img file inside POCO M3’s recovery ZIP

However, if your device utilizes the A/B partition scheme, then the boot image and other partition images are further packed inside a file named payload.bin as shown below.

Google Pixel 5 payload.bin inside recovery ZIP

The recovery ZIP of the Google Pixel 5 contains a payload.bin file

In that case, you have to extract the payload.bin file first, then use one of the community-developed payload.bin unpackers to get the boot.img out of it. We strongly suggest you opt for the extractor written in Go as it is cross-platform and has been actively developed.

Known as “payload-dumper-go”, this fork even allows end-users to extract a single partition image without unpacking the whole payload.bin, which is particularly useful for this usage scenario.

  • First, use the -l parameter to list the partition images inside the payload.bin.
    payload-dumper-go -l payload.bin
  • Then use the -p parameter with the name of the boot image (commonly stored as “boot”) to extract it.
    payload-dumper-go -p boot payload.bin
ASUS ROG Phone 5 boot.img from payload.bin

Extracting the boot.img of the ASUS ROG Phone 5 from its payload.bin

Case II: You have access to the Fastboot-flashable image

A handful of OEMs like Google and Xiaomi provide Fastboot-flashable factory images for their devices. If you managed to grab such a package, then the raw boot.img can easily be extracted from the archive.

Google Pixel 5 boot.img from Fastboot package

The location of the boot.img inside the Google Pixel 5’s Fastboot firmware

Special Case: Samsung

Samsung Galaxy devices don’t a traditional Fastboot interface, hence their factory images are packed differently.

  1. Use Samsung Firmware Downloader to download the factory image for your model.
  2. Unzip the decrypted package and locate the AP tar file to your device. It is normally named as AP_[device_model_sw_ver].tar.md5.

Step 3: Patching the boot image

Now that we have the boot image in hand, we should proceed with the patching part.

Case I: The value of the “Ramdisk” parameter is “Yes”

  1. Copy the boot image to your device. In fact, you can patch it on a different Android device than the target one, but you need to install the Magisk app on the secondary device as well.
  2. Press the Install button in the Magisk card.
  3. Choose “Select and Patch a File” in method, and select the stock boot image.
    Magisk select and patch image
  4. The Magisk app will patch the image to [Internal Storage]/Download/magisk_patched_[random_strings].img.
    Magisk is patching a boot image
  5. Copy the patched image to your PC with ADB:
    adb pull /sdcard/Download/magisk_patched_[random_strings].img
  6. Flash the patched boot image to your device. For most devices, reboot into Fastboot mode and flash with the following command:
    fastboot flash boot /path/to/magisk_patched.img
  7. Reboot and enjoy root access!

Keep in mind that it is possible to patch the boot image on the fly on legacy devices having boot ramdisk through a custom recovery like TWRP, but the method is no longer recommended on modern devices. Having said that, if you have an old phone and want to stick with the custom recovery route, the steps are as follows:

  1. Download the Magisk APK.
  2. Rename the .APK file extension to .ZIP (e.g. Magisk-v23.0.APK → Magisk-v23.0.ZIP).
  3. Flash the ZIP file just like any other ordinary flashable ZIP.
    Magisk flashing via TWRP
  4. Note that sepolicy.rule file of modules may be stored in cache partition, so do not clear it.
  5. Check whether the Magisk app is installed. If it isn’t installed automatically, manually install the APK.

Case II: The value of the “Ramdisk” parameter is “No”

In this case, you need to locate the recovery.img file from the factory image of your device instead of boot.img file. This is because Magisk needs to be installed in the recovery partition, which means you will have to reboot to the recovery mode every time you want root access.

  1. Copy the recovery image to your device (or a secondary device with the Magisk app installed).
  2. Press the Install button on the Magisk card.
  3. Choose “Select and Patch a File” in method, and select the stock recovery image.
  4. The Magisk app will patch the image to [Internal Storage]/Download/magisk_patched_[random_strings].img.
  5. Copy the patched image to your PC with ADB:
    adb pull /sdcard/Download/magisk_patched_[random_strings].img
  6. Flash the patched recovery image to your device. For most devices, reboot into Fastboot mode and flash with the following command:
    fastboot flash recovery /path/to/magisk_patched.img
  7. Reboot.

At this stage, there are three possible scenarios:

    • Power up normally: You’ll end up with no Magisk, i.e. no root access.
    • Recovery Key Combo → Splash screen → Release all buttons: The system should boot with Magisk and full root access.
    • Recovery Key Combo → Splash screen → Keep pressing volume up: To access the stock recovery mode

Special Case: Samsung

  1. Copy the extracted AP tar file to your device.
  2. Press the Install button on the Magisk card.
  3. If your device doesn’t have boot ramdisk, make sure “Recovery Mode” is checked in options.
  4. Choose “Select and Patch a File” in method, and select the AP tar file.
  5. The Magisk app will patch the whole firmware file to [Internal Storage]/Download/magisk_patched_[random_strings].tar
  6. Copy the patched tar file to your PC with ADB:
    adb pull /sdcard/Download/magisk_patched_[random_strings].tar
    • Don’t try to copy over the MTP interface as it is known to corrupt large files.
  7. Reboot to download mode. Open Odin on your PC, and flash magisk_patched.tar as AP, together with BL, CP, and CSC from the original firmware.
    • Don’t choose HOME_CSC because we want to wipe data.
  8. Your device should reboot automatically once Odin finished flashing. Agree to do a factory reset if asked.
  9. If your device doesn’t have boot ramdisk, reboot to recovery now to enable Magisk.
  10. Install the latest Magisk app and launch the app. It should show a dialog asking for additional setup. Let it do its job and the app will automatically reboot your device.
  11. Reboot and enjoy root access!

Step 4: Verification

The last step is to verify that everything is working properly. Locate the newly installed Magisk app and open it. We want to see a version number beside the “Installed” parameter. This means you have successfully obtained root. Great job!

A successful installation of Magisk


We hope this guide not only points you to the right threads for rooting your device but also provides general rooting instructions that can be applied for a large majority of Android devices generally. We’ll be updating this guide with links to further guides for specific phones, so check back again in the future!

The post How to Root your Android smartphone appeared first on xda-developers.



from xda-developers https://ift.tt/2iDAKO4
via IFTTT

Aucun commentaire:

Enregistrer un commentaire