Home > LG

How to Extract Boot.img from LG KDZ or DZ Firmware

In this guide, we will show you the steps to extract the boot.img file from LG’s KDZ or DZ firmware. When it comes to rooting an Android device, there are two different approaches that you could take.  The first one is a rather direct route that just involves flashing the Magisk ZIP (which is now a part of the Magisk App, version 22 onwards) via TWRP Recovery. However, there are still a lot of devices out there that don’t have a working custom recovery (neither official nor unofficial). As a result, those set of users can’t proceed with this method.

Well, even if there is a TWRP, some users prefer to maintain a safe distance due to the complexities involved in installing them. The A/B partition thing: the absence of recovery partition/ replaced by the boot and the data encryption issues are just some of the reasons for the same. As a result, they take an alternate “route to root” their devices. This involves getting hold of the stock boot.img file, patching it via Magisk, and then flashing it via Fastboot. While it is a little bit lengthier method, but at least does its job without any issue.

The only problem that some users have is extracting the boot.img from the stock firmware. This is because most OEMs don’t upload their firmware in ZIP or RAR. OnePlus takes the payload.bin approach, Oppo and Realme have it in the OZIP package and LG has it in KDZ or DZ (or TOT) format. Since there is no universal extraction tool, it leads to a little bit of confusion among the users. But it’s now time to put all these doubts to rest. In this guide, we will show you how to extract the boot.img file from LG’s KDZ or DZ firmware.

Extract Boot.img from LG KDZ or DZ Firmware: The Technicalities

extract boot.img lg kdz dz firmware

[You may skip this section if you’re in a hurry] Recently I covered an article on extracting KDZ, DZ, and TOT firmware. That process involved using the LG Extractor Tool. I loaded the KDZ firmware and upon extraction, it gave me the DZ firmware. Then I loaded this DZ firmware and extracted it again via that tool. This time I got some partition files in IMG format. But, there was something just not right with the extracted DZ file. This is because there were just a couple of partition files, all the major ones such as recovery, boot, and system were missing.

So I did some research and found out the issue was with the method LG Extractor Tool handling of the KDZ file- it wasn’t able to extract the KDZ file correctly, so the DZ file that it gave out was only half-baked. Therefore I decided to ditch this tool for the KDZ extraction and found out a Python script that does this job quite efficiently. So here we would use that Python command to extract the KDZ file, which will give us the DZ firmware. We would then use the LG Extraction Tool to extract this DZ file and get the boot.img file.

So can’t we have used Python to extract the DZ file as well? Truth be told, that script is made to work for the extraction of both the KDZ and DZ files. But there are some indentation issues with its DZ extraction file. So I had to only limit its usage for the extraction of KDZ and then shift over to the LG Extraction Tool for the DZ extraction. Phew! Anyways, let’s now keep these technicalities aside, and start off with the guide to extract the boot.img file from LG’s KDZ or DZ firmware. Follow along.

How to Extract Boot.img from LG KDZ or DZ Firmware

We will list out the entire instructions in separate sections for ease of understanding. Proceed ahead in the exact same sequence as mentioned below.

Download LG Stock firmware

To begin with, download the LG Firmware file for your device. Do keep in mind that you have to download the same firmware that is currently installed on your device. You may check the currently installed version from your device’s Settings > About Phone section.

As far as the site for downloading firmware is concerned, there’s no official one. However, just a Google search should list out a plethora of sites with your device’s firmware. Download it from your preferred source and then move over to the next step.

Download Python Extraction Script

We will be using Python to extract the KDZ firmware which shall give us the DZ firmware file. So download the KDZTools from GitHub.

download python lg kdz extract boot.img tool

But this tool wouldn’t work if you haven’t installed Python on your PC. So head over to the official site and download Python right away. Once downloaded, launch its setup file, tick-mark the Add Python to Path option and proceed with the onscreen instructions to install it.


Download LG Extractor Tool

Once we have got the DZ firmware via Python, we will use the LG Extractor Tool to extract this DZ file and get the stock boot.img file. So download the LG Extractor Tool [Credits: XDA Developer bullghost] and extract it to any convenient location on your PC.

Extract LG KDZ Firmware via Python

  1. To begin with, transfer the downloaded LG firmware file to the Steadfast kdz-tools folder.
  2. Furthermore, it is recommended to rename the firmware file to firmware.kdz to make it easy to type in the Command window.
    place lg kdz firmware in python extract stock boot.img
  3. Now head over to this folder’s address bar, type in CMD in the address bar, and hit Enter. This shall launch the Command Prompt window.
  4. Type in the below command in this window to extract the DZ file from KDZ:
    python unkdz.py -f firmware.kdz -x

    lg kdz extracted to dz python

  5. The extraction process will now begin. Once done, a new folder by the name kdzextracted will be created inside the kdztools-master directory and your extracted DZ file will be placed there.
    lg kdz extracted to dz files
  6. You will get PARAM, DZ, BIN, DLL, and DYLIB Files. As of now, let’s keep our focus on the extraction of the DZ file which shall give us your LG device’s stock boot.img file.

Extract LG DZ firmware via LG Extraction Tool

  1. Double click on the WindowsLGFirmwareExtracxt.exe file to launch the Tool.
  2. Now click on the Open button next to the DZ file.
  3. Navigate to the DZ file, select it and click OK.
    extract boot.img kdz firmware lg extraction tool
  4. It will bring up all the associated files present inside this DZ file.
  5. Select the boot.img (and any other file if you require) and click on the Extract DZ button.
  6. You will now get the boot.img file in the LG Firmware Extract Tool folder. It will be something like boot.img_numbers. Rename it to boot.img.
    extracted LG boot.img from dz via extraction tool
  7. That’s it. You may now refer to our guide to Patch Stock Boot Image via Magisk and Flash it using Fastboot.

So this was all from this guide on how to extract LG KDZ or DZ firmware and get the stock boot.img file. If you have any queries concerning the aforementioned steps, let us know in the comments. We will get back to you with a solution at the earliest.

  • same here

  • I try to extract boot.img but it leaves a 0KB file

    • I had the same problem and managed to figure it out.

      Instead of the LG Extraction Tool use the python tool to unpack the boot.img.

      The fork that is posted here gives errors when running
      ( File “undz.py”, line 173
      if cmd.batchMode:
      TabError: inconsistent use of tabs and spaces in indentation)

      So use the master-branch instead: https://github.com/steadfasterX/kdztools

      You need to install the zstandard library. (run “pip install zstandard”).

      Run the undz.py script with flag -l to find the correct chunk for the boot image. (“python undz.py -f V50040d_0_user-signed-ARB0_OPEN_KR_OP_1027.dz -l”)

      In my case it was 47 (“47/136 : boot.img_118538 (31095425 bytes)”

      Then extract it using flag -s (“python undz.py -f CV50040d_0_user-signed-ARB0_OPEN_KR_OP_1027.dz -s 47”).

    • I have the same problem.

  • Thank you. But, when I extract the DZ, my boot.img files keep ending up 0 bytes and Magisk won’t patch them…. I thought it was that “Ionic Zlib…” error, but you’re getting the same error in your screenshots…. Do you happen to know what the problem I’m having is and how I can get my LM-G900UM rooted?

  • Hi, i cannot extract Dz file before extracted Kdz, it leave one file 0KB

  • william bergen

    so,one problem im noticing w this whole extration thing is,ive been using the lg f.extractor to extr. the kdz,and then the kz,it does give the boot file evry time…if..it manages to actually extract the kz b4 the program all of a sudden closes,in which case,it doesnt…but lets say it does,my ?is about the a/b/ partition phones,yes it does give you 2 boot img,but does it matter,which boot img.gets flashed to which partition??there is say boot_img 04958,and then boot_img 03526..so is each one a/b specific or???

  • Aballamis

    Thank you for the detailed instructions. I was also interested in how to re-compile or archive the files back into a complete .kdz file to flash with LGup or LG Flash Tool. This would be extremely helpful for lower and mid-range LG phones that do not come with a fastboot mode but do have a download mode. If you have any information how to merge the magisk-patched boot image back into the .dz and then into .kdz, or to do it in 1 step if possible, any help would be greatly appreciated! Feel free to email me at my address listed.

    Thanks in advance!!!!

  • william vanbergen

    hello Sir&greetings from LasVegas…i was reading and learning on all your aricles.i am a prior microsoft employee,m.c.p.,m.c.e.,m.c.s.a.who went from flashing bios mains,to learning python and flashing phones..phwee!!!alot to learn there…you have been an inspiration to my career change and i believe a pillar in the cell phone industry,to you a HUGE show of appreciation and kudos to you ,thanks from all of us learning out here GREAT JOB…and now for the tricky part…lol..i was wondering..if you could maybe shift over and take a look at the LG k51..which is also the variant km500mm10r…as is my luck..i started way back w samsung.mastered them and moved on to lg,since i had the k51..and from what ive found out,threw var.devs on XDA who have worked on this phone…this might be one of if not the hardest phones out there to do…i was just thinking,from what ive learned working on this phone..that maybe you could do an article on this..?????i am way above my paygrade here..since now im extracting kdz via python,extracting dz’s..using diff.flash tools for media tek chips and working with the infamous wwr-mtk program..{excellent resource},and every know flash tool extractor and form of lg extension there is…my goal here sir becomes yours,to take this info,and have you maybe turn it into an article for people to learn…ive been learning about the lg procedures now for a month straight,crashcourse in lg…ive even gotten the chimera tool,just to name one..i would be happy to write a detailed ,correctly instructed procedure list or anything that you would like to start this off,maybe would cut down on your limited research time…if you would require anything id be more then happy to help…pay it forward,moving on…t.y.v.m.for your timne sincere….william vanbergen

  • and I was scared at first lol
    thanks for the good job!

  • i installed magisk in lg g7 with qfil but got red secure boot error i have backed up with qfil but with .bin instead of img extension help me p;z

  • thank you sir, helped me a lot!