In this article, how to root Android phones and tablets through the Magisk program is taught.
Rooting Android phones is one of the common ways to increase access to different parts of the device, which can lead to more advanced customization and more features. Stay with us in the next article to explain a comprehensive method for rooting Android mobiles and tablets.
What is the advantage of rooting the phone?
In short, we can say that rooting Android phones and tablets end up increasing the level of user access. Users can change or replace more settings and system applications with this level of access. It is also possible to run some special programs that require a high level of access. On the other hand, some other apps have features that cannot be used in normal mode and can only be accessed after rooting.
Note that rooting the phone may void the warranty. It is also possible that after rooting, the condition of the device will become unstable, and if this is not done correctly, there will be a possibility of permanent damage to the mobile phone or tablet.
What are the risks and disadvantages of rooting the phone?
Although rooting the phone gives the user complete control over the smartphone, to be honest, its benefits are much less than before. Because during these years, Google as an Android software developer; has expanded its set of facilities and features related to it. These features include many things that the user used to root the phone to access in the past.
Considering the changes made in these years, mobile rooting has risks and disadvantages that you should be aware of before making any decision. In this case, you can make the right choice.
- Since rooting all smartphones is against the manufacturer’s policy, rooting will automatically void your device’s original warranty.
- Rooting is a complicated process and if there is a mistake in any of the steps, your phone will be useless.
- Your device will never receive official Android updates.
- After rooting, Google’s security measures that protect your device from malware are no longer effective, leaving your device completely vulnerable.
How to root Android phones
Today, Magisk is the best solution for rooting Android phones and tablets. The mentioned tool allows changing the boot partition without manipulating the system partition; As a result, this method is also called the systemless method.
Before you can start working with Magisk, you must have access to a Windows or Mac OS computer with ADB and Fastboot. Also, the bootloader of the device you intend to root must be open. It is worth noting that opening the bootloader in the products of some brands such as Samsung will cause some restrictions in the future.
1. Identify the type of Boot Image
First, to download the Magisk program, you can refer to this GitHub repository to access the latest version. Because the APK file of this application has only been released outside of Google Play, to install it, you must enable the option to install from unknown sources (Unknown Sources) in the device settings. After installing the app, you will see a screen similar to the image below.
At this point, you should note down the values written in front of the terms “Ramdisk” and “A/B” along with “SAR“. Note that we will need these values in the next steps, so try to write them down somewhere or remember them well.
2. Find the Boot Image
To patch the “Boot Image” of your device, you must first extract it from the official firmware package specific to your mobile or tablet. If you are using custom ROMs like “LineageOS“, you can find the “Boot Image” inside the ZIP file used for flashing. At this stage, several scenarios are proposed, which are explained separately below.
2.1. If you have access to the flashable recovery ZIP file
If you are still using a device that uses the “A-only” partition structure, you can find the “boot.img” file inside the flashable recovery ZIP file. For this purpose, you only need to extract the zip file using a suitable tool (such as WinRAR or WinZip).
If your device uses the “A/B” partition structure, you can find the “boot.img” file and other related files inside another package named “payload.bin” (as shown in the image below). In this case, you must first extract the “payload.bin” file from the ZIP file using one of the extracting software. Then you can extract the “boot.img” file with the help of unofficial tools developed by the Android user community.
The “Payload Dumper Go” tool is one of the best options for extracting contents from inside “payload.bin” file. The said program can be downloaded through this GitHub repository. Also, the possibility of extracting only one file (such as boot.img) without the need to extract other files is considered inside the mentioned tool, which can greatly reduce the time required for this process. To do this, just follow the steps below:
- First, use the following command to get the “Partition Images” list inside the “payload.bin” file.
payload-dumper-go -l payload.bin
- Next, select the “Boot Image” file you want to extract with the help of the following command. This file is usually saved with the name “boot” and img format, but you don’t need to enter its format.
payload-dumper-go -p boot payload.bin
2.2 If you have access to the Fastboot flashable file
Some manufacturers of Android devices, such as Google and Xiaomi, publicly release the flashable “Fastboot” file of their products. If you can access such a file, you can easily extract the raw “boot.img” file from it.
2.3 If you want to root Samsung phone
Samsung Galaxy series devices do not use the common “Fastboot” interface. As a result, the “Image” files in them are compressed in a different way. For this purpose, you can follow the path mentioned below:
(First, you need to access the desired firmware for your device. You can do this using the “Samsung Firmware Downloader” tool, which is available via the GitHub repository link below.)
- To start, you must select your device and its region through the “Downloader” tab.
- Then click on the “Download” button in the upper left corner of the window to start the process of downloading the firmware.
- After the download is finished, you can open the downloaded file through the “Decrypter” tab.
- Unzip the unzipped file.
- Then find the file “AP_[device_model_sw_ver].tar.md5“. Inside the bracket, the device model is written along with its software version.
3. Patching the Boot Image file
After finding the “Boot Image” file according to the steps mentioned in the previous section, we need to patch it. To do this, several different scenarios are proposed, which are mentioned below independently. To continue, we will need the values we wrote down in step 1.
3.1 If the value of Ramdisk is equal to Yes
- Copy the “Boot Image” file to the internal memory of your mobile phone or tablet. Of course, you don’t need to copy it to the destination device and you can do the patching process with any Android device you have available; But you should note that the “Magisk” application is installed on the device.
- Enter the “Install” section inside the “Magisk” program.
- Choose the “Select and Patch a File” option.
- Then specify the address of the “Boot Image” file that you copied on your device and select it.
- Magisk will save the patched “Boot Image” file to the device’s internal storage at the address below.
- Using the following command in “ADB“, transfer the patched “Boot Image” file to the computer.
adb pull /sdcard/Download/magisk_patched_[random_strings].img
- Now flash the patched “Boot Image” file on your device. In most devices, you can flash the said file by rebooting and entering “Fastboot” mode with the following command.
fastboot flash boot /path/to/magisk_patched.img
- Finally, reboot the device again. Now you will have root access on your mobile or tablet.
Note that the “Boot Image” file can also be patched through custom recoveries such as “TWRP“; But this method is no longer recommended in modern devices. However, if you have an old device and want to continue with a custom recovery, you can root it from the following path.
- Download the “APK” file of the “Magisk” program. Then change the downloaded file format from “APK” to “ZIP“.
- Flash the ZIP file like any other regular ZIP file.
- Note that the “sepolicy.rule” file is probably stored in the “cache” partition and you should not delete it.
- Make sure the “Magisk” application is installed. If the program was not installed automatically, install it manually.
3.2 If the value of Ramdisk is equal to No
In this case, you should find the “recovery.img” file instead of the “boot.img” file; Because Magisk must be installed on the recovery partition. As a result, every time you need root access, you must reboot the device in recovery mode. For this purpose, follow the path below.
- Copy the “recovery.img” file to the device you want to root or any other Android device that has the Magisk app.
- Enter the “Install” section inside the Magisk app and then select the “Select and Patch a File” option. Go to the path where the recovery file is saved and select it.
- The Magisk application will save the patched file in the following path on the internal memory of the device.
adb pull /sdcard/Download/magisk_patched_[random_strings].img
- Flash the patched “Recovery Image” file on your device. In most devices, you can flash the file by rebooting and entering “Fastboot” mode using the following command.
fastboot flash recovery /path/to/magisk_patched.img
- Finally, reboot the device again.
Now three different situations may occur, each of which is listed below.
- If the usage is turned on normally and the Magisk app is not installed; There will be no root access.
- Hold down the recovery combination key. After the screen changes, release the keys, the system will now boot with the Magisk app and you will have root access.
- Hold down the recovery combination key. After changing the keyboard, continue to hold the volume up; Now you will access the main recovery mode of the device.
3.3 If you intend to root the Samsung phone
In step “2.3” we saw that when rooting Samsung phones we will need an “AP tar” file instead of “boot.img” file. After finding the desired file through the firmware package of your device, continue the following steps.
- Copy the “AP tar” file to the target Android device.
- Enter the “Install” section inside the “Magisk” program.
- If your device does not have a “Boot Ramdisk“, make sure the “Recovery Mode” option is ticked.
- In the “Method” section, select “Select and Patch a File“. Then go to the path to save the “AP tar” file and select it.
- The “Magisk” program will patch the entire firmware file and save it on the internal memory of the device in the following path.
- Copy the patched “Tar” file to your computer using the following command in “ADB“. Note that do not use the “MTP” interface for copying, as it will damage large files.
adb pull /sdcard/Download/magisk_patched_[random_strings].tar
- Reboot the device to download mode. Now open the “Odin” program on your computer and then flash the patched “Tar” file as “AP” along with “BL“, “CP“, and “CSC” of the original firmware. Note that do not select the “HOME_CSC” option.
- After completing the flashing process through Odin, the device should reboot automatically. If you see a message about restoring factory settings, confirm it.
- If the target device does not have Boot Ramdisk, reboot into recovery to activate the Magisk app.
- Install the latest version of Magisk and run it. Inside it, a message about installing more items will be displayed. Confirm it and wait for the device to reboot automatically.
- Finally, reboot the device again. Now you can enjoy root access on your tablet or phone.
4. root verification
The last step when rooting the phone is to confirm that the process is done correctly. For this, enter the Magisk application. The current version numbers should now be displayed next to the “Installed” value. If you can see such figures, it means that the rooting process of the phone has been done correctly.
How to detect a rooted phone
But how to distinguish a rooted Android phone from other phones? There are three ways to detect a rooted phone:
- through phone settings
- Visit the official website of the brand
- Using external software such as Root Check 184.108.40.206
Checking the phone’s root status through the phone’s settings menu
The easiest way to check the root status of the device is to refer to the mobile settings menu section. Of course, these steps may not be exactly the same in all Android phones, but it is still possible to view the status through the Settings section in all Android phones.
- First, go to “Settings“.
- After entering the settings page, touch “About Phone“.
- This will redirect you to a new page. Tap on the “Status Information” option.
- Check the “Phone Status” option on this page.
- If the word “Official” is written in this section, it means that your phone is not rooted.
Frequently asked questions about rooting the phone
- Does rooting the phone damage the device?
If you do the rooting steps according to your device correctly and use the correct files, it will not be harmed; Otherwise, there will be a possibility of a permanent problem for the phone or tablet.
- Is there any universal app to root the device?
In the past, programs like Kingroot provided the possibility of rooting by pressing a key, but in recent versions of Android, it is not possible to use them.
- What is the best program for rooting Android phones?
Currently, the Magisk application is considered the best option for rooting Android devices, which can be used on most phones and tablets.
- What are the advantages of rooting Android phones and tablets?
Rooted devices give users access to more settings and customization beyond normal. Also, some specific apps will only be usable on rooted devices.
In this article, we talked about “How to root Android phones” and we are waiting for your experiences to use these methods. Please share your thoughts with us.