[Pie 9.0] How To Root Sony Xperia XZ2/Compact/Premium – Using TWRP & Magisk

Sony Xperia XZ2 comes in three variants as Regular XZ2, Compact edition, Premium version. Each variant is formed to focus on a special audience.

But, the software and support are identical from Sony. All three options received Pie 9.0 upgrade. Sony is often high in maintaining regular patch updates.

So with the great Specs, you don’t need root Sony Xperia XZ2 to boost the performance. If you’re a daily user, you don’t need root.

After the basics, you’ll not get an officer update. You must manually update to urge the most recent features If you employ Stock ROM.

Your mobile needs regular optimizations also. You ought to deliberate before doing this.

If you’re a Developer or regular root apps user, you’ll be able to follow the below guide to attain root on your mobile. All three variant methods would be identical unless I discussed the various files.

Root Sony-Xperia-XZ2
Root Sony-Xperia-XZ2

Read the article thoroughly before starting the method. It’ll give some ideas for the preparation.

If you planned to flash Custom ROMs, you must check what’s going to work and whatnot. Unofficial ROMs may contain plenty of great bugs.

If you would like to put in the update using TWRP, after the firmware flash, you must flash Magisk anytime.

Why Should You Root Sony Xperia XZ2/Compact/Premium?

We thank XDA Developer- Topjohnwu, MartinX3 (Who successfully tested this method) and Linckandrea (For the Kernel file) Without their toil, We can’t make this method. Coming to root, you must have a correct reason, and you recognize what you’re doing.

Yes, with a minimum of 4/6 GB RAM and Qualcomm Snapdragon 845 processor, you’ll be able to use this mobile for normal tasks without root for 2-3 Years If you utilize correctly. Software is healthier compared with other manufacturers, Custom skin OS.

Don’t root because everybody is saying when root your mobile it can become fastest. No.

Rooting is to extract some performance from the device. But, you have already got Powerful specs and software. So, If you’re obsessed with some root apps, you’ll be able to root.

But, if you would like to check, I won’t recommend it.

How To Root Sony Xperia XZ2/Compact/Premium Pie 9.0

Sony Xperia XZ1 International Variants comes with a versatile bootloader apart from some carrier locked devices. This implies that different smartphone variants will be easily rooted.

Also, the device can accept to put in TWRP recovery or the other custom recovery file/app alike.

TWRP recovery could be a custom recovery file that must be installed on your devices because you’ll root them successfully. During this article, we explained the best method to follow and install TWRP recovery on Sony Xperia XZ1.

However, the tool required for rooting this device is that the Magisk App.

With the assistance of TWRP Recovery, you’ll be able to quickly flash the most recent version of Magisk into your Xperia XZ1 to achieve root access. Before sharing the tutorial, you will want to understand that, with the TWRP recovery present on your device, you’ll be able to easily install any custom ROM or firmware.

Does it seem complicated? Relax, everything is explained succinctly in bullets.

Things to check out for;

  • First of all, please check your device is charged more than 70%.
  • Please create a backup of your Android device before begin rooting.

Supporting versions

Xperia XZ2
  • H8216
  • H8266 Dual
  • H8276
  • H8296 Dual
XZ2 Compact
  • H8314
  • H8324 Dual
XZ2 Premium
  • H8116
  • H8166 Dual

Pre-Requirement Steps

OEM-Unlock-and-USB-Debugging (1)

  • Enable USB Debugging Mode and OEM Unlock on your mobile. To try to do this; attend settings >>> about >>> Tap on the “Build Number” 7-10 times consistently to enable “Developer Options,” then attend the “Developer Options” and enable USB Debugging Mode, OEM Unlock and Enable the ‘Advanced Reboot.’ There is no complicated process in Sony Xperia XZ2.
  • Download and Install the Sony PC Companion (Windows) or Sony PC Companion for (Mac)
  • Also, download the ADB drivers. Install it on your PC.
  • Download Magisk.Zip (Latest Version) and Copy it to Your mobile SD card or Pendrive OTG Cable.
  • Pie KernelCamera Fix (Both are Optional) Download and Copy it to Your mobile SD Card. This file helps you to take care of the Bootloader unlock and debug some Root issues in your device.
  • Download, extract, and save the TWRP get into your PC and your External mobile storage and rename it to recovery.img. You ought to keep the get into both locations. On the opposite hand, copy this file to the Mobile External SD Card.
  • twrp-xperia1-griffin-pie.zip
  • twrp-xz2compact-pie.zip
  • twrp-xz2premium-pie.zip
  • Based on your model number, Download, extract and save the VB meta Files in your PC and rename it to vbmeta.img.
  • vbmeta-xz2-pie.zip
  • vbmeta-xz2compact-pie.zip
  • vbmeta-xz2premium-pie.zip
  • Copy all the above files into the Fastboot folder.

Unlock the bootloader using ADB and Fastboot

Your mobile should be supported to urge the unlock code. Check this using the below step. If your mobile supported get the code and unlock using unlock stages.

  • Go to Sony Developers Official Page to check if your device model is accepted for this.
  • You should signup to a replacement Sony Xperia account or login with details to an existing account. Alternatively, you’ll use your Gmail account.
  • The device must be connected to the internet
  • Dual SIM Sony devices have two IMEI numbers. Use the IMEI 1 to induce the precise unlock code for your device


  • This action works for all Sony Android devices. However, you continue to should take a look at if your device model supports such action (unlocking the bootloader);
  • If your device is supported, then plow ahead with the steps below to unlock the boot loader.

Unlock Steps

  • Open your phone dialer and dial this code – *#*#7378423#*#*
  • Go to Service Info >>> configuration >>> rooting status >>> Check to work out if bootloader unlocking is allowed or not. If it’s allowed, then continue below.
  • Get the “download_inf.zip” file and paste it into the folder where you installed ADB and Fastboot.
  • Dial *#06# and replica down your Sony Mobile IMEI number.


  • Return to the Sony Official page, select your device model, and supply your Email Id.
  • Switch off your device. Then, enter into Fastboot mode. To try to do this; Press and hold down the amount Down button connect mobile to your PC using USB Cable.
  • Go to the ADB and Fastboot folder, Launch the fastboot on your computer. Open an electronic communication on your PC and sort below command.
  • fastboot devices
  • It should display the connected devices. If you didn’t get the device, restart the prompt and Disconnect and Connect your Sony Xperia XZ2. If you’re detected, type below command and Hit Enter.
  • fastboot oem unlock 0x<insert your unlock code>

Note: you have to replace the key with your own generated Key

  • Tap “Enter” and wait for some time
  • Your mobile bootloader is now unlocked, reboot the device. Move to flash TWRP steps.

Flash TWRP


  • Switch off your device. Then, enter into Fastboot mode. To try and do this; press and hold down the Volume Down button connect mobile to your PC using USB Cable.
  • Launch the fastboot on your computer. Open a prompt on your PC and kind below command.
  • fastboot devices
  • It should display the connected devices. If you didn’t get the device, restart the electronic communication and Disconnect and Connect your Sony Xperia XZ2. If your device detected type below commands one by one and Hit Enter.
  • fastboot –disable-verity –disable-verification flash vbmeta vbmeta.img
  • After the flash of the above file, type below command and hit Enter.


  • fastboot boot recovery.img
  • If you can’t reboot your mobile using the above command, Press Volume Down+ Power button to exit Fastboot mode. When the screen bangs, Immediately Press Volume Up + Power buttons besides into Recovery mode.
  • It will boot into the temporary TWRP. Don’t Boot into standard OS until we flash Magisk.

Install TWRP, Magisk, and Kernel in your Sony Xperia XZ2 using TWRP

  • In TWRP, Make a full Backup on External SD Card or Pendrive using OTG Cable.
  • After the method complete, Reboot to Bootloader using TWRP Option. Reboot->Reboot Bootloader.
  • Go to the TWRP menu. Select Advanced Menu->Install recovery ramdisk->recovery.img. This file is what we stored within the SD card before.
  • Return to Home of TWRP select Install.
  • Select Magisk.Zip.
  • Again Return to Home of TWRP select Install.
  • Select Kernel.Zip. The identical process goes for Camera Fix. Don’t use Add more Zips in TWRP. Install one by one.
  • After the Installation Reboot Your Mobile.
  • You can also install Magisk Manager in your Mobile Applications. Download Root Checker to check your mobile root status.

What More?

In my opinion, you don’t need rooting for your Sony Xperia XZ2. If you thought, you’ll Improve Performance By root;

With the Qualcomm Snapdragon 845 Octa-Core processor and 4/6 GB RAM, your device can perform well. If you don’t know the way much RAM you would like, you’ll never use this much RAM.

Don’t install any apps apart from trusted sites on rooted devices. Third-party site apps can contain some background codes.

So, Check twice before installing those apps. If you would like to return to stock firmware, flash Sony Xperia XZ2 Pie 9.0 firmware. During this process, If you face any problem, comment below.





Leave a Reply

Your email address will not be published. Required fields are marked *