How to Root Sony Xperia XZ install TWRP unlock bootloader
How to Root Sony Xperia XZ

Sony’s new Flagship smartphone, the Xperia XZ with SD820 & 3GB of RAM is a sweet deal with Sony’s premium built quality.  Now as usual, rooting your smartphone can give you additional functionality and control over your device. If you don’t know what Rooting is then, here is a link to more information. Once, you have decided to root, you need to check some prerequisites.

DISCLAIMER: Your warranty will be void. Please proceed at your own risk.

Prerequisites

  1. Minimal ADB: Setup ADB and Fastboot
  2. Sony Xperia XZ USB Drivers: Download
  3. Charge your device upto 50% to avoid any shutdown during the process. We won’t be responsible if your device gets bricked during to no charge.
  4. Backup all your data, Apps, contacts & everything your need. Although this process won’t erase any data (except unlocking bootloader), we need to create a restore point in order to restore if anything goes wrong.

How to Root Sony Xperia XZ

  1. Unlock Bootloader: Opens the door to System files of your device. This allows you to flash images onto the main system partitions of the phone.
  2. Install a Custom Recovery: A custom recovery is flashed onto the recovery partition of the device and overwrites the stock recovery that exists by default. Custom recoveries bring lots of functionality and allows you to perform wipes, install flashable zips, create full backups of your NAND (Nandroid backup), and various other features. An unlocked bootloader is needed to install a custom recovery.
  3. Install SuperSU zip: You can gain root by flashing SuperSU through a custom recovery. A custom recovery allows flashing the SuperSU files into the system files. You can unroot your Android device in just one click.

Unlocking bootloader can cause some deterioration in low light camera performance and loss of DRM keys. It will also factory reset your device and format your data. BACKUP your device first!

How to unlock Bootloader on Xperia XZ

The first step to rooting your device or flashing ROM is to unlock the bootloader. To prepare your device to be unlocked follow the following steps:

Sony Xperia XZ unlock Bootloader
Sony Xperia XZ unlock Bootloader
  1. Open your dialer.
  2. Dial *#*#7378423#*#*
  3. Click on Service info/Configuration.
  4. Check if “Bootloader Unlock” is yes under Rooting status. If not then your device can not be unlocked.

If you’re still here then let’s proceed. Before you unlock the bootloader BACKUP your media (photos, videos etc from internal storage) as this will wipe your data. You will also have to make a backup of your TRIM area partition. Follow the steps to do this :

  1. Check what android you are running on. Go to Settings -> About Phone -> Android Version. If you have 6.x.x then skip to step 6 but if you have 7.x.x then you have to downgrade to Marshmallow.
  2. Download FlashTool from its official website.
  3. Install the drivers for fastmode and for your device in the driver folder of the FlashTool.
  4. Click on XperiFirm and select Xperia XZ then F8831 or F8832. Click on “Check All” on the top right and choose 39.0.A.1.250 firmware.  Just click on the fw name and download it. Close it after download, and close XperiFirm. FlashTool will now unpack the new firmware, wait for the end. Then click on Flash. Choose Flashmode options and select the downloaded firmware.
  5. Now put the phone into fastboot mode by turning it off and pressing VOLUME DOWN and plug the USB simultaneously. You will see a green LED. Wait untiil FlashTool says DONE. Reboot and now you are on Marshmallow.
  6. Download the “backup-TA.zip” : Link
  7. Enable USB Debugging by going into Settings -> About Phone -> tap build number until a pop up shows “You’re now a developer”. Locate Developer Options in your Settings and enable “USB Debugging.”
  8. Run backuipTA.sh if you are on Mac or BackupTA.cmd if you are on windows.
  9. Your partition will be saved as TA-ModelNumber-Serial-Timestamp.img. Keep it safe!

How to get Unlock Code for Sony Xperia XZ

Go to Sony Unlock and follow the steps below:

Sony Xperia XZ Unlock Code
Sony Xperia XZ Unlock Code

 

  1. Ensure that OEM Unlocking and USB Debugging is ON under Developer Options.
  2. Choose Xperia XZ at the bottom of the page.
  3. Enter your Email and you will receive a link in your mail. Follow the steps given by Sony.
  4. BE CAREFUL and, from now on, DON’T ENABLE the MyXperia. It could hard brick your phone.

Now your device is unlocked. We will noow go over some other fixes.

Flashing AndroPlus kernel to fix Battery issue

This kernel will help your device cope up with some battery issues and it also has some DRM Fixes. To install it, follow the steps :

  1. Download the kernel from here.
  2. Unzip the downloaded file and paste them into your fastboot directory.
  3. Now Boot into Bootloader mode by turning the device off and pressing VOLUME UP while plugging in the USB or use adb command – adb reboot bootloader
  4. Run the command prompt where your fastboot files are located. Do this by shift+right click and selecting Open command prompt here.
  5. Flash the kernel by the command – fastboot flash boot boot.img
  6. Reboot your device.

How to Flash TWRP in Sony Xperia XZ

This process will provide your device a custom recovery (TWRP) This can be used to flash root script, ROM and custom kernels at anytime without PC.

  1. Download TWRP image file.
  2. Paste it in your Fastboot directory and rename it as recovery.img.
  3. Flash the recovery by the command : fastboot flash recovery recovery.img
  4. Reboot your device into recovery. Press VOLUME DOWN and POWER.

How to Root Xperia XZ by SuperSU

Now to the final step. To root your device all you’ll need to do is flash the SuperSU via recovery or install the SuperSU from the play store.

  1. Download the flash image of SuperSU – Download
  2. Paste it in your device’s storage.
  3. Now Boot into recovery manually or via the command adb reboot recovery
  4. Now select install and navigate to the downloaded SuperSU image. Swipe to flash. Wait for it to complete.
  5. Reboot and check if you have SuperSU present in your apps.

Congratulations, now you are rooted!

Restore TA partition and Relock Bootloader

If you ever want to return to the stock or you want to return your device to service you will need to flash the stock and relock the bootloader.

  1. Backup all the data as your device will reset and formatted after this process.
  2. Rename your backed up TA partition and rename it TAbackup.img
  3. Boot into TWRP.
  4. Plug your device in your pc via USB and check the connection by the command adb devices in command prompt in your fastboot directory.
  5. Now run the command adb push TAbackup.img /data/local/tmp/TAbackup.img
  6. Then run adb shell dd if=/data/local/tmp/TAbackup.img of=/dev/block/bootdevice/by-name/TA
  7. Now flash Stock ROM via FlashTool and your device will have original DRM and stock ROM and Ta partition.

Congratulations! Now you have successfully rooted your device and learned how to return to stock and backup TA partition. Sony Xperia XZ is an amazing device and with root its capabilities increases even further. If you have any questions, post it in the comment section below.