In this guide, we will show you the steps to root your LG device via Magisk and the stock boot.img file extracted from the KDZ/DZ Firmware. When it comes to the custom development scene, LG isn’t usually the first name that might pop up in your mind. With that said, it still has its presence felt up to an extent. The only prerequisite is that you need to have the bootloader unlocked. Once that is done, you could easily flash custom ROMs or a custom recovery like TWRP.
Along the same lines, you could also gain administrative privileges by rooting your device via Magisk App (beginning with v22, Magisk ZIP and APK are combined under one roof, known as Magisk App). This would then allow you to flash Magisk Modules, Xposed Framework, Substratum Themes, among others. Talking about, rooting, you could do so via two different methods. The first one is by simply flashing the Magisk ZIP via TWRP. However, this recovery isn’t yet available for all devices. Hence, users then opt for the second method which involves the stock boot.img file.
Keeping our focus on the LG device, you will have to extract the stock boot.img file from the KDZ or DZ firmware. Then we will patch it boot.img via Magisk and flash it via Fastboot Commands. While the patching could also be carried out via QFIL Tool but that would require a firehose file and hence calls for a lot of effort. So let’s stick with the conventional and the easier method. Keeping that in mind, here are the detailed instructions to root your LG device via Magisk and boot.img file from KDZ/DZ Firmware.
How Root any LG Device using Magisk and Boot.img from KDZ or DZ Firmware
The below instructions are listed under separate sections for ease of understanding. Make sure to follow in the exact same sequence as mentioned below. Droidwin and its members wouldn’t be held responsible in case of a thermonuclear war, your alarm doesn’t wake you up, or if anything happens to your device and data by performing the below steps.
STEP 1: Install ADB Fastboot
First and foremost, you will have to install the Android SDK Platform Tools on your PC. This is the official ADB and Fastboot binary provided by Google and is the only recommended one. So download it and then extract it to any convenient location on your PC. Doing so will give you the platform-tools folder, which will be used throughout this guide.
STEP 2: Enable USB Debugging and OEM Unlocking
To begin with, you will have to enable USB Debugging and OEM Unlocking on your device. The former will make your device recognizable by the PC in ADB mode. This will then allow you to boot your device to Fastboot Mode.
On the other hand, OEM Unlocking is required to carry out the bootloader unlocking process. So head over to Settings > About Phone > Tap on Build Number 7 times > Go back to Settings > System > Advanced > Developer Options > Enable USB Debugging and OEM Unlocking.
STEP 3: Unlock LG Bootloader
To root your LG device via Magisk and stock boot.img from KDZ/DZ Firmware, you will also have to unlock the device bootloader as well. Do keep in mind that doing so will wipe off all the data and could make the device’s warranty null and void. So take a backup beforehand and then only refer to our guide to
STEP 4: Download LG Firmware
Next up, download the LG firmware for your device. Make sure to download the same firmware that is currently installed onto your device. You may check the same via Settings > About Phone. As far as downloading the firmware is concerned, there is no official source as such. But a Google search shall bring up the desired result. Once downloaded, let’s proceed to the next step to root your LG device via Magisk and boot.img file from KDZ/DZ Firmware.
STEP 5: Extract Stock Boot.img File
Now that you have downloaded the firmware, it’s time to extract it and get the stock boot.img file. In this regard, you will have to make use of the LG Firmware Extractor Tool and a Python script. Only using the Extractor Tool didn’t give out all the partition files, hence I had to use a script file as well. All this has been explained in-depth in this guide, please refer to it: How to Extract Boot.img from LG KDZ or DZ Firmware.
STEP 6: Patch Stock Boot.img via Magisk
Now that you have extracted the stock boot.img file from KDZ/DZ Firmware, it’s time to patch it via Magisk and root your LG device. Follow along:
- To begin with, transfer the extracted stock boot.img file to your device
- Then install the Magisk app onto your device.
- Launch it and tap on Install next to Magisk.
- Choose Select and Patch a file option,
- Navigate to the extracted boot.img file and select it.
- Magisk will now begin patching this file.
- Once done, you shall get the magisk_patched.img file under the Downloads folder of your device
STEP 7: Boot Device to Fastboot Mode
The next step in this guide to root your LG device via Magisk and boot.img file from KDZ/DZ Firmware requires you to boot your device to Fastboot Mode. Here’s how it could be done:
- Connect your device to the PC via USB cable. Make sure USB Debugging is enabled.
- Then head over to the platform-tools folder, type in CMD in the address bar, and hit Enter. This will launch the Command Prompt.
- Type in the following command in the CMD window to boot your device to Fastboot Mode
adb reboot bootloader
STEP 8: Flash Magisk Patched Boot.img and Root LG
- To begin with, transfer the magisk_patched.img file to the platform-tools folder on your PC.
- Inside that folder, type in CMD in the address bar and hit Enter. This will open the Command Prompt window:
- Now type in the below command to flash this patched boot.img file
fastboot flash boot magisk_patched.img
- If you have a Dual A/B Partition device, then you will have to flash it to both slots, as follows:
fastboot flash boot_a magisk_patched.img fastboot flash boot_b magisk_patched.img
- Once the flashing is complete, you may now reboot the device to the OS using the below command:
- fastboot reboot
That’s it. These were the steps to root your LG device via Magisk and stock boot.img file extracted from KDZ/DZ Firmware. If you have any queries concerning the aforementioned steps, do let us know in the comments section. We will get back to you with a solution at the earliest.