Rooting Help for a Complete Beginner

orapyt

Member
Jul 13, 2019
34
14
8
PLEASE DO NOT FOLLOW MY INSTRUCTIONS. I DO NOT KNOW WHAT I AM DOING.

Basically, I am a complete noob wanting to root my device - using Sony Xperia XZ2 Compact Dual (H8324, build 52.0.A.8.107, so that's Android 9)[1]. I'm hoping someone can check if what I'm doing is correct and answer a few questions, as I am much confused. I appreciate your help. Hopefully, this can help other people like me who want to get into rooting.

I've been reading a lot on this website and other websites, and I think I have a basic idea of what I am supposed to do, but I've been reading some info and I do not know what is outdated and am being overwhelmed.

Before all else, I should have adb and fastboot from the 'android-tools' package (installed from pamac-manager on Linux, but there are other ways to get it for other OS's)[2]. Also, connect device to PC.

First, I need to unlock the bootloader, which can be done using two methods[3]:
1. Using adb/fastboot by running these commands:
Code:
adb reboot bootloader
fastboot oem unlock-go
OR
2. Following Sony's guide on https://developer.sony.com/develop/open-devices/get-started/unlock-bootloader/

Then, I need TWRP, which, officially, does not support the XZ2C, so I need a custom one, like MartinX3's (https://forum.xda-developers.com/xp...recovery-twrp-3-2-2-0-touch-recovery-t3821597)[4], for example:
  • Download 'Sony Xperia XZ2 Compact/android_9/twrp/custom_rom/2019-07-12_12-15-30_twrp_sodp_xz2c.tar.gz'[4] (which is the latest version as of me writing this).
  • Extract the archive
  • Open a terminal in the same directory[5]:
    Code:
    fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img
    fastboot boot twrp.img
  • In TWRP menu on the device, open Advanced Menu, "Install recovery ramdisk" using twrp.img

Finally, I need to install a root manager, Magisk, for example (https://forum.xda-developers.com/apps/magisk/official-magisk-v7-universal-systemless-t3473445).
  • Download 'Latest Stable' (*.zip)
  • Download MagistManager from the GitHub link (*.apk)
  • Place the files somewhere on the device through the PC (Downloads folder, for example)
  • Boot into recovery (which will open TWRP(?))
  • Install the *.zip
  • Boot normally and install the *.apk

At this point, I should have a rooted Sony Xperia XZ2 Compact Dual?

Process related questions:
[1] Does build number matter when rooting? Or is it just the Android version?
[2] Are there any specific Sony drivers I need to install on my Linux PC, or is 'android-tools' enough?
[3] Does the method of unlocking the bootloader matter? Which is best for a beginner? Also, when doing the adb/fastboot method, should the device be connected in recovery mode before-hand?
[4] So, over here I am downloading the TWRP for the normal Sony Xperia XZ2 Compact, not the Dual SIM one. Does that matter? I do use the two SIM slots.
[5] Again, when doing these commands, should I be in recovery mode before-hand?

Other questions:
  1. I've been reading a lot about the DRM thing and breaking some functionality, including the camera. Is that still a problem on Android 9? I heard it's mostly not. What am I loosing from unlocking the bootloader on Android 9?
  2. I like to keep my device updated for the security patches. I read that I cannot do that through the device with root, but I have to flash it from my PC each time. Does anyone have a guide for Linux users? Do I loose root? Where do I even download the updates from?
  3. Also, should I keep TWRP and Magisk updated for security and stability? How do I do that?

Thank you for reading this relatively long post, and I appreciate your help. :)
 
Last edited:

MartinX3

Recognized Contributor
Sep 14, 2014
5,584
2,787
253
Mars
martinx3.github.io
About the rooting, follow my twrp thread after unlocking in the newest PIE firmware.

With PIE you loose sony backup&restore, OTA, maybe Bluetooth ps4 controller, the login into the Sony club (I think) and maybe low light night antinoise algorithms (I think).

You can also switch to one of the custom ROMs. Existenze is stock and gives you at least an OTA notification.

Or omnirom and sonyaosp, based on SODP, a rewrite of the hardware drivers in an aosp compatible way. (Camera is work in progress).

For stock upgrades you need xperifirm, newflasher and removing the userdata.sin (if you don't want a full wipe)
 
  • Like
Reactions: orapyt

orapyt

Member
Jul 13, 2019
34
14
8
About the rooting, follow my twrp thread after unlocking in the newest PIE firmware.

With PIE you loose sony backup&restore, OTA, maybe Bluetooth ps4 controller, the login into the Sony club (I think) and maybe low light night antinoise algorithms (I think).

You can also switch to one of the custom ROMs. Existenze is stock and gives you at least an OTA notification.

Or omnirom and sonyaosp, based on SODP, a rewrite of the hardware drivers in an aosp compatible way. (Camera is work in progress).

For stock upgrades you need xperifirm, newflasher and removing the userdata.sin (if you don't want a full wipe)
Ok. I think I get.
First I unlock bootloader.
Flash latest stock firmware (which I can download from XperiFirm).
Flash TWRP and Magsik.
Finally, use the eXistenZ Pie patch.
Thank you very much. :)

But before I go ahead and follow through, I have a few more questions:
Does re-flashing the latest stock firmware mean I will lose personal data stored on the device (like call/chat history for example)?
Also, in the eXistenZ Pie patch, it says it is based on 52.0.A.8.83, but latest firmware is 52.0.A.8.107. Does that matter?
Finally, I will only get the OTA notification, but I will need to follow the process again to update (flash latest firmware from XperiFirm, --> flash TWRP and Magisk, --> eXistenZ patch)?

Again, thank you.

Edit: I almost forgot. Installing TWRP for H8314 on H8324 (Dual SIM) is ok, right? I won't lose that functionality?
 
Last edited:

MartinX3

Recognized Contributor
Sep 14, 2014
5,584
2,787
253
Mars
martinx3.github.io
Ok. I think I get.
First I unlock bootloader.
Flash latest stock firmware (which I can download from XperiFirm).
Flash TWRP and Magsik.
Finally, use the eXistenZ Pie patch.
Thank you very much. :)

But before I go ahead and follow through, I have a few more questions:
Does re-flashing the latest stock firmware mean I will lose personal data stored on the device (like call/chat history for example)?
Also, in the eXistenZ Pie patch, it says it is based on 52.0.A.8.83, but latest firmware is 52.0.A.8.107. Does that matter?
Finally, I will only get the OTA notification, but I will need to follow the process again to update (flash latest firmware from XperiFirm, --> flash TWRP and Magisk, --> eXistenZ patch)?

Again, thank you.

Edit: I almost forgot. Installing TWRP for H8314 on H8324 (Dual SIM) is ok, right? I won't lose that functionality?
First flash newest firmware and boot it once, then unlock please :)

And yes, dual/single is the same twrp.
Existence V9 for 107 comes soon. Yes, sou should wait :)
 
  • Like
Reactions: orapyt

orapyt

Member
Jul 13, 2019
34
14
8
First flash newest firmware and boot it once, then unlock please :)

And yes, dual/single is the same twrp.
Existence V9 for 107 comes soon. Yes, sou should wait :)
I think I understand the process completely now. Thank you for your help.
About the OTA notification: I will get the notification for update from Sony but I will have to wait for the eXistenZ Pie patch to update first, right?
 

orapyt

Member
Jul 13, 2019
34
14
8
Yes. Just update to 107, wait for v9 and with existence you'll get the august notification :D
Oh, sorry. My question was not clear enough. I feel bad for wasting your time. :(

I mean like each time I update I have to re-flash latest stock firmware and start from beginning, losing all data? I cannot update from the UI in the device?

Also, while I wait for v9 (I am on 52.0.A.8.107), can I unlock bootloader now, flash TWRP and Magisk in order to make a backup using Titanium Backup?
 

MartinX3

Recognized Contributor
Sep 14, 2014
5,584
2,787
253
Mars
martinx3.github.io
Oh, sorry. My question was not clear enough. I feel bad for wasting your time. :(



I mean like each time I update I have to re-flash latest stock firmware and start from beginning, losing all data? I cannot update from the UI in the device?



Also, while I wait for v9 (I am on 52.0.A.8.107), can I unlock bootloader now, flash TWRP and Magisk in order to make a backup using Titanium Backup?
No problemo, I'm a recognized XDA slave hihi

Oh, just remove userdata.sin all the time before using newflasher and no userdata will be lost

As backup tool I can recommend migrate and titanium backup

Titanium backup makes a backup of each app and can restore it

Migrate makes a big flashable twrp zip.

(Make sure removing the app cache to reduce the backups size)
 
  • Like
Reactions: devMel and orapyt

orapyt

Member
Jul 13, 2019
34
14
8
No problemo, I'm a recognized XDA slave hihi

Oh, just remove userdata.sin all the time before using newflasher and no userdata will be lost

As backup tool I can recommend migrate and titanium backup

Titanium backup makes a backup of each app and can restore it

Migrate makes a big flashable twrp zip.

(Make sure removing the app cache to reduce the backups size)
lol

'userdata_X-FLASH-CUST-B6B5.sin' from the firmware folder?
 

orapyt

Member
Jul 13, 2019
34
14
8
Just to give closure to this: I did get eXistenZ on my Sony XZ2C Dual on build 52.0.A.8.107, and here is what I did exactly (could act as a guide, but please read completely before doing anything and I'm not responsible for any losses before, during, or after the process).

Prerequisites:
  • adb/fastboot (through package manager for Linux ('android-tools') or here for Windows)
  • mono (required only for Linux, through package manager)
  • Drivers (only required for Windows--install them from device manager when you have device turned on normally, and then again after you reboot into bootloader, as Windows detects it as a different device)
  • XperiaFirm
  • Newflasher

Steps:
I. Flashing the latest firmware:
  1. Use XperiaFirm to get latest stock firmware with your customization (run with mono on Linux)
  2. Delete userdata{somethingsomething}.sin from the firmware folder created by XperiaFirm
  3. Place Newflasher into the folder
  4. Shut-off phone
  5. Hold volume-down button and plug in phone to computer to enter recovery mode
  6. Run Newflasher and enter 'n' when prompted
  7. Just wait until everything finishes (no data should be deleted).

II. Unlocking the bootloader:
Before you do, understand that you are voiding your warranty. Also it has some side-effects:
With PIE you loose sony backup&restore, OTA, maybe Bluetooth ps4 controller, the login into the Sony club (I think) and maybe low light night antinoise algorithms (I think).
  1. Get the unlock code for your device here.
  2. Enable USB debugging from developer menu
  3. Plug in phone to computer
  4. Connect to fastboot:
    Code:
    adb reboot bootloader
  5. Enter unlock code:
    Code:
    fastboot oem unlock 0x<insert your unlock code>
  6. Wait for device to boot again (For me data was deleted. Also, don't mind the "can't check for corruption"; it's a side-effect of unlocking the bootloader)

III. Installing TWRP:
  1. Get TWRP for XZ2
  2. From the "Download," navigate to "Xperia XZ2 Compact/android_9/twrp/stock/" and download latest one
  3. Extract, and open terminal in the extracted folder as a working directory
  4. Plug in phone
  5. Copy twrp{sometingsomething}.img to phone somewhere
  6. Boot into TWRP:
    Code:
    adb reboot bootloader
    fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img
    fastboot boot twrp{somethingsomething}.img
  7. Enter pin if prompted
  8. Go to Advanced, Install recovery ramdisk, and pick the copied twrp image (this will install twrp to recovery mode, so you just shutdown phone, hold volume-down button and power, wait for vibration, and let go to enter TWRP)

IV. Flashing other stuff (Magisk, permissive):
  1. Copy Magisk .apk and .zip, and permissive .zip from the twrp .tar.gz downloaded above to your phone somewhere
  2. Enter installed TWRP by going into recovery mode (shutdown phone, hold volume-down button and power, wait for vibration, and let go)
  3. Go to install, pick the Magisk .zip, and slide to install
  4. Reboot into system and install the Magisk .apk to make sure it's working (do not update Magisk as it may be unsupported; only use the version provided in the twrp .tar.gz)
  5. Boot back into TWRP and install permissive the same way Magisk .zip was installed
  6. Reboot into system and launch Magisk manager, go to modules to check if permissive is working

V. Installing eXistenZ:
  1. Download the version for your firmware version
  2. Place the .zip somewhere on your phone
  3. Boot into TWRP (shutdown phone, hold volume-down button and power, wait for vibration, and let go)
  4. Got to wipe, advanced, and selected only Data and Dalvik/ART Cache
  5. Now install eXistenZ .zip like installing the Magisk .zip
  6. Reboot into system
  7. ??? (takes a long time)
  8. Profit!! (for me data was deleted, so I had to reinstall Magisk and permissive)

Notes:
  • You probably want to backup your data.
  • Personally, I used UK customization firmware because that is what my phone shipped with.
  • Some guides say remove the *.ta files from the firmware folder, but I did not and it worked fine??
  • For some reason, all fastboot commands return "FAILED (command write failed (Success))" on Linux (fastboot version 9.0.0_r41) for me, but worked on Windows??
  • If you get 'error getting bootctrl module,' in TWRP you might need to mount something... forgot what exactly (might be OEM)??

Edit 1: Added drivers for Windows
 
Last edited:
  • Like
Reactions: devMel and MartinX3
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone