Is there any way to backup/dump kernel image without root or twrp/cwm ?
2 Answers
It is possible to dump device partitions without root or custom recovery - if your device has "fastboot" mode and is boot unlocked. I'm not going to describe unlocking the boot loader, but with a fastboot device it is usually pretty easy - search the internet for instructions for your specific device.
You will need a TWRP recovery image for your device, but you don't need to actually install it on the device - we'd just temporarily boot into it to get access to the raw boot partition. Look at https://twrp.me/Devices/ and download the image for your device.
Preparations:
You need to find out which partition you want to backup from the device's storage. Usually there is a by-name
directory somewhere under the devices tree that lists all the operating system's partitions with names and physical partition identifiers.
- Install ADB and Fastbook command line tools.
- On your device, enable "Developer Mode" and then go into the developer settings and enable "USB debugging".
- Connect your device to your computer.
- On your computer run
adb devices
and verify your device is listed. You may need to authorize access on the device itself in a popup that will appear. - Run
adb shell
to go into the device's command line shell - Run
find /dev -name 'by-name' 2>/dev/null
to find theby-name
directory. It should list one, though if there are a couple, it shouldn't be a problem and both should work. - Take the directory name and run
ls -la <by-name-directory>
(replacing the place holder with the actual directory name) - Find the name of the partition you are interested in - if you want just the kernel, the name is
boot
, or if your device has multiple slots, it is probablyboot_a
- and record the physical partition path listed for it. It should be something like/dev/block/mmcblk0p22
(this is on my Mi A1 device - if you have a different one, the number after "p" will be different and possibly even the number before "p").
If you do not have a by-name
directory on your device, you might want to search the internet for the correct device name, though there are ways to detect the correct partition from within the device - comment if you need help.
Steps to Backup
- Reboot your device to the fastboot boot loader. There's usually a boot time key combination for this, on my Xiaomi Mi A1 its POWER + VOLUME-DOWN, but you can also use ADB to do that: execute
adb reboot-bootloader
to go directly to fastboot mode. - Use fastboot to boot into the TWRP image you downloaded, without installing it on the device:
fastboot boot recovery-3.2.1-1.img
. It will take a couple of minutes for the device to boot into TWRP, so be patient. - On your computer, run
adb pull /dev/block/mmcblk0p22 boot.img
, replacing "mmcblk0p22
" with the correct boot device path you found in the preparations stage, and "boot.img
" with where you actually want to save the kernel boot image.
If your device has multiple boot slots, its probably a good idea to backup both (on my device, for some reason, after a clean install and update, they are not identical).
Good luck.
-
1First to be honest I can't even remember why I needed to dump these images this way. However in your answer you are using twrp (you don't install it but you are using it, we are not lawyers to use loopholes like that :) ), one more thing you have provided a link to download twrp from official site, but much of phones (those not so famous or not high end devices) doesn't even have an unofficial build, so tough luck for a lot of people. However I appreciate the effort, cheers. Commented Jun 1, 2018 at 23:02
-
1Well, if we can't load any custom boot code, then the answer would have to be "no, you can't". You don't have to use official TWRP - you can use any recovery that offers adb access. You didn't mention which device your using, so I had to go with a generic solution. That being said, I wrote this for my own needs, which BTW is using a Xiaomi Mi A1, that is not a high end not overly famous, and it has a TWRP release. I hope this answer helps other people, and if you still want to try it and your missing something (like a TWRP release) - please give more details on your device and I'll try to help– GussCommented Jun 1, 2018 at 23:40
-
-
+1 You might find convenient to list candidate partitions in one shot with:
ls -al --color $(find /dev|grep by-name$)
– antonioCommented Jan 16, 2021 at 21:26 -
On some devices this won't work due to bootloader lock. E.g., on my bootloader locked OnePlus 9 when I try to boot twrp, I get "boot is not allowed in Lock State". Commented Dec 25, 2021 at 22:34
I just used
dd if=/dev/block/mmcblk0p15 of=test_boot.img
and then used adb to download the file for a backup of the boot ramfs
-
4To do this you'd need root access on your device (for raw block access through the device tree), and busybox (for
dd
) - which you'd also need root access to install, through most rooting manuals and/or "su applications" include it. Also,mmcblk0p15
may be right for your device but is unlikely to be correct for devices from other manufacturers (or even the same manufacturer). In my answer I describe a method to find the correct block device for any Android phone.– GussCommented Feb 10, 2019 at 13:12
dd
. Without root? Guess not.