Skip to content

Instantly share code, notes, and snippets.

@gitclone-url
Last active April 22, 2025 09:25
Show Gist options
  • Save gitclone-url/a1f693b64d8f8701ec24477a2ccaab87 to your computer and use it in GitHub Desktop.
Save gitclone-url/a1f693b64d8f8701ec24477a2ccaab87 to your computer and use it in GitHub Desktop.
Guide on how to extract boot image from any android phone without needing to root using magisk and without custom recovery.

Boot Image Extraction Guide

Guide on how to extract a boot image from any Android phone without needing to root using Magisk and without a custom recovery.

Most Android users face hurdles when attempting to root their phones because they require a boot image for patching, and custom recoveries specifically designed for their devices are often unavailable. Additionally, finding the phone firmware online can be challenging. As a result, rooting such phones becomes a daunting task. In this guide, I'll provide a comprehensive solution for users who want to extract the boot image from their phone without the need to root it first, download firmware from the internet, or rely on custom recoveries.

Getting started!

Before diving into the guide, please thoroughly review the Frequently Asked Questions (FAQ) to understand the basics of GSI and the various naming conventions used by GSI builders and maintainers.

Accessing and modifying system files on your device typically requires superuser permissions. To extract the boot image, we'll need a root environment. We'll achieve this by using a GSI that includes the "su" binary or has superuser capabilities built-in.

You can use this Lineage OS GSI as an example. You'll need to flash it onto your phone.

If you're unfamiliar with flashing a GSI or unsure how to proceed, watch this YouTube video or search online for additional guides. You can also join the PHH GSI support group on Telegram for assistance.

Alternatively, the DSU sideloader can be used to install GSIs via Android's DSU feature with ease. For a detailed explanation, watch this YouTube video.

Steps to Follow After Flashing/Installing a GSI

Manual Process

  1. Download the Termux app from here.
  2. If not pre-installed, download the PHH Superuser app from here.
  3. Open Termux, grant storage permission, type su, and approve the superuser request from the PHH app to gain root access.
  4. With superuser permission, you can access any system file. Copy and enter the following command in termux:
for PARTITION in "boot" "boot_a" "boot_b"; do
  BLOCK=$(find /dev/block \( -type b -o -type c -o -type l \) -iname "$PARTITION" -print -quit 2>/dev/null)
  if [ -n "$BLOCK" ]; then
    echo "$PARTITION" = $(readlink -f "$BLOCK")
  fi
done

This command will display the boot partition paths for both A/B and A-only devices.

Note!

On A/B devices, the loop command will display the boot partition paths for both slots, something like this!

boot_a = /dev/block/sda40
boot_b = /dev/block/sda41

In this case, you can extract the image corresponding to your currently active slot.To determine the active slot, enter the command getprop ro.boot.slot_suffix. If the output is _a, use the path for boot_a; otherwise, use the path for boot_b.

  1. Finally, use the following command to extract the image from the specified boot path:
dd if=<boot_partition_path> of=<output_path>

For example:

dd if=/dev/block/mmcblk0p42 of=/sdcard/boot_a.img

Automated Extraction

If you find the manual process too complicated, you can use my Boot-image-Extractor script. This script automates the task, making the extraction process simpler and more efficient. You can find detailed instructions and usage guidelines within the repository.

Disclaimer!

The guide and script provided are for informational purposes only. The author does not take responsibility for any damage or loss caused by using or misusing the guide or script. By using the guide or script, you acknowledge that you are solely responsible for any outcomes, including but not limited to device damage, data loss, or voided warranty. Please note that modifying system files, including extracting the boot image, can have serious consequences if not done correctly. It is recommended to seek additional resources, such as official documentation or dedicated forums, for your specific device and firmware version.

@gitclone-url
Copy link
Author

@Zxxcxwww Yeah it's possible, if your device has recovery partition then you can pull the image.
Just replace

for PARTITION in "boot" "boot_a" "boot_b"; do

with your desired partition name that you wanna find.
After locating you can pull the img with dd command 😉

@NeverSm1le
Copy link

Hello, I have a question. My device has a 64bit SoC yet the manufacturer decided to use 32bit Android on it, what GSI version should I use, arm or arm64?

@gitclone-url
Copy link
Author

@NeverSm1le To Know which GSI image is right for your device, Download Treble Info app and check the "Required Image" section. ✨

@NeverSm1le
Copy link

Thank you @gitclone-url, I tried but sadly my device is not unlocked, thankfully it just reboot into recovery and reboot normally after that.

@gitclone-url
Copy link
Author

gitclone-url commented Oct 26, 2024

Yeah bootloader needs to be unlocked, else can't flash/install GSI image.

@JakkarinX
Copy link

<script src="https://gist.github.com/gitclone-url/a1f693b64d8f8701ec24477a2ccaab87.js"></script>

@dipeshjatt2
Copy link

dipeshjatt2 commented Mar 26, 2025

@Hot12345

Thanks for help but I can't find arm64 ab gsi with su in link you provided of Lineageos, my device has ab(android 14)partition, please bro can you find it for me please 🥺

@gitclone-url
Copy link
Author

gitclone-url commented Mar 26, 2025

@dipeshjatt2

You can find all the GSI image link in here : https://github.com/phhusson/treble_experimentations/wiki/Generic-System-Image-%28GSI%29-list

Just choose any particular ROM then check if there is a su varient is available or not.

You can also try this build for your device : link

@wbeimar543
Copy link

Her

no

Hermano hago todo bien pero nose como hacerle root ala rom de linage podrías ayudarme porfavor.

@gitclone-url
Copy link
Author

@wbeimar543 Please use English, and contact me on Telegram for further assistance: @Abhijeet ✨ Sorry for the delayed response, I've been quite busy lately and just saw your message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment