I need to delete or corrupt modemst1, modemst2 and fsg partitions - Xiaomi Mi 4C

I need to change my imei and when I follow guides on the net I am stuck at deleting modemst1, modemst2 and fsg partitions. The purpose of that is to make the device let me write modified imei partitions later.
I am trying to delete the partitions by the following commands
adb shell
su
and after I am root
dd if=/dev/zero of=/dev/block/xxxxxxx where xxxxxxx is the partition I am trying to delete. However, I get
"No space left on device"
and the partitions remain intact.
fastboot erase does not work since the partitions are write-protected.
I am open to suggestions of other strategies to change intact IMEI number.

arjantin78 said:
I need to change my imei
Click to expand...
Click to collapse
I'm afraid I don't have a solution for you, but I'd like to warn you that changing the IMEI of a mobile device is illegal in many countries. I hope it's not in yours. Good luck!

Related

[IMP] [SCRIPTS] IMEI backup scripts for MOTO G /E(all variants) Rooted.

This script creates backup of partitions related to IMEI number. If you have not unlocked your boot-loader then you do not have to worry, you're safe. But read this in case you root someday!
DISCLAIMER:
I am not responsible for any damage caused to your device in any manner, you should be careful while doing anything. Before you proceed please read everything.
DESCRIPTION
The IMEI number is like an identifier to your cellphone for network operators. The phones will not be able to communicate in case IMEI is lost. The IMEI number is generally stored in PDS partition of the EMMC but the Moto g is an exception, there is no physical EFS partition so NV-Items are inaccessible for manipulation which means backing up PDS partition only will not make any sense.
The EFS is created on the fly: the modem reads HOB and DHOB partitions and after manipulations it creates a EFS file-system which is isolated from rest of the system. The modem finds the baseband, MEID, IMEI etc. and reports it to the OS.
The DHOB partition is encrypted and the key used is a PBKFD2 derived key for which the details like passkey, salt and iterations are unknown. HOB partition is XML-formatted and contains encrypted base64 text items. The secret is yet to be discovered.
Reference
http://forum.xda-developers.com/moto-g/help/info-moto-g-imei0-t2925970/post62064474#post62064474
http://forum.xda-developers.com/showthread.php?t=2640677
What does the script do?
This script simply creates the dumps of HOB, DHOB, FSC and PDS partition.
REQUIREMENTS:
A rooted phone is bare minimum and rest depends upon the method you choose. Download the archive one is for Linux and other is for Windows.
Choose any one.
FROM PHONE:-
1. Download and install any “Terminal Emulator” application from App store.
2. Type su and press enter to have superuser privileges.
3. Run these commands one-by-one.
HTML:
su
mkdir /sdcard0/imei_backup
dd if=/dev/block/platform/msm_sdcc.1/by-name/hob" of=/sdcard0/imei_backup/hob.img
dd if=/dev/block/platform/msm_sdcc.1/by-name/dhob" of=/sdcard0/imei_backup/dhob.img
dd if=/dev/block/platform/msm_sdcc.1/by-name/fsc" of=/sdcard0/imei_backup/fsc.img
dd if=/dev/block/platform/msm_sdcc.1/by-name/pds" of=/sdcard0/imei_backup/pds.img
4. Copy imei_backup from the top folder of internal storage or SD-card.
FROM PC:-
1. Enable ROOT for both apps and adb from developer options.
2. Open cmd or terminal hange current location to folder imei_linux or imei_windows extracted from archive.
3. Run the below commands from cmd or terminal.
Windows
Make sure you have Motorola drivers installed (Motorola device manager).
HTML:
imei_backup.bat
Linux
Superuser privileges are necessary.
HTML:
sudo bash imei_backup.sh
or
su -C 'bash imei_backup.sh'
4. Once finished save imei_backup folder to someplace safe. The folder sits in the same folder the commands are run and in phone's internal storage or SD card.
FOR RESTORATION
1. Copy imei_backup folder to /sdcard (both internal or SD-Card in case you are not sure)
2. Open terminal emulator on phone and run these commands, all of them do not miss any. Run all of them twice to be sure.
HTML:
dd if=/sdcard0/imei_backup/hob.img of=/dev/block/platform/msm_sdcc.1/by-name/hob"
dd if=/sdcard0/imei_backup/dhob.img of=/dev/block/platform/msm_sdcc.1/by-name/dhob"
dd if=/sdcard0/imei_backup/fsc.img of=/dev/block/platform/msm_sdcc.1/by-name/fsc"
dd if=/sdcard0/imei_backup/pds.img of=/dev/block/platform/msm_sdcc.1/by-name/pds"
4. Reboot your phone.
How to keep IMEI safe:
1. Do not use incompatible Roms or firmware.
2. Never run these commands.
Don't even try, I have screwed my phone already. Misspelled for safety.
HTML:
Fast-boot erasee all (Don't)
Fast-boot erasee recovery (Don't)
Fast-boot erasee HOB (Don't)
Fast-boot erasee DHOB (Don't)[/COLOR]
Fast-boot erasee earth (Please Don't)
Run any of these commands and your phone turn into a tablet forever.
3. Create backup of the partitions i mentioned using one of the methods.
FAQS:-
Does it work on Dual-Sim or CDMA ?
Yes, it works. It just creates partition dumps, nothing more nothing less. It should work on Moto G (1st and 2nd gen) all variants and Moto E (1st and 2nd).
Is it safe to share my imei_backup folder if anyone asks?
Yes, the content is encrypted and there is no chance of manipulation of IMEI, the NV-ITEMS are written after verification. No two phones can have same IMEI. If it was possible then I wouldn't be so mad or worried or you would not be reading this. The best he could achieve is base-band change and signal but IMEI stays zero. No Cheating!
I have PDS partition backup, why should I care about this?
The PDS partition alone is no good for recovery, there are other partitions which help phone get a working cellular and valid IMEI number, those partition are HOB and DHOB. You can create backup through terminal emulator.
Why should I believe you?
I am a victim and did research on this for like 30 days. I do have a clear idea of what the problem really is. Please refer to mentioned threads for more information.
I have lost my IMEI because of “fast-boot erase all” command, can I get my IMEI back?
Sorry! But there is no working solution at the moment. All you can do right now is either buy a new motherboard or a spare phone to do work. The cure has not been found till now and hopes are really low unless some guy with good cryptography knowledge comes to rescue. So far i only know the problem
Very useful, thanks. Just want to add my experience - actually I did run "fast-boot erasee recovery" once in the past and did lost IMEI, but it was possible to recover it in an easy way. But those other commands seem to be really catastrophic indeed (though I haven´t tried them )
Here´s the original story: http://forum.xda-developers.com/showthread.php?p=52648789
drfr said:
Very useful, thanks. Just want to add my experience - actually I did run "fast-boot erasee recovery" once in the past and did lost IMEI, but it was possible to recover it in an easy way. But those other commands seem to be really catastrophic indeed (though I haven´t tried them )
Here´s the original story: http://forum.xda-developers.com/showthread.php?p=52648789
Click to expand...
Click to collapse
It is always better to be safe than sorry. The thing is if you lose hob and dhob partitions, you are doomed. I am glad to know that your phone is intact.
Script works well - thanks for this.
Well I'm here to ask something related to the problems issued in this thread.
I got a XT1032 with IMEI fully written but, for some reasons I still don't know, the damn phone does not "read" the signal. The bars just stay empty and nothing, not even a full original firmware restore, seems to help.
Now I wonder if the problem is in a non-working modem partition, but I'd see that problem solved when I fully flashed the stock FW.
Is there any solution? I also tried to flash all the european (I'm italian) basebands known to mankind and nothing happens.
Dionysus2389 said:
Well I'm here to ask something related to the problems issued in this thread.
I got a XT1032 with IMEI fully written but, for some reasons I still don't know, the damn phone does not "read" the signal. The bars just stay empty and nothing, not even a full original firmware restore, seems to help.
Now I wonder if the problem is in a non-working modem partition, but I'd see that problem solved when I fully flashed the stock FW.
Is there any solution? I also tried to flash all the european (I'm italian) basebands known to mankind and nothing happens.
Click to expand...
Click to collapse
When you dial *#06# do you see your IMEI number?
PuLKit4xd said:
When you dial *#06# do you see your IMEI number?
Click to expand...
Click to collapse
Yep, the IMEI is there as it is in the phone info. That's why I can't figure out what the heck is wrong with it. I also tried to flash any baseband and still no signal.
Dionysus2389 said:
Well I'm here to ask something related to the problems issued in this thread.
I got a XT1032 with IMEI fully written but, for some reasons I still don't know, the damn phone does not "read" the signal. The bars just stay empty and nothing, not even a full original firmware restore, seems to help.
Now I wonder if the problem is in a non-working modem partition, but I'd see that problem solved when I fully flashed the stock FW.
Is there any solution? I also tried to flash all the european (I'm italian) basebands known to mankind and nothing happens.
Click to expand...
Click to collapse
PuLKit4xd said:
When you dial *#06# do you see your IMEI number?
Click to expand...
Click to collapse
Dionysus2389 said:
Yep, the IMEI is there as it is in the phone info. That's why I can't figure out what the heck is wrong with it. I also tried to flash any baseband and still no signal.
Click to expand...
Click to collapse
Aaaaan then I managed to fix everything. Simply, kitkat european firmwares have some issues with basebands, so I wipe everything and flash via mfastboot the 5.0.2 brazillian stock firmware. Everything is flawless now!
Hi all, thanks for this huge piece of info, very usefull, but i need from you if you have the backup of the files for XT1540 (moto g3 4g).
Cheers
PuLKit4xd said:
This script creates backup of partitions related to IMEI number. If you have not unlocked your boot-loader then you do not have to worry, you're safe. But read this in case you root someday!
DISCLAIMER:
I am not responsible for any damage caused to your device in any manner, you should be careful while doing anything. Before you proceed please read everything.
DESCRIPTION
The IMEI number is like an identifier to your cellphone for network operators. The phones will not be able to communicate in case IMEI is lost. The IMEI number is generally stored in PDS partition of the EMMC but the Moto g is an exception, there is no physical EFS partition so NV-Items are inaccessible for manipulation which means backing up PDS partition only will not make any sense.
The EFS is created on the fly: the modem reads HOB and DHOB partitions and after manipulations it creates a EFS file-system which is isolated from rest of the system. The modem finds the baseband, MEID, IMEI etc. and reports it to the OS.
The DHOB partition is encrypted and the key used is a PBKFD2 derived key for which the details like passkey, salt and iterations are unknown. HOB partition is XML-formatted and contains encrypted base64 text items. The secret is yet to be discovered.
Reference
http://forum.xda-developers.com/moto-g/help/info-moto-g-imei0-t2925970/post62064474#post62064474
http://forum.xda-developers.com/showthread.php?t=2640677
What does the script do?
This script simply creates the dumps of HOB, DHOB, FSC and PDS partition.
REQUIREMENTS:
A rooted phone is bare minimum and rest depends upon the method you choose. Download the archive one is for Linux and other is for Windows.
Choose any one.
FROM PHONE:-
1. Download and install any “Terminal Emulator” application from App store.
2. Type su and press enter to have superuser privileges.
3. Run these commands one-by-one.
HTML:
su
mkdir /sdcard0/imei_backup
dd if=/dev/block/platform/msm_sdcc.1/by-name/hob" of=/sdcard0/imei_backup/hob.img
dd if=/dev/block/platform/msm_sdcc.1/by-name/dhob" of=/sdcard0/imei_backup/dhob.img
dd if=/dev/block/platform/msm_sdcc.1/by-name/fsc" of=/sdcard0/imei_backup/fsc.img
dd if=/dev/block/platform/msm_sdcc.1/by-name/pds" of=/sdcard0/imei_backup/pds.img
4. Copy imei_backup from the top folder of internal storage or SD-card.
FROM PC:-
1. Enable ROOT for both apps and adb from developer options.
2. Open cmd or terminal hange current location to folder imei_linux or imei_windows extracted from archive.
3. Run the below commands from cmd or terminal.
Windows
Make sure you have Motorola drivers installed (Motorola device manager).
HTML:
imei_backup.bat
Linux
Superuser privileges are necessary.
HTML:
sudo bash imei_backup.sh
or
su -C 'bash imei_backup.sh'
4. Once finished save imei_backup folder to someplace safe. The folder sits in the same folder the commands are run and in phone's internal storage or SD card.
FOR RESTORATION
1. Copy imei_backup folder to /sdcard (both internal or SD-Card in case you are not sure)
2. Open terminal emulator on phone and run these commands, all of them do not miss any. Run all of them twice to be sure.
HTML:
dd if=/sdcard0/imei_backup/hob.img of=/dev/block/platform/msm_sdcc.1/by-name/hob"
dd if=/sdcard0/imei_backup/dhob.img of=/dev/block/platform/msm_sdcc.1/by-name/dhob"
dd if=/sdcard0/imei_backup/fsc.img of=/dev/block/platform/msm_sdcc.1/by-name/fsc"
dd if=/sdcard0/imei_backup/pds.img of=/dev/block/platform/msm_sdcc.1/by-name/pds"
4. Reboot your phone.
How to keep IMEI safe:
1. Do not use incompatible Roms or firmware.
2. Never run these commands.
Don't even try, I have screwed my phone already. Misspelled for safety.
HTML:
Fast-boot erasee all (Don't)
Fast-boot erasee recovery (Don't)
Fast-boot erasee HOB (Don't)
Fast-boot erasee DHOB (Don't)[/COLOR]
Fast-boot erasee earth (Please Don't)
Run any of these commands and your phone turn into a tablet forever.
3. Create backup of the partitions i mentioned using one of the methods.
FAQS:-
Does it work on Dual-Sim or CDMA ?
Yes, it works. It just creates partition dumps, nothing more nothing less. It should work on Moto G (1st and 2nd gen) all variants and Moto E (1st and 2nd).
Is it safe to share my imei_backup folder if anyone asks?
Yes, the content is encrypted and there is no chance of manipulation of IMEI, the NV-ITEMS are written after verification. No two phones can have same IMEI. If it was possible then I wouldn't be so mad or worried or you would not be reading this. The best he could achieve is base-band change and signal but IMEI stays zero. No Cheating!
I have PDS partition backup, why should I care about this?
The PDS partition alone is no good for recovery, there are other partitions which help phone get a working cellular and valid IMEI number, those partition are HOB and DHOB. You can create backup through terminal emulator.
Why should I believe you?
I am a victim and did research on this for like 30 days. I do have a clear idea of what the problem really is. Please refer to mentioned threads for more information.
I have lost my IMEI because of “fast-boot erase all” command, can I get my IMEI back?
Sorry! But there is no working solution at the moment. All you can do right now is either buy a new motherboard or a spare phone to do work. The cure has not been found till now and hopes are really low unless some guy with good cryptography knowledge comes to rescue. So far i only know the problem
Click to expand...
Click to collapse
Need help!!
It does not work for me. whenever any command with /sdcard is written, it replies "/sdcard/hob.img :File or directory not found."
Please help.
Thanks in advance : )

sp flash tool can't backup userdata ?

Hello,
I have an issue trying to readback and then flash userdata partition.
In one device it worked without issues (I actually dd from linux the userdata in that device).
But in a second device its just does not work. I tried dd, I tried readback, but after programming the image, it fails to boot.
Using twrp backup/restore works.
I don't understand why userdata partition can't be backup and restored with sp flash.
I also noticed a very strange issue, that the text in this device gives only 1.6G to userdata, while dd and /cat/partitions shows 5.5G.
I tried to change the text to 5.5G but it did not help neighter...
Please help.
Regards,
ranran

[HOW-TO] Recover Bricked U11+

Greetings all.
Several weeks ago, I made this post seeking help with a self-created problem. I am happy to announce that the problem has been resolved with the immense help of sephstyler. He is literally my phone's messiah.
The afore-mentioned XDA member has a device identical to mine. I borrowed his and mirrored most of the data on his device by copying several partitions off his phone on to mine. I followed this guide about changing CID/MID.
I got a hold of a notepad document (you'll find it here) that lists partition information of the U11+. I wasn't sure which of my partitions were corrupt but I was certain the one containing the OS and IMEI information were messed up. My IMEI was blank. The OS version reported in fastboot was 9.99999 or something like that.
So I set out to copy these partitions and their corresponding img files in no particular order - boot, hosd, radio, modemst1, modemst2, cache, system, vendor, persist, and sdf1 (which carries CID info).
Please note that this method fixes the issue where your device is stuck on the bootloader screen with the message, "this phone has been flashed with unauthorised software and is locked....." And you will need a second device that is identical to yours (and functional too) for this process to work. I don't know if they both have to come from the same region (i.e have the same CID and MID). I guess there is no harm in trying. You couldn't possibly do more harm to your device by doing this. Or maybe you could. Either way, I will not be held responsible for any undesirable outcomes.
Steps taken:
- I installed HTC drivers on my computer, running Windows 10 64-bit. And 15-second ADB Installer. Get them both from here and here. I uninstalled HTC Sync Manager after the installation was done as I only needed the drivers.
- I flashed TWRP on the borrowed device so I could have access to adb from recovery.
- I then opened up a command prompt window on my computer, typed adb devices just to be sure that drivers were installed correctly.
The next few steps can be achieved right from within TWRP using the Terminal function. But I chose to use my computer as it'd be much quicker and I am less likely to make typos on a full-sized keyboard.
In a command prompt window, type adb shell. Hit enter.
To copy the system image, type dd if=/dev/block/sda5 of=/sdcard/system.img
For cache, type dd if=/dev/block/sdd21 of=/sdcard/cache.img
For boot, type dd if=/dev/block/sda3 of=/sdcard/boot.img
For radio, type dd if=/dev/block/sdd13 of=/sdcard/radio.img
For modemst1, type dd if=/dev/block/sde2 of=/sdcard/modemst1.img
For modemst2, type dd if=/dev/block/sde3 of=/sdcard/modemst2.img
For persist, type dd if=/dev/block/sde5 of=/sdcard/persist.img
For vendor, type dd if=/dev/block/sda6 of=/sdcard/vendor.img
For sdf1 (board_info), type dd if=/dev/block/sdf1 of=/sdcard/sdf1.img
For hosd, type dd if=/dev/block/sdd12 of=/sdcard/hosd.img
These img files would be saved to your internal storage. I then copied all files to the root folder of my faulty device's storage using Windows Explorer. System.img however refused to transfer. I got creative and used a microSD to make the transfer possible.
Now that these files were sitting comfortably on my phone, I booted to TWRP, connected it to my PC, then entered the following commands in Command Prompt via adb shell.
To copy these images to the appropriate partitions on your phone:
For board_info, type dd if=/sdcard/sdf1.img of=/dev/block/sdf1
For system, type dd if=/sdcard/system.img of=/dev/block/sda5
For cache, type dd if=/sdcard/cache.img of=/dev/block/sdd21
For boot, type dd if=/sdcard/boot.img of=/dev/block/sda3
For radio, type dd if=/sdcard/radio.img of=/dev/block/sdd13
For modemst1, type dd if=/sdcard/modemst1.img of=/dev/block/sde2
For modemst2, type dd if=/sdcard/modemst2.img of=/dev/block/sde3
For persist, type dd if=/sdcard/persist.img of=/dev/block/sde5
For vendor, type dd if=/sdcard/vendor.img of=/dev/block/sda6
For hosd, type dd if=/sdcard/hosd.img of=/dev/block/sdd12
Upon completion, press Ctrl+C or type exit to quit adb shell. Then type adb reboot to reboot your device.
If the above commands were entered correctly (and if the adb gods smile upon you), your device should be restored.
Now I know that copying all images fixed the issue. My guess is the system, boot, and radio images were the crucial ones. I am not entirely sure. But I was desperate for a positive result so I copied the ones that I deemed important.
I hope this helps someone. Cheers.
P.S: My apologies for the formatting. I am still fairly new to this. Also, I just realised I could upload these images for anyone who doesn't have access to a second device. I shall update the post with download links after the upload's completed. Sorry about the brain fart.
[EDIT] Images are up. You can find them here. These files are for the Taiwan-based HTC U11+ (CID - HTC_621)
Nice tutorial.
Hi, I'm having a similar problem with my U11+.... followed ur download link but a decryption key is needed. whats the decryption key?
ChuDust said:
Hi, I'm having a similar problem with my U11+.... followed ur download link but a decryption key is needed. whats the decryption key?
Click to expand...
Click to collapse
Here's the key. I had no idea the files were encrypted to begin with. Sorry about that.
-b087zdU9re0k3e3HHah1w
P.S: Since you're downloading the image files from the link provided, you don't have to go through the first half of the process - copying data from a working phone to an external location.
Best of luck.
Hello. I have an identical situation. My original CID is 622. I changed the CID to 001, but after RUU firmware I could not boot into the system. Now after flash RUU, the phone will reboot into the bootloader. Can anyone help me?
Do you have to be rooted or with unlocked bootloader to be able to backup the phone partitions using this method ?
Or does it just work on completely stock from an db connection to PC ?
Thank you.
The bootloader needs to be unlocked at the very least so you can gain access to the required partitions. Root isn't necessary.
Hope this helps.
Hello, I followed your instructions and made backups of my partitions from HTC U11+ dual-sim european version 401.12.
With unlocked bootloader and rooted with magisk by patched boot image.
Ran adb shell and su while phone was running normally in Android OS and connected to PC.
I'm curious about the sizes of the images created because they don't match with the sizes from partitions.txt.
For example "4210688 sda5 - system" is actually 4,311,744,512 bytes,
"65536 sda3 - boot" is actually 67,108,864 bytes in created image, but the actual boot.img from the OTA file is 38,163,762 bytes.
If these sizes are different can I actually trust the created images ? and use them in need.
Can these created images be flashed by fastboot, for example for system.img: "fastboot flash -S 1G system system.img" ?
Thanks.
andreipaval said:
I'm curious about the sizes of the images created because they don't match with the sizes from partitions.txt.
For example "4210688 sda5 - system" is actually 4,311,744,512 bytes,
"65536 sda3 - boot" is actually 67,108,864 bytes in created image, but the actual boot.img from the OTA file is 38,163,762 bytes.
Thanks.
Click to expand...
Click to collapse
If you divide the 4,311,744,512 bytes by the 1024, you get what you need - 4210688 - this is in Kb.
And so same for boot - 67,108,864 bytes / 1024 = 65536 Kb.
andreipaval said:
Hello, I followed your instructions and made backups of my partitions from HTC U11+ dual-sim european version 401.12.
With unlocked bootloader and rooted with magisk by patched boot image.
Ran adb shell and su while phone was running normally in Android OS and connected to PC.
I'm curious about the sizes of the images created because they don't match with the sizes from partitions.txt.
For example "4210688 sda5 - system" is actually 4,311,744,512 bytes,
"65536 sda3 - boot" is actually 67,108,864 bytes in created image, but the actual boot.img from the OTA file is 38,163,762 bytes.
If these sizes are different can I actually trust the created images ? and use them in need.
Can these created images be flashed by fastboot, for example for system.img: "fastboot flash -S 1G system system.img" ?
Thanks.
Click to expand...
Click to collapse
Hi. I hope your first question was answered. Regarding your second concern, I'm afraid I don't have an answer to that. At the time, flashing any image files onto my device didn't fix the issue even though each flash completed successfully. Copying them manually sure did.
Hope this helps.
Do you have the twrp backup of the stock rom?
andreipaval said:
Hello, I followed your instructions and made backups of my partitions from HTC U11+ dual-sim european version 401.12.
With unlocked bootloader and rooted with magisk by patched boot image.
Ran adb shell and su while phone was running normally in Android OS and connected to PC.
I'm curious about the sizes of the images created because they don't match with the sizes from partitions.txt.
For example "4210688 sda5 - system" is actually 4,311,744,512 bytes,
"65536 sda3 - boot" is actually 67,108,864 bytes in created image, but the actual boot.img from the OTA file is 38,163,762 bytes.
If these sizes are different can I actually trust the created images ? and use them in need.
Can these created images be flashed by fastboot, for example for system.img: "fastboot flash -S 1G system system.img" ?
Thanks.
Click to expand...
Click to collapse
Hello,
do you have the twrp backup of stock rom?
I did not make backups with twrp.

[Guide] [XT16XX] Moto G4/Plus Complete Partition Backup/Restore Zip/Script

Code:
#include <disclaimer.h>
/*
* Your warranty is now.......(wait a minute)........still valid?
*
* I am not responsible for bricked devices.
* YOU are choosing to make these modifications, and if you point
* your finger at me for messing up your device, I will laugh at you.
*/
As we know that on flashing ROMs/kernels/other mods, we sometimes do some mistake or face some issues so it is always recommended to take backup.
But unfortunately, TWRP does not takes backup of all the partitions.
When you open/dev/block/bootdevice/by-name/ you can see the names of the partitions and there are a total of 48 partitions. Of course not every one of them is important to back up, but it's better to be safe than sorry.
This method has been tested on my Moto G4 Plus (XT1643) and all the parts are work on it (backup and restore both using zip file and batch file)
Here is the list to all those partitions along with their number/id (maybe that's what its called, please correct me if there's any mistake)
Code:
Number/ID Name
mmcblk0p1 modem
mmcblk0p2 fsc
mmcblk0p3 ssd
mmcblk0p4 sbl1
mmcblk0p5 sbl1bak
mmcblk0p6 rpm
mmcblk0p7 rpmbak
mmcblk0p8 tz
mmcblk0p9 tzbak
mmcblk0p10 hyp
mmcblk0p11 hypbak
mmcblk0p12 dsp
mmcblk0p13 modemst1
mmcblk0p14 modemst2
mmcblk0p15 DDR
mmcblk0p16 fsg
mmcblk0p17 sec
mmcblk0p18 aboot
mmcblk0p19 abootbak
mmcblk0p20 logs
mmcblk0p21 utags
mmcblk0p22 utagsBackup
mmcblk0p23 cid
mmcblk0p24 logo
mmcblk0p25 clogo
mmcblk0p26 metadata
mmcblk0p27 kpan
mmcblk0p28 boot
mmcblk0p29 recovery
mmcblk0p30 persist
mmcblk0p31 misc
mmcblk0p32 config
mmcblk0p33 limits
mmcblk0p34 mota
mmcblk0p35 devcfg
mmcblk0p36 dip
mmcblk0p37 syscfg
mmcblk0p38 cmnlib
mmcblk0p39 keymaster
mmcblk0p40 frp
mmcblk0p41 padC
mmcblk0p42 sp
mmcblk0p43 hw
mmcblk0p44 customize
mmcblk0p45 oem
mmcblk0p46 cache
mmcblk0p47 system
mmcblk0p48 userdata
modemst1 and modemst2 are your EFS (the IMEI which you see in settings). When we flash Stock ROM, we erase them with fastboot erase commands but they are regenerated with the help of persist, so never ever restore somebody else's persist on your device and always keep a backup of modemst1, modemst2 a.k.a EFS and persist.
@givitago has already made a backup script for all the partitions which can be found here: Complete Partition Backup Script, so huge thanx to him!
Q) So why create another thread?
A) Frankly speaking, this thread does the same work as the above-mentioned thread, but it also talks about restoring the backup.
Also, now you can back up the partitions with a TWRP flashable zip file and restore them too with a TWRP flashable zip too!
The backup and restore will be done using dd commands.
Those who are unaware of dd commands, it is generally used for converting files.
Here is the syntax for dd command (I have used colors so that it is easy to differentiate them):
Code:
[COLOR="Green"]su
dd[/COLOR] [COLOR="Blue"]if=/directoryName/fileName[SIZE="4"].[/SIZE]fileExtension[/COLOR] [COLOR="DeepSkyBlue"]of=/yourDirectoryName/yourFileName[SIZE="4"].[/SIZE]yourFileExtension[/COLOR]
directoryName is the generic name of the directory where the file (which we want to access) is present.
fileName is the generic name of the file which we want to access.
fileExtension is the generic file extension of the file which we want to access.
yourDirectoryName is the generic name of the directory where we will store the file.
yourFileName is the generic name of the file which we will store as backup.
yourFileExtension is the generic file extension of the file which we are taking a backup of.
And lastly, su because we will run these commands under root permissions.
This thread is divided into 2 parts, backup and restore.
We will be using .img extension for the backed up partitions.
Pre-requisites:
You must be on latest Stock ROM
You must be rooted (install Elemental-X kernel first and then flash Magisk otherwise you will have boot issues)
Terminal app or adb drivers in PC/Laptop
Official TWRP only (if you use adb in TWRP)
Note: The below commands are to be typed in a terminal app or adb shell.
Q) How to type in adb shell?
A) Open command prompt in the folder where you have adb and fastboot installed and type:
Code:
adb shell
Code:
su
This command it to get root access for the terminal/shell. Grant the root access and you will see that the $ symbol is replaced with# symbol which means that root access has been granted.
You can skip this command if you are using TWRP (although then you wouldn't be able to backup build.prop)
Note: The flashable zip files are attached as well as their link has been given. The rar files are the ones which contain the commands for backup/restore and also contains the batch file.
Its been a while since I have moved on to a newer device, and not remember quite a few things about the device. Here is something important to note:
echo92 said:
Just a thought, do you think it'd be worth stressing to users of the recovery script to ensure they do NOT include any of the bootloader partitions in their recovery folder? I've seen a couple of users hard brick their devices by attempting to flash older bootloader partitions accidentally ( luckily, now we've got a newer OPJ28.111-22 blankflash).
I think the partitions to avoid restoring are:
mmcblk0p4 sbl1
mmcblk0p5 sbl1bak
mmcblk0p6 rpm
mmcblk0p7 rpmbak
mmcblk0p8 tz
mmcblk0p9 tzbak
mmcblk0p10 hyp
mmcblk0p11 hypbak
mmcblk0p18 aboot
mmcblk0p19 abootbak
Possibly more if there are other critical partitions not accounted for.
Click to expand...
Click to collapse
This method won't backup/restore system, userdata and cache as they take up too much space and are reset on flashing Stock ROM again.
Part 1: Backup
Here are the list of commands which will be used to backup the partitions:
Code:
mkdir /sdcard/Athene_Partitions
dd if=/system/build.prop of=/sdcard/Athene_Partitions/build.prop
dd if=/dev/block/bootdevice/by-name/aboot of=/sdcard/Athene_Partitions/aboot.img
dd if=/dev/block/bootdevice/by-name/abootbak of=/sdcard/Athene_Partitions/abootbak.img
dd if=/dev/block/bootdevice/by-name/boot of=/sdcard/Athene_Partitions/boot.img
dd if=/dev/block/bootdevice/by-name/cid of=/sdcard/Athene_Partitions/cid.img
dd if=/dev/block/bootdevice/by-name/clogo of=/sdcard/Athene_Partitions/clogo.img
dd if=/dev/block/bootdevice/by-name/cmnlib of=/sdcard/Athene_Partitions/cmnlib.img
dd if=/dev/block/bootdevice/by-name/config of=/sdcard/Athene_Partitions/config.img
dd if=/dev/block/bootdevice/by-name/customize of=/sdcard/Athene_Partitions/customize.img
dd if=/dev/block/bootdevice/by-name/DDR of=/sdcard/Athene_Partitions/DDR.img
dd if=/dev/block/bootdevice/by-name/devcfg of=/sdcard/Athene_Partitions/devcfg.img
dd if=/dev/block/bootdevice/by-name/dip of=/sdcard/Athene_Partitions/dip.img
dd if=/dev/block/bootdevice/by-name/dsp of=/sdcard/Athene_Partitions/dsp.img
dd if=/dev/block/bootdevice/by-name/frp of=/sdcard/Athene_Partitions/frp.img
dd if=/dev/block/bootdevice/by-name/fsc of=/sdcard/Athene_Partitions/fsc.img
dd if=/dev/block/bootdevice/by-name/fsg of=/sdcard/Athene_Partitions/fsg.img
dd if=/dev/block/bootdevice/by-name/hw of=/sdcard/Athene_Partitions/hw.img
dd if=/dev/block/bootdevice/by-name/hyp of=/sdcard/Athene_Partitions/hyp.img
dd if=/dev/block/bootdevice/by-name/hypbak of=/sdcard/Athene_Partitions/hypbak.img
dd if=/dev/block/bootdevice/by-name/keymaster of=/sdcard/Athene_Partitions/keymaster.img
dd if=/dev/block/bootdevice/by-name/kpan of=/sdcard/Athene_Partitions/kpan.img
dd if=/dev/block/bootdevice/by-name/limits of=/sdcard/Athene_Partitions/limits.img
dd if=/dev/block/bootdevice/by-name/logo of=/sdcard/Athene_Partitions/logo.img
dd if=/dev/block/bootdevice/by-name/logs of=/sdcard/Athene_Partitions/logs.img
dd if=/dev/block/bootdevice/by-name/metadata of=/sdcard/Athene_Partitions/metadata.img
dd if=/dev/block/bootdevice/by-name/misc of=/sdcard/Athene_Partitions/misc.img
dd if=/dev/block/bootdevice/by-name/modem of=/sdcard/Athene_Partitions/modem.img
dd if=/dev/block/bootdevice/by-name/modemst1 of=/sdcard/Athene_Partitions/modemst1.img
dd if=/dev/block/bootdevice/by-name/modemst2 of=/sdcard/Athene_Partitions/modemst2.img
dd if=/dev/block/bootdevice/by-name/mota of=/sdcard/Athene_Partitions/mota.img
dd if=/dev/block/bootdevice/by-name/oem of=/sdcard/Athene_Partitions/oem.img
dd if=/dev/block/bootdevice/by-name/padC of=/sdcard/Athene_Partitions/padC.img
dd if=/dev/block/bootdevice/by-name/persist of=/sdcard/Athene_Partitions/persist.img
dd if=/dev/block/bootdevice/by-name/recovery of=/sdcard/Athene_Partitions/recovery.img
dd if=/dev/block/bootdevice/by-name/rpm of=/sdcard/Athene_Partitions/rpm.img
dd if=/dev/block/bootdevice/by-name/rpmbak of=/sdcard/Athene_Partitions/rpmbak.img
dd if=/dev/block/bootdevice/by-name/sbl1 of=/sdcard/Athene_Partitions/sbl1.img
dd if=/dev/block/bootdevice/by-name/sbl1bak of=/sdcard/Athene_Partitions/sbl1bak.img
dd if=/dev/block/bootdevice/by-name/sec of=/sdcard/Athene_Partitions/sec.img
dd if=/dev/block/bootdevice/by-name/sp of=/sdcard/Athene_Partitions/sp.img
dd if=/dev/block/bootdevice/by-name/ssd of=/sdcard/Athene_Partitions/ssd.img
dd if=/dev/block/bootdevice/by-name/syscfg of=/sdcard/Athene_Partitions/syscfg.img
dd if=/dev/block/bootdevice/by-name/tz of=/sdcard/Athene_Partitions/tz.img
dd if=/dev/block/bootdevice/by-name/tzbak of=/sdcard/Athene_Partitions/tzbak.img
dd if=/dev/block/bootdevice/by-name/utags of=/sdcard/Athene_Partitions/utags.img
dd if=/dev/block/bootdevice/by-name/utags-Backup of=/sdcard/Athene_Partitions/utags-Backup.img
The first command mkdir is used to create a folder named "Athene_Partitions" in your /sdcard directory, where all the partitions will be saved.
There is also a command to back up build.prop
Note: /sdcard is the same as the Internal storage directory. Do not confuse it with micro Sdcard as it has its directory named as /external_sd
I have not included backup of system, userdata, and cache partitions (system and userdata have huge sizes)
All these commands will create a backup of all the partitions except system, userdata and cache.
You can simply copy and paste them on the terminal and it will execute all of the commands simultaneously one after the other.
I am attaching a .bat file and a .txt file which will basically do the same thing as typing or copy-pasting the above commands.
Note: Backup-Partitions.bat and Backup-Partitions.txt should be saved together in adb and fastboot folder, otherwise the .bat file won't work.
I have created a TWRP flashable zip file which will do the same task as above. Make sure you flash it in Official TWRP only (Unofficial TWRP will also work, but I was facing some problem while restoring the partitions which were backed up using Unofficial TWRP, so just a warning).
Downloads:
Link: https://www.androidfilehost.com/?fid=11410963190603873123
md5: 16b9b34c82ca0cd8674428145961abff
Part 2: Restore
Note: Make sure that you place only the partitions which you want to restore in Athene_Partitions(if its not there, create it and put all the partitions which you want to restore in that folder) folder in /sdcard directory. Its fine if you still run all the commands while restoring partitions, as it will just ignore the files which it didn't find.
If you are using TWRP to restore the partitions, make sure it Official TWRP only (Unofficial TWRP won't work because for some partitions it might reboot in between (It happened with me and I do not know which partitions are causing this (one of them is hw)) so just a warning)
Here are the commands
Code:
dd if=/sdcard/Athene_Partitions/build.prop of=/system/build.prop
dd if=/sdcard/Athene_Partitions/aboot.img of=/dev/block/bootdevice/by-name/aboot
dd if=/sdcard/Athene_Partitions/abootbak.img of=/dev/block/bootdevice/by-name/abootbak
dd if=/sdcard/Athene_Partitions/boot.img of=/dev/block/bootdevice/by-name/boot
dd if=/sdcard/Athene_Partitions/cid.img of=/dev/block/bootdevice/by-name/cid
dd if=/sdcard/Athene_Partitions/clogo.img of=/dev/block/bootdevice/by-name/clogo
dd if=/sdcard/Athene_Partitions/cmnlib.img of=/dev/block/bootdevice/by-name/cmnlib
dd if=/sdcard/Athene_Partitions/config.img of=/dev/block/bootdevice/by-name/config
dd if=/sdcard/Athene_Partitions/customize.img of=/dev/block/bootdevice/by-name/customize
dd if=/sdcard/Athene_Partitions/DDR.img of=/dev/block/bootdevice/by-name/DDR
dd if=/sdcard/Athene_Partitions/devcfg.img of=/dev/block/bootdevice/by-name/devcfg
dd if=/sdcard/Athene_Partitions/dip.img of=/dev/block/bootdevice/by-name/dip
dd if=/sdcard/Athene_Partitions/dsp.img of=/dev/block/bootdevice/by-name/dsp
dd if=/sdcard/Athene_Partitions/frp.img of=/dev/block/bootdevice/by-name/frp
dd if=/sdcard/Athene_Partitions/fsc.img of=/dev/block/bootdevice/by-name/fsc
dd if=/sdcard/Athene_Partitions/fsg.img of=/dev/block/bootdevice/by-name/fsg
dd if=/sdcard/Athene_Partitions/hw.img of=/dev/block/bootdevice/by-name/hw
dd if=/sdcard/Athene_Partitions/hyp.img of=/dev/block/bootdevice/by-name/hyp
dd if=/sdcard/Athene_Partitions/hypbak.img of=/dev/block/bootdevice/by-name/hypbak
dd if=/sdcard/Athene_Partitions/keymaster.img of=/dev/block/bootdevice/by-name/keymaster
dd if=/sdcard/Athene_Partitions/kpan.img of=/dev/block/bootdevice/by-name/kpan
dd if=/sdcard/Athene_Partitions/limits.img of=/dev/block/bootdevice/by-name/limits
dd if=/sdcard/Athene_Partitions/logo.img of=/dev/block/bootdevice/by-name/logo
dd if=/sdcard/Athene_Partitions/logs.img of=/dev/block/bootdevice/by-name/logs
dd if=/sdcard/Athene_Partitions/metadata.img of=/dev/block/bootdevice/by-name/metadata
dd if=/sdcard/Athene_Partitions/misc.img of=/dev/block/bootdevice/by-name/misc
dd if=/sdcard/Athene_Partitions/modem.img of=/dev/block/bootdevice/by-name/modem
dd if=/sdcard/Athene_Partitions/modemst1.img of=/dev/block/bootdevice/by-name/modemst1
dd if=/sdcard/Athene_Partitions/modemst2.img of=/dev/block/bootdevice/by-name/modemst2
dd if=/sdcard/Athene_Partitions/mota.img of=/dev/block/bootdevice/by-name/mota
dd if=/sdcard/Athene_Partitions/oem.img of=/dev/block/bootdevice/by-name/oem
dd if=/sdcard/Athene_Partitions/padC.img of=/dev/block/bootdevice/by-name/padC
dd if=/sdcard/Athene_Partitions/persist.img of=/dev/block/bootdevice/by-name/persist
dd if=/sdcard/Athene_Partitions/recovery.img of=/dev/block/bootdevice/by-name/recovery
dd if=/sdcard/Athene_Partitions/rpm.img of=/dev/block/bootdevice/by-name/rpm
dd if=/sdcard/Athene_Partitions/rpmbak.img of=/dev/block/bootdevice/by-name/rpmbak
dd if=/sdcard/Athene_Partitions/sbl1.img of=/dev/block/bootdevice/by-name/sbl1
dd if=/sdcard/Athene_Partitions/sbl1bak.img of=/dev/block/bootdevice/by-name/sbl1bak
dd if=/sdcard/Athene_Partitions/sec.img of=/dev/block/bootdevice/by-name/sec
dd if=/sdcard/Athene_Partitions/sp.img of=/dev/block/bootdevice/by-name/sp
dd if=/sdcard/Athene_Partitions/ssd.img of=/dev/block/bootdevice/by-name/ssd
dd if=/sdcard/Athene_Partitions/syscfg.img of=/dev/block/bootdevice/by-name/syscfg
dd if=/sdcard/Athene_Partitions/tz.img of=/dev/block/bootdevice/by-name/tz
dd if=/sdcard/Athene_Partitions/tzbak.img of=/dev/block/bootdevice/by-name/tzbak
dd if=/sdcard/Athene_Partitions/utags.img of=/dev/block/bootdevice/by-name/utags
dd if=/sdcard/Athene_Partitions/utagsBackup.img of=/dev/block/bootdevice/by-name/utagsBackup
Like earlier in Step 1, I have not included system, userdata and cache.
You can simply copy and paste them on the terminal and it will execute all of the commands simultaneously one after the other.
I am attaching a .bat file and a .txt file which will basically do the same thing as typing or copy-pasting the above commands.
Note: Restore-Partitions.bat and Restore-Partitions.txt should be saved together in adb and fastboot folder, otherwise the .bat file won't work.
I have created a TWRP flashable zip file which will do the same task as above. Make sure you flash it in Official TWRP only (Unofficial TWRP won't work because for some partitions it might reboot in between (It happened with me and I do not know which partitions are causing this (one of them is hw)) so just a warning).
Just like earlier, just place the partitions you want to restore in Athene_Paritions folder and the zip file will ignore the partitions which aren't present.
Downloads:
Link: https://www.androidfilehost.com/?fid=11410963190603873124
md5: cfd44f834b72342816c308e915791135
Also do note that some people who weren't able to flash hw.img after getting their device changed from Moto G4 Plus to Moto G4, the restoring part wouldn't work for you unless you skip restoring hw.img, but trying won't hurt.
reserved.
Heeth21 said:
reserved.
Click to expand...
Click to collapse
how can i restore system, userdata and cache if i had a 16 gb model? i haven`t enough free space to backup these big parts. :c
commands through termanal app works well, but i want to backup all 48 parts of the stock ROM.
change all "sdcard" to "way_to_my_sd_card" through Msoft Word (faster) and run the script in terminal app, but it crashes and reboot in the process.
vlrgamaley said:
how can i restore system, userdata and cache if i had a 16 gb model? i haven`t enough free space to backup these big parts. :c
commands through termanal app works well, but i want to backup all 48 parts of the stock ROM.
Click to expand...
Click to collapse
I too have 16 GB model. Its just not practically possible to take backup of all these partitions on internal storage.
System, user data and cache will be changed(first erased and then recreated) if you clean flash a Custom ROM.
And on flashing Stock ROM, you will always have them so there isn't much to worry about their backup.
However if you still insist on taking their backup, there are two ways,
0. Reboot to recovery
1. Take their backup in external sd card.
The commands will be:
Code:
su
dd if=/dev/block/bootdevice/by-name/cache of=/external_sd/cache.img
dd if=/dev/block/bootdevice/by-name/system of=/external_sd/system.img
dd if=/dev/block/bootdevice/by-name/userdata of=/external_sd/userdata.img
These commands will save them in your external sd card.
2. Take their backup in PC/Laptop and then convert them
The commands will be:
Code:
adb pull /dev/block/bootdevice/by-name/cache
adb pull /dev/block/bootdevice/by-name/system
adb pull /dev/block/bootdevice/by-name/userdata
These commands will save their copy in your adb folder (so make sure you have enough space in that drive)
These files will have no extension so while restoring them take care of file extensions, so if we want to save them as .img files, we will have to convert them.
Now there are two ways to convert them:
a. Using Command Prompt/Command Line:
In Windows as well as in Linux, their file checksum remains the same, so no worries!
Also, I have restored the converted file (which was converted in Windows) and they work just fine!
Make sure you are running the command prompt/command line from the same directory where your cache, userdata and system files are stored.
Code:
In windows:
ren cache cache.img
ren userdata userdata.img
ren system system.img
In Linux:
mv cache cache.img
mv userdata userdata.img
mv system system.img
b. Directly changing their extension by renaming them:
Just rename the files manually.
Code:
cache->cache.img
system->system.img
userdata->userdata.img
This will change their file extensions.
In Windows as well as in Linux, the checksum remains the same by this method.
Also, I have restored the converted file (which was converted in Windows) and they work just fine!
Though I would still recommend converting them via command prompt/command line!
Edit: If you are using adb pull, it will take time as userdata and system are big partitions, also not to ignore the quality of USB cable, so be patient, it will take a while!
Edit2: @vlrgamaley was your friend able to recover their IMEI, I saw you earlier post in other thread.
Edit2: @vlrgamaley was your friend able to recover their IMEI, I saw you earlier post in other thread.
Click to expand...
Click to collapse
he wrote on phone "persist" twrp backup from Lenovo forum (in ext4 format), and after that phone works. gsm, 3g and calls also works, but 4g isn`t work and imei = 0 is staying. but calls works, and that`s not bad in that situation.
i try to backup userdata on sd and it crashes and boot again and again :c strange.
vlrgamaley said:
he wrote on phone "persist" twrp backup from Lenovo forum (in ext4 format), and after that phone works. gsm, 3g and calls also works, but 4g isn`t work and imei = 0 is staying. but calls works, and that`s not bad in that situation.
i try to backup userdata on sd and it crashes and boot again and again :c strange.
Click to expand...
Click to collapse
He messed up his device for good now. He will never able to recover IMEI now, unless by editing persist.
Backup by rebooting in TWRP.
Heeth21 said:
He messed up his device for good now. He will never able to recover IMEI now, unless by editing persist.
Click to expand...
Click to collapse
i don`t know why he hurry up with that, but he did it and now no way to return)
Heeth21 said:
Backup by rebooting in TWRP.
Click to expand...
Click to collapse
backup userdata in TWRP? ok.
vlrgamaley said:
backup userdata in TWRP? ok.
Click to expand...
Click to collapse
Well, you could do that infact, as TWRP can backup data, system and cache.
If you want to take their backup in .img format, reboot your device in TWRP as TWRP has adb enabled by default and then follow post #6 (https://forum.xda-developers.com/showpost.php?p=78354296&postcount=6)
Heeth21 said:
Well, you could do that infact, as TWRP can backup data, system and cache.
If you want to take their backup in .img format, reboot your device in TWRP as TWRP has adb enabled by default and then follow post #6 (https://forum.xda-developers.com/showpost.php?p=78354296&postcount=6)
Click to expand...
Click to collapse
ooooooooo, hard for me lol) "adb not found" but adb is on (from cmd on windows), and now phone in recovery. what i did wrong? i so stupid, sry)
vlrgamaley said:
ooooooooo, hard for me lol) "adb not found" but adb is on (from cmd on windows), and now phone in recovery? what i did wrong? i so stupid, sry)
Click to expand...
Click to collapse
Make sure you open command prompt from inside the adb folder or direct the command prompt to adb directory.
Open the folder where adb is present, press shift button + mouse right click and then you will see some options like refresh, view, sort by, etc. Select "Open command prompt window here" or "Open powershell window here" or similar to that.
If you open command prompt, then just continue, and if you open powershell, then just type "cmd" and hit enter and then backup.
To check if your device is recognized by pc in adb mode, type "adb devices" and you will see the serial number for your device.
If you have any more questions, do ask, don't do anything stupid as dd commands are very powerful and a mistake could by costly!
Heeth21 said:
Well, you could do that infact, as TWRP can backup data, system and cache.
If you want to take their backup in .img format, reboot your device in TWRP as TWRP has adb enabled by default and then follow post #6 (https://forum.xda-developers.com/showpost.php?p=78354296&postcount=6)
Click to expand...
Click to collapse
very strange error.
vlrgamaley said:
very strange error.
Click to expand...
Click to collapse
Could you explain??
Heeth21 said:
Could you explain??
Click to expand...
Click to collapse
you can see it on attach picture. that command isn`t work and i haven`t backup file of "cache" in adb folder...
vlrgamaley said:
you can see it on attach picture. that command isn`t work and i haven`t backup file of "cache" in adb folder...
Click to expand...
Click to collapse
Sorry, I missed the screenshot. What version of TWRP are you using?? Please use official TWRP, as mentioned in OP. I am using official TWRP and it works fine for me.
Here is the link to Official TWRP: https://dl.twrp.me/athene/
Download the latest version (3.2.1.0) and save the twrp in your adb folder, reboot to bootloader mode and then flash it. Command:
Code:
fastboot flash recovery twrp-3.2.1-0-athene.img
.
Then reboot into recovery from fastboot itself by using volume keys and selecting recovery option
Here is a screenshot when I use adb pull:
Heeth21 said:
Sorry, I missed the screenshot. What version of TWRP are you using?? Please use official TWRP, as mentioned in OP. I am using official TWRP and it works fine for me.
Here is the link to Official TWRP: https://dl.twrp.me/athene/
Download the latest version (3.2.1.0) and save the twrp in your adb folder, reboot to bootloader mode and then flash it. Command:
.
Then reboot into recovery from fastboot itself by using volume keys and selecting recovery option
Here is a screenshot when I use adb pull:
Click to expand...
Click to collapse
i have official twrp 3.2.1 right now and boot into recovery from fastboot through volume keys)
but command in prompt isn't work) wtf?)
vlrgamaley said:
i have official twrp 3.2.1 right now and boot into recovery from fastboot through volume keys)
but command in prompt isn't work) wtf?)
Click to expand...
Click to collapse
Did you wipe cache?? Try the commands for system and userdata and check if they work.
And please attach a screenshot
Heeth21 said:
Did you wipe cache?? Try the commands for system and userdata and check if they work.
And please attach a screenshot
Click to expand...
Click to collapse
ok, now is night in Siberia, and i go to sleep. tomorrow (+12 hrs) i try and write here about results)
vlrgamaley said:
ok, now is night in Siberia, and i go to sleep. tomorrow (+12 hrs) i try and write here about results)
Click to expand...
Click to collapse
If you are okay with a twrp backup, then just backup data, system and cache from twrp and store them.

[SOLVED] Help to mount userdata in linux or repair userdata.img

After an Update of Two magisk modules, my Ulefone Armor 11 5G staied stucked on boot logo, I can only enter in recovery or fastboot.
I try to build a TWRP, but it is not able to mount userdata.
I was able to download with the help of mtkclient all the partition on my phone, even userdata , it took 7 hours.
I wanted to load the image in linux but using mount disk imag or using the command sudo mount -o loop userdata.img ~/Armor_11_5G doesn't do anything not even an error message.
I'm wondering if the filesystem was corrupted during the update.
Is it possible to repair the fylesystem like in Windows?
Thanks
did you previously disable encryption and factory reset long time before the modules updates failed?
what do you mean mount doesn't do anything not even an error message? either it give error message or it succeed.
I didn't disable encryption before updating the modules, I already updated this modules many times.
what do you mean mount doesn't do anything not even an error message? either it give error message or it succeed.
Click to expand...
Click to collapse
That is the problem, it doesn't succed and I don't have an error message. The file is 256 Gbyte big, I don't know if it plays a role. I'm using Ubuntu 22
if phone is encrypted that's just 256G garbage. post the output of
Code:
$ parted <file> unit B print
Here are the results of parted
Code:
Error: /home/*****/Public/userdata.bin.img: unrecognised disk label
Model: (file)
Disk /home/osboxes/Public/userdata.bin.img: 249208733696B
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
Thanks
You may try https://www.cgsecurity.org/wiki/TestDisk_Download
I'd be glad for your feedback.
sorry thought it's whole disk, but it's only 232G file therefore parted won't print partition table
does apply to FDE only
assuming this file is dump of single userdata partition, open with HxD editor. if the partition image is not encrypted, you will see lot zeros within first 1024 bytes.
in that case you can check for file system type is ext4 or f2fs.
Code:
$ xxd -l 1080 dump.img | grep 53ef
$ xxd -l 1024 dump.img | grep 1020.f5f2
But most likely the userdata partition is encrypted, therefore no way to recover data offline.
The easiest way not to load Magisk modules is, not to load Magisk. Flashing stock boot.img will solve it.
Beware, in case you disabled encryption beforehand, booting stock boot.img will force encryption. This may take long time without notice.
I never disabled encryption, I don't know if Magisk do it without informing. I used this phone for an year without a problem.
After the update I left the phone on for one night but nothing happens. I tried to reflash the stock boot image, and again a whole night wait, but again nothing happens.
Reading the fstab the file system should be ext4.
The file is the dump of the whole userdata partition of my Ulefone Armor 11 5G.
I did a backup of the whole system before doing any experiment so if the partition table is corrupted maybe if I reflash back the userdata partition with a working partition table I have again access to the datas.
there is no partition table in userdata partition, I just gave you wrong advise. because the phones total storage is 256G, I made wrong assumptions (you can view partition table from file pgpt.bin)
full 1:1 backup is impossible for FBE encryption because encryption keys are stored in TEE. once you factory reset device backup of userdata + metadata becomes useless.
fstab doesn't tell you what file you just have dumped. if you can't find ext4 super magic (#7) it's impossible to loop mount that file (and impossible to decrypt on linux PC)
if you can't fix boot-loop by stock boot.img then it's unrelated to magisk modules. you can however enable adb in default.prop and capture adb logcat during boot-loop for further analysis. you could also inject own script that deletes some files (only DE encrypted files, CE encrypted files requires lock screen credentials aka pin/pattern)
boot this TWRP and get log from adb
Code:
$ fastboot boot recovery.img
$ adb shell twrp decrypt '1234'
$ adb pull /tmp/recovery.log
https://twrp.me/faq/openrecoveryscript.html
full 1:1 backup is impossible for FBE encryption because encryption keys are stored in TEE. once you factory reset device backup of userdata + metadata becomes useless.
Click to expand...
Click to collapse
With mtk client I was able to do the backup of tee1 and tee2 and also of gpt_backup and gpt_main.
$ xxd -l 1080 dump.img | grep 53ef
$ xxd -l 1024 dump.img | grep 1020.f5f2
Click to expand...
Click to collapse
Doesn't produce any results.
I have immediately the command prompt.
you can however enable adb in default.prop
Click to expand...
Click to collapse
How can I do that? Which value should I change in default.prop?
so your "backup" is encrypted. please note Trustonic Kinibi is TEE OS running in secure memory one can't access or backup with mtkclient. the tee partitions in phone storage do not contain any encryption key (none of the partitions does, secure memory is not even a partition). the only crypto related partition is metadata used for keydirectory of metadata encryption (on top of FBE encryption) but it is useless for backup purposes.
yes you can modify default.prop in boot.img, ro.secure=0 should give root access.
https://forum.xda-developers.com/t/...hone-with-broken-screen.2965462/post-85905033
Code:
ro.secure=0
ro.debuggable=1
persist.service.adb.enable=1
in case the default.prop modification is not sufficient, you need additional command to be executed as root.
Code:
# settings put global adb_enabled 1
as you installed magisk, you could use magisk overlay.d/sbin/ for running startup script.
https://forum.xda-developers.com/t/...ithout-losing-your-data.4383255/post-86934375
aIecxs said:
boot this TWRP and get log from adb
Code:
$ fastboot boot recovery.img
$ adb shell twrp decrypt '1234'
$ adb pull /tmp/recovery.log
https://twrp.me/faq/openrecoveryscript.html
Click to expand...
Click to collapse
How about this TWRP? it should be able to decrypt userdata. if decryption failed, provide recovery.log
Until tomorrow I cannot do a logcat and I cannot find my view logcat on my laptop.
I unpacked boot.img with Carliv Image Kitchen and there is no default.prop, that is present in the recovery as prop.default.
Is there a way to backup secure memory of Trustonic?
How about this TWRP? it should be able to decrypt userdata. if decryption failed, provide recovery.log
Click to expand...
Click to collapse
I already tried that version but it cannot decrypt, that' why I'm trying to build my own version of TWRp with the help of the creator of that version of TWRP, but I'm stucked.
oh, you know how to build TWRP with proper FBE + metadata encryption support? have a look at other Oppo devices how they did... good luck.
regarding default.prop in boot.img (it's a symlink to system unfortunately) you can do it the other way
use magisk overlay.d/sbin/
create a boot script that does the thing with resetprop -n <prop_name> <prop_value>
don't use outdated Carliv Image Kitchen! use osm0sis AIK from link above.
oh, you know how to build TWRP with proper FBE + metadata encryption support? have a look at other Oppo devices how they did... good luck.
Click to expand...
Click to collapse
I'm learning.
I try to integrate the decryption service following the suggestion of ADeadTrouser on Github, but the service doesn't want to start and I don't understand why.
I never checked Oppo, I will take a look at them also, thanks for the suggestion.
I think I figured out now the adb logcat at least. hope that helps
https://forum.xda-developers.com/t/accessing-my-phone-with-a-dead-screen.4542763/post-88016019
I tried your script butr nothing happens, the telephone is not listed when I type
Code:
adb devices
and if I type
Code:
adb logcat
I receive the message waiting for device
you might follow the thread
wenyendev said:
You may try https://www.cgsecurity.org/wiki/TestDisk_Download
I'd be glad for your feedback.
Click to expand...
Click to collapse
I run the software on the image and it identify the contents and can read the encrypted and not encrypted part, that means that all the files are there, but I cannot mount in Linux or in TWRP
The fact that I cannot mount in Linux or TWRP the userdata image/partition can be that is corrupted the partition or the file index?
That would also explain why the script for Magisk provided by aIecxs is not able to copy the adb_key from the cache in the data partition.

Categories

Resources