Unlock and root Android with Magisk
In order to get full control on your Android, you have to get the root access (superuser power). To do so, the /system directory should be made writable. But obviously it is read-only by default. So you are reading this blog. Android comes with unlocked bootloader, so you cannot flash any modified images (kernel, recovery, system, etc), and hence you cannot make /system writable easily. For manufacturers such as our great Google, or Sony, they permit their user to officially unlock the phone bootloader. In this article, only these phones will be benefited. For other phones without official unlock, you must wait for the "jailbreak", to break through the security system and make /system writable.
The steps below are based on Android Oreo and Ubuntu 16.04 / 18.04.
Install adb and fastboot
The links below should link to the latest file package.
Windows:
https://dl.google.com/android/repository/platform-tools-latest-windows.zip
Mac:
https://dl.google.com/android/repository/platform-tools-latest-darwin.zip
Linux:
https://dl.google.com/android/repository/platform-tools-latest-linux.zip
Source:
https://developer.android.com/studio/releases/platform-tools.html
After download, unzip it, and place the file on an easily accessible place.
e.g. /usr/bin/
(Sorry Windows user)
Enable development mode
- Go to "Settings" > "System" > "About phone"
- Click "Build number" for 7 times. Type in the passcode if needed
- You will see the "You are now a developer!" toast
- Go back to "System", and choose "Developer options"
- Turn on "OEM unlocking". Type in the passcode if needed
- Choose "Enable" if warned
Reboot to bootloader
Connect your phone to your computer. Run adb commands on the terminal.
sudo adb reboot bootloader
Your phone will reboot into the bootloader mode.
Bootloader unlock
ALL DATA WILL BE WIPED AFTER BOOTLOADER UNLOCK
Some devices allow you to unlock the bootloader directly (e.g. Google Pixel), while some require you to input a passcode obtained from the manufacturer website (e.g. Sony).
For Sony phones, IMEI is required to exchange for a passcode:
https://developer.sony.com/develop/open-devices/get-started/unlock-bootloader/
I cannot list out all manufacturer. Google it.
And for those phone requires a passcode, please refer to instructions given by the manufacturer. After unlock, please proceed to next part.
For latest Android, run this on the terminal:
fastboot flashing unlock_critical
For older Android, or the above command fails, run this:
sudo fastboot oem unlock
Follow the instruction on the phone. Your phone should reboot after unlock.
Install custom recovery
Download TWRP for your phone:
https://dl.twrp.me
You may see both .img and .zip files. Download the latest version of both of them.
Reboot to bootloader again. In the future, you can flash all kinds of image here.
sudo adb reboot bootloader
If there is only one .img file, run this and go to the next part.
sudo fastboot flash recovery twrp.img
If there are .img and .zip file, run this to install the temporary TWRP:
sudo fastboot boot twrp.img
Your phone will reboot to TWRP.
Enter passcode if needed.
If correct passcode is entered and it fails to decrypt, reboot, remove any screen lock, and try this step again.
Place the TWRP zip file on your phone by
sudo adb push twrp.zip /sdcard/Download/
On TWRP, click "Install", navigate to /sdcard/Download/, choose the zip file, and "Swipe to flash". Please notice if there is any error.
If you don't want to push the file, you can click "Sideload" on TWRP, and run
sudo adb sideload twrp.zip
After flashing, reboot to "System" WITHOUT installing TWRP app.
It is important not to install the app. Since it will modify the /system partition, and make you fail on SafetyNet check.
If you see any problem (should be a bootloop), you may leave a comment or Google for solution.
Root with Magisk
Magisk is the latest root solution. It allows your phone passing SafetyNet check so most of the troblesome apps (banking, games, etc) won't strike. It supports numerous of modules to modify and enhance your phone.
Download the stable version
https://forum.xda-developers.com/apps/magisk/official-magisk-v7-universal-systemless-t3473445
Download the latest beta version
https://forum.xda-developers.com/apps/magisk/beta-magisk-v13-0-0980cb6-t3618589
Only the Magisk zip is needed. No need to download MagiskManager, since it is already included and will be installed automatically after flash.
Reboot to recovery
sudo adb reboot recovery
In the future, you can flash / install any .img or .zip file in recovery / TWRP.
Click install, locate the Magisk.zip, "Swipe to install", reboot WITHOUT installing TWRP app.
After reboot, you will see MagiskManager. Click it.
If everything go well, you should see two beautiful green check marks!
YOUR PHONE IS NOW ROOTED!
You can check the SafetyNet status. You should see two green check marks as well.
Greater power comes with greater responsibility.
Please be careful when installing, approving or running anything on your phone.
I am NOT responsible for any loss.