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.
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.
- Download the Termux app from here.
- If not pre-installed, download the PHH Superuser app from here.
- Open Termux, grant storage permission, type
su
, and approve the superuser request from the PHH app to gain root access. - 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.
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.
- 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
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.
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.
First of all many thanks for @gitclone-url ❤️❤️❤️,
All the credits goes to him! By his help I make a small guide for myself!
I managed to extract the init_boot_a and _b.img file of my phone for root access::
Extracted the init_boot_image for acces to root::
Normal phone other then Xiaomi is it boot.img instead of init_boot_a/b.img::
Apps you need:
https://f-droid.org/packages/vegabobo.dsusideloader/
https://github.com/RikkaApps/Shizuku
Site: https://github.com/phhusson/treble_experimentations/wiki/Generic-System-Image-%28GSI%29-list
a required info is:
Working image: Unofficial Android 14 - LineageOS "Light" - Download
https://sourceforge.net/projects/andyyan-gsi/files/lineage-21-light/
BIG S in the file name for Superuser root acces.
lineage-21.0-20240824-UNOFFICIAL-gsi_arm64_vS.img
Download Shizuku and setup this.
Pair with wireless debugging in devp mode.
3.Enable USB debugging and USB debugging security Settings
Disable Batteryoptimize - Settings - Apps - Shizuku - disable pauze app activity unused- Batterysaver - No restrication
Pair with Wireless debugging in devp mode
Press on Start in Shizuku, when its done Shizuke is running.
Authorized 0 applications, add DSU Sideloader
Close all and start it again Shizuku , you see 1 authorized applications
Go in DSU Sideloader -> Setting -> Operation Mode should Shizuku.
Select the Lineage image S.build from above and select it. It should extract the image. give it time. Not enable Userdata size, and Image size.
Allow one time acces from DSU Side loader
From the notification bar - Dynamic System updates -> Press on Restart.
Phone will boot into the Lineage OS with Superuser permission.
Skip the Wizard. of the OS.
Install from the Internet Termux
Open Termux
Type su
Prompt SuperUser grant it.
Use script below of Xiaomi.
It will give 2 lines:
init_boot_a = /dev/block/sde30
init_boot_b = /dev/block/sde59
Extract both of these images of the init_boot_a & b.
dd if=/dev/block/sde30 of=/sdcard/init_boot_a.img
dd if=/dev/block/sde59 of=/sdcard/init_boot_b.img
Extract the init_boot_a and b .img to the PC.
Reboot to the normal state of the phone from the notification bar
Install Magisk.apk.
Patch the one of the Init_boot file. One will be succeed.
Extract the pathed_magisk-image copy that to the adb directory of your pc.
Enable USB debugging from devp mode.
Open CMD -> type adb devices to see if its detect.
type adb reboot fastboot
Because its a init_boot image file, type the following:
type fastboot flash init_boot magisk_patched.img
Quickly go in to the Magisk app, Find Magisk app in your device, open it, click “install” and then check “direct install”, then press “let’s go”. Magisk will now install and make the root permanent. Now click “reboot” and the device will restart.