Investigation: Recovering EFS after TWRP restore - ZTE Axon 7 Guides, News, & Discussion

WARNING: Do NOT use TWRP to restore EFS!
Several people have used TWRP to do a backup and restore of EFS, and rendered their phone's mobile settings invalid. This is typically indicated by cellular data not working and/or invalid IMEI.
This thread will attempt to find out how to restore these devices to a functional state. We will need help from the community to make this successful! Please read through the thread and try to help with any requests.
WARNING: Do NOT use TWRP to restore EFS!
To backup your EFS data for safe keeping or sending to someone, do the following:
1. Boot into TWRP (any version).
2. Backup:
Code:
adb shell dd if=/dev/block/bootdevice/by-name/modemst1 of=/tmp/modemst1.img
adb shell dd if=/dev/block/bootdevice/by-name/modemst2 of=/tmp/modemst2.img
3. Pull the files:
Code:
adb pull /tmp/modemst1.img
adb pull /tmp/modemst2.img
Now you should have the backup files on your PC. They should each be exactly 2097152 bytes long. DO NOT share these files with anyone that you don't trust.

Okay so the first thing to note is that the signed TWRP provided by tenfar has an error in the EFS backup procedure. From the backup log:
Code:
Backing up EFS...
I:Reading '/dev/block/sdf1', writing '/data/media/0/TWRP/BACKUPS/.../efs1.emmc.win'
Backing up efs2...
I:Reading '/dev/block/sdf2', writing '/data/media/0/TWRP/BACKUPS/.../efs1.emmc.win'
Note that it read sdf1 (aka modemst1), placing the backup into efs1.emmc.win. Then it read sdf2 (aka modemst2), also placing the backup into efs1.emmc.win. In other words, sdf1 data was overwritten and lost.
I am looking into what is in each of these partitions and how to best recover.

The twrp in question is different from the 'unofficial' twrp, correct?
I have this one installed on my phone
12/03/2016 15:12 17,932,169 twrp-recovery-3.0.2-2.zip
​I believe this is the unofficial one?

gpz1100 said:
The twrp in question is different from the 'unofficial' twrp, correct?
I have this one installed on my phone
12/03/2016 15:12 17,932,169 twrp-recovery-3.0.2-2.zip
​I believe this is the unofficial one?
Click to expand...
Click to collapse
I can't say which is which. But regardless of the version you are using, the safest option is to never backup and restore EFS using TWRP.

Agreed. There's really no reason one should be messing/touching the EFS partition in the first place. I'm not sure why it was included. The only partitions needed for a successful backup include those below.
Boot
System
Data

Alright, so the first thing I think we'll need is two known working backups of the EFS data for each model. I have a U model so if I can get a backup from someone else's U model, I can compare. This will provide some insight on where the IMEI is stored.

Just a thought here, back when I had my original Galaxy S we had an issue with the EFS partition getting destroyed all the time. We almost always get a clean backup as a "just in case". However if you ever did a factory restore, meaning using Odin on that phone your EFS would always be restored. Is there any factory restore images for this phone that work in the same fashion?

Velrix said:
Just a thought here, back when I had my original Galaxy S we had an issue with the EFS partition getting destroyed all the time. We almost always get a clean backup as a "just in case". However if you ever did a factory restore, meaning using Odin on that phone your EFS would always be restored. Is there any factory restore images for this phone that work in the same fashion?
Click to expand...
Click to collapse
Nope, not that I am aware of anyway. But I could possibly make one. It's a good idea. But first I want to see about helping people that have corrupted EFS.

tennear said:
Nope, not that I am aware of anyway. But I could possibly make one. It's a good idea. But first I want to see about helping people that have corrupted EFS.
Click to expand...
Click to collapse
Ya, the issue you will face here is TWRP overwriting the original backup image with the second blob. The only fix is going to be finding the location of the IMEI inside that initial file and doing a manual change possibly without it being something the backup files would replace naturally. The problem here is the legality, while you are replacing the IMEI with the one original to the phone something like this being published would/could be used maliciously as well.
Has any of the users affected by this tried to roll back to a completely stock phone, removing TWRP?

Velrix said:
Ya, the issue you will face here is TWRP overwriting the original backup image with the second blob. The only fix is going to be finding the location of the IMEI inside that initial file and doing a manual change possibly without it being something the backup files would replace naturally. The problem here is the legality, while you are replacing the IMEI with the one original to the phone something like this being published would/could be used maliciously as well.
Has any of the users affected by this tried to roll back to a completely stock phone, removing TWRP?
Click to expand...
Click to collapse
I am sadly affected by this mishap on an otherwise brilliant phone.
I have not tried this. I have re-flashed completely to stock, but didn't relock my BL and/or remove TWRP. I do not know a lot about these matters, but tbh I don't see why that would help us, flashing the stock recovery back would only change the recovery partition, amirite?
Here's a thankful plea from an affected user. Please share a valid EFS partition backup with @tennear, @Tebor, @jcadduono or myself. We are NOT going to mess around with your IMEI or other data, we just want to try to help out ourselves and provide a future reference for people who happen to be in the same situation. THANK YOU. ETERNAL RESPECT.

This is weird. I never run across this issue?
Are maybe only A2017G affected?
I'm still on Tenfar's TWRP and due to habits I always creat a full backup. Meaning I included the EFS partitions.
While working on my own Axon-7 CM bring-up I have probably flashed my CM (while working on my bring-up) and restored those affected partitions like 20x times and never experienced above problems.
I'm on B29 stock. I just went into about phone to see if my IMEI's are listed. Everything is fine.

I extracted my efs partitions to the sd card. Appears there are 5 blocks that make up the sdf block devices.
Code:
[email protected]_ii:/sdcard # dd if=/dev/block/sdf1 of=/sdcard/efs1.img bs=4096
dd if=/dev/block/sdf1 of=/sdcard/efs1.img bs=4096
512+0 records in
512+0 records out
2097152 bytes transferred in 0.015 secs (139810133 bytes/sec)
[email protected]_ii:/sdcard # dd if=/dev/block/sdf2 of=/sdcard/efs2.img bs=4096
dd if=/dev/block/sdf2 of=/sdcard/efs2.img bs=4096
512+0 records in
512+0 records out
2097152 bytes transferred in 0.007 secs (299593142 bytes/sec)
[email protected]_ii:/sdcard # dd if=/dev/block/sdf3 of=/sdcard/efs3.img bs=4096
dd if=/dev/block/sdf3 of=/sdcard/efs3.img bs=4096
1+0 records in
1+0 records out
4096 bytes transferred in 0.008 secs (512000 bytes/sec)
[email protected]_ii:/sdcard # dd if=/dev/block/sdf4 of=/sdcard/efs4.img bs=4096
dd if=/dev/block/sdf4 of=/sdcard/efs4.img bs=4096
128+0 records in
128+0 records out
524288 bytes transferred in 0.008 secs (65536000 bytes/sec)
[email protected]_ii:/sdcard # dd if=/dev/block/sdf of=/sdcard/efs.img bs=4096
dd if=/dev/block/sdf of=/sdcard/efs.img bs=4096
10240+0 records in
10240+0 records out
41943040 bytes transferred in 0.212 secs (197844528 bytes/sec)
Appears efs3 and efs4 are blank inside (just 00's). Efs, efs1, efs2 do contain data. Search all of them using a hex editor for either of the two imei's resulted in nothing. From past flashing, I know these are sometimes stored in a backward manner. Tried searching for that too with no luck. My guess is if the imei is stored in one of these files, it's in an encrypted manner.
Hash checksums for my files are below:
Code:
File: efs4.img
CRC-32: 95d0e631
MD4: 06be904db85f2f54e2cfe3ed65c11311
MD5: 06f49b34524d523cbd925c2fa6fa27bf
SHA-1: 7da5cedafe502f32a68ee9fb7a98433e71c2cf13
File: efs3.img
CRC-32: 9adc2b3a
MD4: 4075c3bfd61127e287dbb5c92a7e04fb
MD5: 778800e21d5e0d70ae337c730b2d5e18
SHA-1: 1ac72bb3eadcfa8af694ace9ebe096f97524424b
File: efs2.img
CRC-32: eecb36a2
MD4: 7d2f020ce6e3f1fcc8f2510fc60b5956
MD5: a009e1cf60afdb6e03b3cb65a5695e95
SHA-1: 76f9d21c1ef95983ff68c1ea8c771909b743fd7e
File: efs1.img
CRC-32: 518ab8df
MD4: e26a4c53061102537a868826e56e22e2
MD5: 913ac8e53227eb6eadbaf0054c2e9092
SHA-1: e9be6f2cd08e7a0fe2a7326920a920aefd064cb8
File: efs.img
CRC-32: 7603f894
MD4: 105bbc7d6d3d082c38d7bc25a7a3c02e
MD5: 3b89d12ee514bbaa4dae27fd180237c3
SHA-1: d8d260b860781c5da48f70c98c42c2c49d8f94f6

Controllerboy said:
I am sadly affected by this mishap on an otherwise brilliant phone.
I have not tried this. I have re-flashed completely to stock, but didn't relock my BL and/or remove TWRP. I do not know a lot about these matters, but tbh I don't see why that would help us, flashing the stock recovery back would only change the recovery partition, amirite?
Here's a thankful plea from an affected user. Please share a valid EFS partition backup with @tennear, @Tebor, @jcadduono or myself. We are NOT going to mess around with your IMEI or other data, we just want to try to help out ourselves and provide a future reference for people who happen to be in the same situation. THANK YOU. ETERNAL RESPECT.
Click to expand...
Click to collapse
I really hope I you didn't think I was implying anyone here needing this fix would be acting maliciously. I am just saying people could use it as so.
To answer your question, flashing recovery wouldn't fix that exactly, I mean getting a completely stock full image of the nand and re-flashing it.

gpz1100 said:
I extracted my efs partitions to the sd card. Appears there are 5 blocks that make up the sdf block devices.
Click to expand...
Click to collapse
Well, /dev/block/sdf is a device and sdf1, sdf2 etc. are partitions of that device.
If you backup the device itself, you backup all partitions within that device.
I don't know what sdf3 & sdf4 are but it appears that they are not important (as you have already stated).
There should be no need to backup the whole device but it doesn't hurt.

celoxocis said:
This is weird. I never run across this issue?
Are maybe only A2017G affected?
I'm still on Tenfar's TWRP and due to habits I always creat a full backup. Meaning I included the EFS partitions.
While working on my own Axon-7 CM bring-up I have probably flashed my CM (while working on my bring-up) and restored those affected partitions like 20x times and never experienced above problems.
I'm on B29 stock. I just went into about phone to see if my IMEI's are listed. Everything is fine.
Click to expand...
Click to collapse
No, the issue is definitely present. You can examine your recovery.log in your backup directory to see for yourself. You should have a file named efs1.emmc.win that is 2mb and the text that I showed in the recovery.log file.
If you have restored your EFS data and you still have functional data and IMEI, consider yourself lucky. I honestly don't know how that would be possible.

Someone in this forum said that turning off the phone, switch the SIM to the other SIM-slot, turn on and then do it otherwise again might help...
But I am not affected, so I cannot test this.

tennear said:
No, the issue is definitely present. You can examine your recovery.log in your backup directory to see for yourself. You should have a file named efs1.emmc.win that is 2mb and the text that I showed in the recovery.log file.
If you have restored your EFS data and you still have functional data and IMEI, consider yourself lucky. I honestly don't know how that would be possible.
Click to expand...
Click to collapse
I've just double checked in the log.
I must have at some point in time been lucky to have switched to UDev's TWRP after having unlocked the bootloader.
As it reads:
Code:
ro.build.host=overrated
ro.build.tags=test-keys
ro.build.type=eng
ro.build.user=unjust
I doubt Tenfar's would have those flags.
I remember the subpartion restore being a bug that was fixed by TWRP. So Tenfar's build probably never included that fix. That warning should be posted in the thread he created too.

@gpz1100 the /dev/sdf "disk" contains 5 partitions:
sdf1 = modemst1 -> EFS data
sdf2 = modemst2 -> EFS data
sdf3 = fsc -> Unused?
sdf4 = ztecfg -> ZTE specific config stuff for stock ROM, unused in CM.
sdf5 = persist -> ext4 filesystem mounted as /persist, some device specific configs etc.

Update: I have one good backup of the EFS partitions from a G user. I'd like to get another to compare.

Velrix said:
Has any of the users affected by this tried to roll back to a completely stock phone, removing TWRP?
Click to expand...
Click to collapse
I have tried:
restoring stock recovery
flashing stock B02, B03, B05, B06 and B08
Flashing the small incremental updates
Flashing DrakenFX's twrp updates and bootstacks
I have swapped recoveries so many times, I can use tennear's tool with my eyes closed
Hell I've even tried flashing the U version firmware. (Nice boot animation by the way. Heaps better than the G version with the pictures :good
None of the factory firmware made any difference. Im guessing that none of the factory firmware makes changes to EFS related items
@tennear, have you had a chance to look into how this little program works --> http://en.miui.com/thread-271552-1-1.html
I can restore my imei numbers with it but it still wont connect to cellular. Funny thing is, when I restore my own numbers, enter my sim pin after rebooting, my carrier logo appears with full signal minus the 4G icon but I cannot make calls. It then proceeds cycle between my carrier and emergency calls only.
All this flashing and wiping has kind of shown me how good the Axon 7 is. I haven't had a single error nor bootlooped. It just takes everything and always boots up.

Related

[Q] How to Backup and Restore Original Shipped Firmware? For warranty.

Is there a way to Backup and Restore Original Shipped Firmware? Is we have Norton Ghost for Android then it will be good...
The purpose is to claim the phone for warranty, after flashed with customized firmware. The phone's hardware might go fault.
Well as a previous sgs user I know that the best way is to have root on ur device then u can access cwm to create a complete image (backup) of ur current os.
I don't know if there is a better way of doing so
Cheers
Sent from my GT-I9100 using Tapatalk
A lot of branded roms are posted in the Branded rom post in dev section .
jje
For an own backup, exactely as you bought the phone, here's what I did:
- flash an insecure kernel (stock kernels are available for all FWs, so restoring original stock kernel is easy)
- apply root
- dump all important partitions:
Code:
dd if=/dev/block/mmcblk0p1 of=/sdcard/p1-EFS.img bs=4096
dd if=/dev/block/mmcblk0p4 of=/sdcard/p4-PARAM.img bs=4096
dd if=/dev/block/mmcblk0p5 of=/sdcard/p5-KERNEL.img bs=4096
dd if=/dev/block/mmcblk0p8 of=/sdcard/p8-MODEM.img bs=4096
dd if=/dev/block/mmcblk0p9 of=/sdcard/p9-FACTORYFS.img bs=4096
dd if=/dev/block/mmcblk0p12 of=/sdcard/p12-HIDDEN.img bs=4096
As a more easy/convinient alternative you could flash a kernel with a custom recovery (like CF-Root, containing CWM recovery) and use the Nandroid backup feature from the recovery menu - but those root-kernels usually perform a few more changes on the /system partition, so I did my "initial stock backup" just using an insecure kernel and root applied.
HellcatDroid said:
For an own backup, exactely as you bought the phone, here's what I did:
- flash an insecure kernel (stock kernels are available for all FWs, so restoring original stock kernel is easy)
- apply root
- dump all important partitions:
Code:
dd if=/dev/block/mmcblk0p1 of=/sdcard/p1-EFS.img bs=4096
dd if=/dev/block/mmcblk0p4 of=/sdcard/p4-PARAM.img bs=4096
dd if=/dev/block/mmcblk0p5 of=/sdcard/p5-KERNEL.img bs=4096
dd if=/dev/block/mmcblk0p8 of=/sdcard/p8-MODEM.img bs=4096
dd if=/dev/block/mmcblk0p9 of=/sdcard/p9-FACTORYFS.img bs=4096
dd if=/dev/block/mmcblk0p12 of=/sdcard/p12-HIDDEN.img bs=4096
As a more easy/convinient alternative you could flash a kernel with a custom recovery (like CF-Root, containing CWM recovery) and use the Nandroid backup feature from the recovery menu - but those root-kernels usually perform a few more changes on the /system partition, so I did my "initial stock backup" just using an insecure kernel and root applied.
Click to expand...
Click to collapse
Thanks for the advice! I have a question regarding Nandroid and CWM. Restoring the image made with Nandroid is easy enough, but won't the carrier/Samsung detect that a custom recovery (CWM) has been installed and consider it voiding the warranty regardless of the stock ROM being on the device?
Thanks in advance.
techjunkieza said:
Restoring the image made with Nandroid is easy enough, but won't the carrier/Samsung detect that a custom recovery (CWM) has been installed and consider it voiding the warranty regardless of the stock ROM being on the device?
Click to expand...
Click to collapse
After restoring a stock backup via a custom recovery/nandroid, just flash a stock kernel afterwards with Odin as well.
That will restore kernel and the recovery back to stock too.
All that is then left from a rooting is two files and a few symlinks hidden in /system/xbin - unlikely they'll go and check that IMO.
HellcatDroid said:
After restoring a stock backup via a custom recovery/nandroid, just flash a stock kernel afterwards with Odin as well.
That will restore kernel and the recovery back to stock too.
All that is then left from a rooting is two files and a few symlinks hidden in /system/xbin - unlikely they'll go and check that IMO.
Click to expand...
Click to collapse
Thanks dude. I was wondering how it is done. I did not know that flashing a stock kernel will make the recovery mode default as well. I'm new to Android so please forgive the noob questions. Surely there should be a list of files in a thread somewhere which indicates which files are modified when rooting the phone?
So I take it by restoring the original ROM, flashing a stock kernel (if you have a custom recovery mode or root access), removing the files and symlinks and resetting the ROM counter that the phone will be "stock" again?
techjunkieza said:
Thanks dude. I was wondering how it is done. I did not know that flashing a stock kernel will make the recovery mode default as well. I'm new to Android so please forgive the noob questions.
Click to expand...
Click to collapse
He, I had to learn all this myself recently, the SGS2 is my first Android device as well
For the SGS2 the recovery mode is part of the main kernel (partition), so flashing a stock kernel replaces that as well.
AFAIK this a unique Samy thing, on the other Android devices the recovery actually resides on its own partition.
techjunkieza said:
Surely there should be a list of files in a thread somewhere which indicates which files are modified when rooting the phone?
So I take it by restoring the original ROM, flashing a stock kernel (if you have a custom recovery mode or root access), removing the files and symlinks and resetting the ROM counter that the phone will be "stock" again?
Click to expand...
Click to collapse
Depending on how you rooted it's just /system/xbin/su that gets replaced and /system/xbin/busybox that gets added.
Then all the symlinks busybox installs - not sure if busybox has an "uninstall" option to remove them, if not just dump all symlinks in /system/xbin, on stock FWs there are none in this dir.
HellcatDroid said:
He, I had to learn all this myself recently, the SGS2 is my first Android device as well
For the SGS2 the recovery mode is part of the main kernel (partition), so flashing a stock kernel replaces that as well.
AFAIK this a unique Samy thing, on the other Android devices the recovery actually resides on its own partition.
Click to expand...
Click to collapse
Thanks a lot for the advice. I see many people asking the same questions but no one really gives them answers. I'm guessing it's betterfor it to be on two different partitions in terms of coupling. For noobs, the Samsung way is easier.
HellcatDroid said:
Depending on how you rooted it's just /system/xbin/su that gets replaced and /system/xbin/busybox that gets added.
Then all the symlinks busybox installs - not sure if busybox has an "uninstall" option to remove them, if not just dump all symlinks in /system/xbin, on stock FWs there are none in this dir.
Click to expand...
Click to collapse
Great. Thanks. I would like to know what Android does on a low level in order to gain root access. I'm going to research that a bit.
Thanks very much for the info!
techjunkieza said:
I would like to know what Android does on a low level in order to gain root access. I'm going to research that a bit.
Click to expand...
Click to collapse
Well, once one knows what happens it's not that much magic that happens.
Basically, the stock su gets replaced with a custom one that actually has a way of allowing other user (IDs) to run as root, Superuser.apk is installed to maintain su's database of allowed (and disallowed) user IDs and last not least busybox is installed to gain some shell commands not available (or limited) on stock.
All that is done via an adb daemon (already) running with root perms - that's what the insecure kernels do, they simply let the adbd run with root perms (so the above things can be done).
Each app running has it's unique, own user ID it's running with, so root access/permissions can easiely be maintained that way.
I hope that was what you wanted to know
HellcatDroid said:
Well, once one knows what happens it's not that much magic that happens.
Basically, the stock su gets replaced with a custom one that actually has a way of allowing other user (IDs) to run as root, Superuser.apk is installed to maintain su's database of allowed (and disallowed) user IDs and last not least busybox is installed to gain some shell commands not available (or limited) on stock.
All that is done via an adb daemon (already) running with root perms - that's what the insecure kernels do, they simply let the adbd run with root perms (so the above things can be done).
Each app running has it's unique, own user ID it's running with, so root access/permissions can easiely be maintained that way.
I hope that was what you wanted to know
Click to expand...
Click to collapse
Basically, yes! You definitely deserve a thanks for all of this. I was looking for information of what you just described but couldn't find anything. Shot dude!
how to reset counter without the USB jig ?
You don't.
Best you can do is getting rid of the triangle by flashing a stock kernel, but to reset the counter you really need the USB jig.
Great post! I cannot find a clear answer to these questions as well:
1. What is the location of the so called "boot loader" and how to make a backup? On Intel architecture it's on the first few sectors of the disk block device.
2. What is the location of the "ODIN mode/Download mode" application and how to make a backup? I suspect it may be in some read only memory and there is nothing to backup?
3. What is the location of the partition table? How to backup?
I want to understand the real/core/linux/android way of doing these, not just blindly running arbitrary tools.
Thanks in advance.
HellcatDroid said:
You don't.
Best you can do is getting rid of the triangle by flashing a stock kernel, but to reset the counter you really need the USB jig.
Click to expand...
Click to collapse
You can try this
http://forum.xda-developers.com/showthread.php?t=1494114
I already did it on my SII running ICS 4.0.3, worked great!..., but..., read the thread and cross your fingers...
gingingingin said:
1. What is the location of the so called "boot loader" and how to make a backup? On Intel architecture it's on the first few sectors of the disk block device.
2. What is the location of the "ODIN mode/Download mode" application and how to make a backup? I suspect it may be in some read only memory and there is nothing to backup?
3. What is the location of the partition table? How to backup?
Click to expand...
Click to collapse
1, 2 and 3: they are outside of the normal partitioned space / on hidden partiions (the bootloader partition is visible in ICS though) and you should not touch them.
Backing them up is useless as when the bootloaders are corrupted/broken, you'll have no way to restore them anyways as no bootloader == no boot to run anything, hence no restoring.
One is advised to leave them alone and not touch them - usually you can't access them anyways.
2: "Download Mode" is part of the secondary bootloader (partitions /dev/block/mmcblk0p2 and mmcblk0p3).
Hence the inability to access Download Mode when the bootloaders are broken.
Does it mean that "Download Mode" can be corrupt by overwriting this secondary bootloader? What about the the primary one? Is this a sure way for "hard bricking"? I was always wondering is there a way to completely lock yourself out of SGS2, but could not get a conclusive answer in the forum. Or you can recover from any failure by having any single piece backed up?
What do update packages mean when they contain a bootloader update - is it primary or secondary bootloader, or both?
You didn't say about the location of the partition table, although it's quite often part of the updates to have a PIT file with a new layout?
And last but not least, what is the basic sequence to recover from a partition based raw backup, like the one we're discussing in the thread?
Regards,
Anton

Restore file fails checksum verification...

I recently tried a new ROM and made a Rom Manager recovery restore file prior to changing. Things didn't work out as well as I had hoped and when attempting to restore, it fails at the checking MD5 sum process.
Any way to work around this? I really would like to restore to the previous ROM without starting over.
Anybody? I am not quite sure how the restore file can be created on this phone and then not pass verification?
Any ideas or am I stuck starting over?
sandiegopaneraiguy said:
Anybody? I am not quite sure how the restore file can be created on this phone and then not pass verification?
Any ideas or am I stuck starting over?
Click to expand...
Click to collapse
depending on the type of file format used to backup, the restoring could be done manually but a changed md5sum generally means the files are not the same as the original. this could result in corruption and generally it isnt recommended to restore corrupted files as you run the risk of nothing working.
if you're still wanting to proceeding with attempting to restore files which are different than the original and could be corrupted, off the top of my head, you can probably dd the .img files back and untar the .tar files back.
i would suggest starting over and perhaps copying the backup files over to your desktop instead of only leaving on the sdard. this should help ensure at least one of the copies maintains their integrity.
hope that helps!
You can boot into recovery, and run nandroid via adb shell command line, no md5 checksum file needed. Now if the image is bad, you of course get bad results, but if the checksum is just hosed for some reason, it will work fine.
Put the .win files for the partitions you want to restore in /sdacrd
then issue the command "tar xvpf /sdcard/data.win" or "tar xvpf /sdcard/system.win" from the adb shell while in /data or /system respectively. .win files are what TWRP creates for backups.
I had this happen with TWRP 1.01 or 1.02 once on a good backup that passed the checksum tests when I backed it up.
I was testing the reliability of the TWRP package's nandroid and first one failed.
Once I moved to the newer version, I've not had that issue.

CWM Restore: "/system" error

While trying to restore an old backup of stock 2.3.6 on my Atrix 4g (ATT) from Jokersax CM9, I recieved an error while restoring "/system". This is what showed up:
Rom Manager version 5.0.0.7
August 22, 2012
Checking MD5 sums...
Erasing boot before restore...
Restoring boot image...
Restoring system...
Error while restoring /system!
/tmp/recovery.log was copied to /sdcard/clockworkmod/recovery.log.
Please open ROM Manager to report the issue.
A bit of background...So, I rooted and unlocked the bootloader of my Atrix 4g about two weeks ago, and everything went fine. I then decided to flash Jokersax CM9 on my Atrix, so I backed up the stock 2.3.6 that I was on at that time. I then used CM9 for the next two weeks, but then decided I wanted to go back to stock, and I received the error. Btw, I used ROM Manager for backups and restore, and had flashed CWM recovery properly. Also, the backups I had created of CM9 earlier wouldn't restore because of the missing MD5 file.
I was curious why it wouldn't restore properly. Is it just a bad backup or is something wrong with my internal sd card? Anyway, what should I do if I want to restore the backup?
Thanks in Advance!
Anything interesting or useful in /sdcard/clockworkmod/recovery.log?
No file
ravilov said:
Anything interesting or useful in /sdcard/clockworkmod/recovery.log?
Click to expand...
Click to collapse
Actually if I go into /sdcard/clockworkmod, I can't find the recovery.log file. It might have been moved but I don't recall ever messing with the files.
Md5sum miss match possibly?
Sent from my MB860 using xda premium
Md5sum mismatch
stevendeb25 said:
Md5sum miss match possibly?
Sent from my MB860 using xda premium
Click to expand...
Click to collapse
If it was Md5sum mismatch, how would I fix it?
Actually I didn't rename the backup and it has no spaces, so I don't know what it would be...
According to your log, there is nothing wrong with your backup, or else the "Checking MD5 sums" part would have caught it.
There is also no way of a MD5 sum mismatch, for the same reason.
The only thing I can think of is there's something wrong with copying the backup to the phone (specifically, the /system partition). You can hook the phone to the computer right after you try restoring the backup and run adb shell, then run this:
Code:
cat /cache/recovery/log
cat /cache/recovery/last_log
See if that has something revealing.
Or, maybe the recovery has some problems wiping your /system for some reason. In that case, you can also try this (also within adb shell):
Code:
dd if=/dev/zero of=/dev/block/mmcblk0p12 bs=512 count=1000
That will wipe the beginning of the /system partition, so the recovery will be forced to format it. Use this at your own risk.
Then after that try restoring your backup again.
ravilov said:
According to your log, there is nothing wrong with your backup, or else the "Checking MD5 sums" part would have caught it.
There is also no way of a MD5 sum mismatch, for the same reason.
The only thing I can think of is there's something wrong with copying the backup to the phone (specifically, the /system partition). You can hook the phone to the computer right after you try restoring the backup and run adb shell, then run this:
Code:
cat /cache/recovery/log
cat /cache/recovery/last_log
See if that has something revealing.
Or, maybe the recovery has some problems wiping your /system for some reason. In that case, you can also try this (also within adb shell):
Code:
dd if=/dev/zero of=/dev/block/mmcblk0p12 bs=512 count=1000
That will wipe the beginning of the /system partition, so the recovery will be forced to format it. Use this at your own risk.
Then after that try restoring your backup again.
Click to expand...
Click to collapse
I'll definitely try that, I'm not gonna have a chance to do it soon though. I'll get back to you as soon as I do.
Thanks for all the answers anyway!
Did this work? I have had a similar issue with my Atrix, too. I can do an "Advanced Restore" and restore all partitions but /system.
Issue restoring stock rom backup
I loaded epritner's CM10 rom and am getting the same error when attempting to restore the backup of the stock rom. Reviewing the report.log i see that there is a space issue writing to the \system partition but dont know how to proceed. Any help would be appreciated. Attached is the log output...
Restoring system...
I:Formatting unknown device.
I:Formatting ext3 device.
tune2fs 1.41.11 (14-Mar-2010)
Setting current mount count to 1
e2fsck 1.41.11 (14-Mar-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/block/mmcblk0p12: 11/81920 files (0.0% non-contiguous), 20632/327680 blocks
deleted
nvmm_sorensondec.axf
deleted
Protips.apk
deleted
CarDock.odex
deleted
GoogleServicesFramework.odex
deleted
Glam_alert.ogg
deleted
libopencore_player.so
deleted
tar: write error: No space left on device
defaults.xml
deleted
Error while restoring /system!
result was NULL, message is: assert failed: restore_rom("/sdcard/clockworkmod/backup/Atrix4g", "boot", "system", "data", "cache", "sd-ext")
in2slack said:
I loaded epritner's CM10 rom and am getting the same error when attempting to restore the backup of the stock rom. Reviewing the report.log i see that there is a space issue writing to the \system partition but dont know how to proceed. Any help would be appreciated. Attached is the log output...
Click to expand...
Click to collapse
in2slack, did you try these steps from ravilov? If so, did you get an error?
ravilov said:
According to your log, there is nothing wrong with your backup, or else the "Checking MD5 sums" part would have caught it.
There is also no way of a MD5 sum mismatch, for the same reason.
The only thing I can think of is there's something wrong with copying the backup to the phone (specifically, the /system partition). You can hook the phone to the computer right after you try restoring the backup and run adb shell, then run this:
Code:
cat /cache/recovery/log
cat /cache/recovery/last_log
See if that has something revealing.
Or, maybe the recovery has some problems wiping your /system for some reason. In that case, you can also try this (also within adb shell):
Code:
dd if=/dev/zero of=/dev/block/mmcblk0p12 bs=512 count=1000
That will wipe the beginning of the /system partition, so the recovery will be forced to format it. Use this at your own risk.
Then after that try restoring your backup again.
Click to expand...
Click to collapse
Were you able to find a solution? I'm facing the exact same issue
Same here I installed the AtrICS ROM for a play around after backing up my MIUI ROM. Decided to go back to the MIUI ROM and I get the error when trying to restore. I've got a load of application data that I've lost if I can't get this ROM restored. It seems that the AtrICS ROM, as good as it is, has changed something.
Any thoughts anyone? It seems to be a file system thing? As if the System partion is the wrong type, or not large enough?
I went back from atrICS to epinter by backup today. I had no problems what so ever so it is not an atrICS related issue, my steps were:
1. format /cache
2. format /data
3. format /system
4. format /dalvik-cache
5. recover epinter
have you tried to use format system before recovery? maybe there is some residual file that can't be overwritten...
Thanks for your reply.
I did try formatting System before restoring and still got the same error when restoring.
However, I ignored it and rebooted and I was back at MIUI and able to recover my files
I've the exact same problem.
In the /cache/recovery/last_log, I've found a message:
write error: No space left on device
Click to expand...
Click to collapse
I don't understand why there is no space left on /system... the size of partitions should not change, isn't it?
After checking /system partition size and system backup, I saw that the backup completely fills the partition:
[email protected]:/ # df
Filesystem Size Used Free Blksize
[...]
/system 309M 309M 3K 1024
[...]
Click to expand...
Click to collapse
I faced the same issue
I faced the same issue and would request experienced users to take a look at my log file and advise me
Okay did anyone try anything of this I faces same problem and idk what to do.
Solved - Non conventional method
I solved this problem using a non conventional method.
I used "advanced restore" to restore boot, data and cache.
So, I copied "system.ext3.tar" to my computer and extract it using winrar. Then, using the files I created a flashble zip and flash it using "install zip" option.
It worked!
If someone wants, I could post a tutorial here later.
danilocps87 said:
I solved this problem using a non conventional method.
I used "advanced restore" to restore boot, data and cache.
So, I copied "system.ext3.tar" to my computer and extract it using winrar. Then, using the files I created a flashble zip and flash it using "install zip" option.
It worked!
If someone wants, I could post a tutorial here later.
Click to expand...
Click to collapse
Sorry to ressurect the topic, but I can't restore even /system and /data.. gives me error, and MD5 is fine.
Backing up .android_secure...
.
com.trust5.odp-1.asec
com.quoord.tapatalkxda.activity-1.a
com.loudtalks-1.asec
com.whatsapp.wallpaper-1.asec
com.music.download-1.asec
com.facebook.orca-1.asec
me.pou.app-2.asec
com.kiloo.subwaysurf-2.asec
com.davidamado.MetalGearOuterHeaven
Backing up cache...
.
lost+found
dalvik-cache
recovery
last_log
log
No sd-ext found. Skipping backup of sd-ext.
Generating md5 sum...
chmod: /sdcard/clockworkmod/blobs/02c/§☻‼/♀~|♫: No such file or directory
chmod: /sdcard/clockworkmod/blobs/235/∟/☺>☼>♣~: No such file or directory
Backup complete!
Checking MD5 sums...
boot.img: OK
cache.ext4.dup: OK
data.ext4.dup: OK
system.ext4.dup: OK
.android_secure.vfat.dup: OK
couldn't find default
Found new backup image: /sdcard/clockworkmod/backup/2013-06-30.03.16.22//data.ex
t4.dup
Restoring data...
Creating filesystem with parameters:
Size: 2147483648
Block size: 4096
Blocks per group: 32768
Inodes per group: 8192
Inode size: 256
Journal blocks: 8192
Label:
Blocks: 524288
Block groups: 16
Reserved block group size: 127
Created filesystem with 11/131072 inodes and 17193/524288 blocks
warning: wipe_block_device: Discard failed
Unable to copy file ./backup/processed
data
user
0
idd
etc
bluetooth_bdaddr
wlan_macaddr
light_themes
GNB_DEBUG.txt
backup
processed
Error while restoring /data!
Click to expand...
Click to collapse
Can someone answer that? Thank you!!
I have the same issue
danilocps87 said:
I solved this problem using a non conventional method.
I used "advanced restore" to restore boot, data and cache.
So, I copied "system.ext3.tar" to my computer and extract it using winrar. Then, using the files I created a flashble zip and flash it using "install zip" option.
It worked!
If someone wants, I could post a tutorial here later.
Click to expand...
Click to collapse
Can you please post a tutorial? I am experiencing the same issue.
Edit : I've searched the whole internet and some say that i can't restore the system because my cwm backup of the stock system is to large (315 MB to be precise) while the system partition has 320 MB.It look like i need to have more free space, like 10-15MB .Any ideas on how i might to that?

[GUIDE] Recover phone from a formated /efs partition

I'm just writting this because i've recently had this problem. I managed to sort it out by my own but didn't really find it written anywhere, just bits and pieces scavenged from so many pages that might point to a solution (granted, part of my problem was also finding what was really my problem since the phone stopped working so fast i didn't really had the time to get what happened)
I was trying out swap for my S3, i had created a swap partition in my external card and then followed a guide here from xda to use an app called swapper2 (from market) to enable swap. I must have done something wrong because what it did was format my /efs partition instead as if it was a swap partition. Phone stopped working on the spot, obviously, and wouldn't past samsung's bootscreen.
Also, keep in mind while this worked for me there might be other ways of doing this which may be simpler. This is just what i figured for a solution.
When this helps:
- you accidentally formated your /efs partition
- you have a backup from your /efs partition, files copied with root explorer but not an image you can just flash back to the partition.
- your phone boots to download and to recovery but not to main system (which every tutorial i found seemed to assume to be able to do, i just figured their /efs was not as screwed as mine was)
- your recovery won't mount the /efs partition because it expects it to be ext4 but it's formated to something else and it showing the message:
"e: failed to mount /efs (Invalid argument)"
What doesn't work:
- any kind of standard solution like reflashing a stock rom with odin, with or without .pit file, clear EFS, whatever. It will flash, just won't solve since, apparently, nothing touches the /efs partition because it's so sensible. Even custom recoveries do mount it and apparently format and replace every single other partition but the /efs, which is why i had to do it manually.
Solution:
- simply format the /efs partition back to ext4 and copy your backup files there
What's needed:
- phone drivers installed on the computer. If you had kies installed, this should be covered already. Think you can't have it running while doing this though. Also, for what's worth, i've done this with windows 8 x64.
- updated android sdk tool, mainly adb. If adb is saying device not connected or not found, you may be using an outdated adb.exe (i was). I used adb.exe that came with this software here:
http://forum.xda-developers.com/showthread.php?t=1308546
- root. If your rom isn't rooted you can always flash CF-root from odin in download mode.
http://forum.xda-developers.com/showthread.php?t=1695238
- busybox, am not really sure if i actually got to need this, think so for the formating tool. Can't hurt to have more options though. This is how to install:
http://www.omappedia.com/wiki/Android_Installing_Busybox_Command_Line_Tools
- custom recovery that allows root through adb, i used Philz which is pretty awesome
http://forum.xda-developers.com/showthread.php?t=2002953
- backup files from your /efs. I had mine unzipped and copied to my externalsd while in windows. They were in an efs folder in the sd card. You can push this through adb to the phone later, but i found this way simpler.
How to:
- get into recovery (vol up+home+power button) and plug your phone to the computer. You'll hear an usb connected sound from windows after a bit.
- in recovery, navigate to Mounts and try the "mount /efs". It'll fail. Now, navigate to advanced and "view log". You'll see below that the phone tried to mount a partition and failed, in my case, it had unsucessfully tried to mount /dev/block/mmcblk0p3 which is the partition /efs uses. Take note of this partition name.
- On windows, open a command line (type cmd on you start menu), navigate to where you have adb.exe and type:
adb shell
If all went well, command prompt has changed. You can now issue commands directly to your phone from terminal.
- type "su" to get root permissions. Your command line should change to something like [email protected] Before i had this working i needed to use "Fix permissions". It's an option in the recovery menus on the phone.
- this step is optional but i did it anyway. I created an image of the partition i was going to mess with. If anything went wrong i could always flash it back even if it was broken. By the way, this is what i should have done in the first place instead of just copying /efs files. Would have made the process so much simpler... also, do this if you ever get the phone back working again. Type:
dd if=/dev/block/mmcblk0p3 of=/externalsd/efs.img
The /externalsd/efs.img is just a place you can save stuff to, like your external sd card. You can check what's your mounting point for the card with the command "mount" and look for something relevant like "externalsd".
Also, you may want to copy that efs.img to somewhere else from your phone (like your computer) for safekeeping. Literally remove card from phone, put in computer and copy files there. Notice you may need to reboot phone to recovery if you remove your card so it detects and mounts your card again. Sure, you can also do that from the command line, but it's just easier to reboot the phone.
- Now, we'll format the partition to something your phone can mount (ext4) and is expecting. Be careful, by doing this, you're actually erasing what's left of your partition and replacing by something clean. Type:
mk2fs /dev/block/mmcblk0p3
If all went well, you should see some kind of small report about what was just done.
- To mount this we'll need a mounting point. Type:
mkdir /efs
this will create an /efs folder in root, if it doesn't exist already, and to mount, type:
mount -t ext4 /dev/block/mmcblk0p3 /efs
- if all went well, you now have access to the /efs folder and can copy you files back:
cp -r /externalsd/efs/* /efs
where externalsd was my external sd card mounted on my phone.
- Check if your /efs folder has it's contents properly
ls /efs
I had to reboot the phone to recovery once more at this point and use the "fix permissions" option again.
After this, my phone booted up normally again.
I'm getting Segmentation fault, I guess there's some kinda hardware error on my phone. Gonna take it to Sammy's tomorrow.
Code:
mke2fs -F /dev/block/mmcblk0p11
Segmentation fault
sh-4.2#
Hi thnx for your Guide. I have the EFS problem, after installin 4 diferent rom in 2 hours my imei and baseband lost.( dont now why) i dont have a backup. I was thinking if it take the EFS from another S3 does it work?
Will this work with a Galaxy S4? I545
Enea307 said:
Hi thnx for your Guide. I have the EFS problem, after installin 4 diferent rom in 2 hours my imei and baseband lost.( dont now why) i dont have a backup. I was thinking if it take the EFS from another S3 does it work?
Click to expand...
Click to collapse
No. Read General > Sticky roll-up thread > "IMEI / EFS - Know this stuff"
is normal this output? (i'm meaning the tar.gz unfinding file)
Code:
*****************************************
* BACKUP EFS *
*****************************************
WARNING: Do you wish to Continue? (This will make EFS BACKUP) [Y,N]?Y
--- STARTING ----
--- WAITING FOR DEVICE
--- Backup efs image ---
761 KB/s (9357 bytes in 0.012s)
7 KB/s (39 bytes in 0.005s)
SM-N9000ZWEXXV_N900XXUCMJ3_RF1DA111EAY_
Creating filesystem with parameters:
Size: 20971520
Block size: 4096
Blocks per group: 32768
Inodes per group: 1280
Inode size: 256
Journal blocks: 1024
Label:
FLEX_BG size: 0
Blocks: 5120
Block groups: 1
Reserved block group size: 0
Created filesystem with 59/1280 inodes and 2432/5120 blocks
40960+0 records in
40960+0 records out
20971520 bytes transferred in 7.271 secs (2884269 bytes/sec)
unknown option -- ZBusyBox v1.19.4-cm9 bionic (2012-02-05 18:40 +0100) multi-cal
l binary.
Usage: tar -[cxtzjahmvO] [-X FILE] [-T FILE] [-f TARFILE] [-C DIR] [FILE]...
Create, extract, or list files from a tar file
Operation:
c Create
x Extract
t List
f Name of TARFILE ('-' for stdin/out)
C Change to DIR before operation
v Verbose
z (De)compress using gzip
j (De)compress using bzip2
a (De)compress using lzma
O Extract to stdout
h Follow symlinks
m Don't restore mtime
exclude File to exclude
X File with names to exclude
T File with names to include
2684 KB/s (9962352 bytes in 3.623s)
2805 KB/s (20971520 bytes in 7.299s)
remote object '/sdcard/SM-N9000ZWEXXV_N900XXUCMJ3_RF1DA111EAY_EFS.tar.gz' does n
ot exist
7-Zip (A) 4.65 Copyright (c) 1999-2009 Igor Pavlov 2009-02-03
Scanning
SM-N9000ZWEXXV_N900XXUCMJ3_RF1DA111EAY_EFS.tar.gz: WARNING: Impossibile trovare
il file specificato. [COLOR=Red](impossible to find the specify file)[/COLOR]
Creating archive SM-N9000ZWEXXV_N900XXUCMJ3_RF1DA111EAY_EFS.zip
Compressing getprop.txt
Compressing SM-N9000ZWEXXV_N900XXUCMJ3_RF1DA111EAY_EFS.raw.img
Compressing SM-N9000ZWEXXV_N900XXUCMJ3_RF1DA111EAY_EFS.tar.md5
WARNINGS for files:
SM-N9000ZWEXXV_N900XXUCMJ3_RF1DA111EAY_EFS.tar.gz : Impossibile trovare il file
specificato.[COLOR=Red] (impossible to find the specify file)[/COLOR]
----------------
WARNING: Cannot find 1 file
-
-
Finished. Output file is SM-N9000ZWEXXV_N900XXUCMJ3_RF1DA111EAY_EFS BACKUP
Premere un tasto per continuare . . .
well in the zip there are only the txt + md5 + .raw.img
Thanks for this great tutorial. It was my final step to recover my efs partition, without any backup. I copied the efs folder from another device and modified the files according my devices info (bluetooth mac, serial etc). Worked great on my SGS4
By the way I had the same error:
Code:
mke2fs /dev/block/mmcblk0p10
Segmentation fault
You get this error if you run adb shell when you booted to your ROM.
You need to run adb shell in recovery mode
Great tutorial but i hope you can help me, I can't seem to properly find the SDcard. When I type cp -r /externalsd/efs/* /efs
it comes back with cp: can't stat '/sdcard/efs*' : No such file or directory
I cleared my whole sdcard card except for efs directory. I also tried sdcard instead of externalsd but same thing.
I am getting stuck trying to fix this as I have a boot loop or corrupt /efs or something. I have tried to get my phone working by installing my ROM ( Omega v58 ) and also by trying to flash the latest stock 4.3 through Odin v3.09. I havent tried total stock 4.0.3 yet. No matter what I have done though I can't get past the boot logo ( or the walking Omega droid ). My phone just sits there and hangs
I have followed your steps and I have Philz ( 6.07.9.19 ) installed ( but not busybox unless it is sat there somehow from the Omega install ) but when i try to get adb shell running nothing happens or works..as you can see
What am i doing wrong? OR is my phone totally borked?
hi..
Blackwatch said:
I am getting stuck trying to fix this as I have a boot loop or corrupt /efs or something. I have tried to get my phone working by installing my ROM ( Omega v58 ) and also by trying to flash the latest stock 4.3 through Odin v3.09. I havent tried total stock 4.0.3 yet. No matter what I have done though I can't get past the boot logo ( or the walking Omega droid ). My phone just sits there and hangs
I have followed your steps and I have Philz ( 6.07.9.19 ) installed ( but not busybox unless it is sat there somehow from the Omega install ) but when i try to get adb shell running nothing happens or works..as you can see
What am i doing wrong? OR is my phone totally borked?
Click to expand...
Click to collapse
I have successfully fix my efs partition follwing this thread.
you are receiving such message in cmd. I faced it too.
Sol: Use Philoz Recovery 5.0.
Fix permissions.
there you are.. done..
Philz 6.0 do not have an option for "fix permission".
hope it helps..
I wrote a script that attempts to recover your nv_data.bin from a corrupted EFS partition for the i9300. Thus if you don't have a backup and your EFS is corrupt, try the script. The script is still in Alpha phase and may not work for other devices. Feedback would be much appreciated.
You can find the script at: https://github.com/chriscz/efs_recover
I dont have /efs backed up
Hi ,
If i dont have /efs backed up , can I copy any other mobile (same model) efs data to my mobile and try?
Thanks and Regards
Vamshi Pulumati
vamshipulumati said:
Hi ,
If i dont have /efs backed up , can I copy any other mobile (same model) efs data to my mobile and try?
Thanks and Regards
Vamshi Pulumati
Click to expand...
Click to collapse
No, it won't work and trying to clone another imei is illegal.
boomboomer said:
No, it won't work and trying to clone another imei is illegal.
Click to expand...
Click to collapse
How to register for a new IMEI ? Is it possible?? Could you please help me with any site or link?? I don't want to replace motherboard..
Any help are highly appreciated.
No, it isn't possible and discussion about changing imei is banned on xda.
Take your phone to a service centre and pay then to recode it for you, make sure it works on 4.3 before you pay.
boomboomer said:
No, it isn't possible and discussion about changing imei is banned on xda.
Take your phone to a service centre and pay then to recode it for you, make sure it works on 4.3 before you pay.
Click to expand...
Click to collapse
Hey I would like to tell you that a miracle happened for my S3. Yesterday i tried to do same as per in this guide. After taking backup of broken efs backup i tried to clear the efs folder with this command "mk2fs /dev/block/mmcblk0p3"
After that i just flashed 4.4.4 based stock ROM and somehow phone booted up perfectly. No network issues. Bluetooth wifi sim card everything works. IMEI & Serial No is there. But when i'm checking network unlock status it is showing as everything locked. But still I can use everything... I'm amazed.!!!!
Do you have any idea how this happened??
@boomboomer
Same problem with a Samsung gt-i9070 - Galaxy S Advance
Hi!
My i9070 has the same problem, but when i run the command: "mke2fs /dev/block/mmcblk0p3" shows the "Segmentation fault" error message.
Some one can help?
Thanks.
Bro U stated to format but How to format /efs partition
/efs not backed up
boomboomer said:
No, it won't work and trying to clone another imei is illegal.
Click to expand...
Click to collapse
I Dont have efs backed up and I also have formatted efs partition from adb shell and using that Dev type commands now i am in factory mode and my network is not working please give me any solution.
kaynpayn said:
I'm just writting this because i've recently had this problem. I managed to sort it out by my own but didn't really find it written anywhere, just bits and pieces scavenged from so many pages that might point to a solution (granted, part of my problem was also finding what was really my problem since the phone stopped working so fast i didn't really had the time to get what happened)
I was trying out swap for my S3, i had created a swap partition in my external card and then followed a guide here from xda to use an app called swapper2 (from market) to enable swap. I must have done something wrong because what it did was format my /efs partition instead as if it was a swap partition. Phone stopped working on the spot, obviously, and wouldn't past samsung's bootscreen.
Also, keep in mind while this worked for me there might be other ways of doing this which may be simpler. This is just what i figured for a solution.
When this helps:
- you accidentally formated your /efs partition
- you have a backup from your /efs partition, files copied with root explorer but not an image you can just flash back to the partition.
- your phone boots to download and to recovery but not to main system (which every tutorial i found seemed to assume to be able to do, i just figured their /efs was not as screwed as mine was)
- your recovery won't mount the /efs partition because it expects it to be ext4 but it's formated to something else and it showing the message:
"e: failed to mount /efs (Invalid argument)"
What doesn't work:
- any kind of standard solution like reflashing a stock rom with odin, with or without .pit file, clear EFS, whatever. It will flash, just won't solve since, apparently, nothing touches the /efs partition because it's so sensible. Even custom recoveries do mount it and apparently format and replace every single other partition but the /efs, which is why i had to do it manually.
Solution:
- simply format the /efs partition back to ext4 and copy your backup files there
What's needed:
- phone drivers installed on the computer. If you had kies installed, this should be covered already. Think you can't have it running while doing this though. Also, for what's worth, i've done this with windows 8 x64.
- updated android sdk tool, mainly adb. If adb is saying device not connected or not found, you may be using an outdated adb.exe (i was). I used adb.exe that came with this software here:
http://forum.xda-developers.com/showthread.php?t=1308546
- root. If your rom isn't rooted you can always flash CF-root from odin in download mode.
http://forum.xda-developers.com/showthread.php?t=1695238
- busybox, am not really sure if i actually got to need this, think so for the formating tool. Can't hurt to have more options though. This is how to install:
http://www.omappedia.com/wiki/Android_Installing_Busybox_Command_Line_Tools
- custom recovery that allows root through adb, i used Philz which is pretty awesome
http://forum.xda-developers.com/showthread.php?t=2002953
- backup files from your /efs. I had mine unzipped and copied to my externalsd while in windows. They were in an efs folder in the sd card. You can push this through adb to the phone later, but i found this way simpler.
How to:
- get into recovery (vol up+home+power button) and plug your phone to the computer. You'll hear an usb connected sound from windows after a bit.
- in recovery, navigate to Mounts and try the "mount /efs". It'll fail. Now, navigate to advanced and "view log". You'll see below that the phone tried to mount a partition and failed, in my case, it had unsucessfully tried to mount /dev/block/mmcblk0p3 which is the partition /efs uses. Take note of this partition name.
- On windows, open a command line (type cmd on you start menu), navigate to where you have adb.exe and type:
adb shell
If all went well, command prompt has changed. You can now issue commands directly to your phone from terminal.
- type "su" to get root permissions. Your command line should change to something like [email protected] Before i had this working i needed to use "Fix permissions". It's an option in the recovery menus on the phone.
- this step is optional but i did it anyway. I created an image of the partition i was going to mess with. If anything went wrong i could always flash it back even if it was broken. By the way, this is what i should have done in the first place instead of just copying /efs files. Would have made the process so much simpler... also, do this if you ever get the phone back working again. Type:
dd if=/dev/block/mmcblk0p3 of=/externalsd/efs.img
The /externalsd/efs.img is just a place you can save stuff to, like your external sd card. You can check what's your mounting point for the card with the command "mount" and look for something relevant like "externalsd".
Also, you may want to copy that efs.img to somewhere else from your phone (like your computer) for safekeeping. Literally remove card from phone, put in computer and copy files there. Notice you may need to reboot phone to recovery if you remove your card so it detects and mounts your card again. Sure, you can also do that from the command line, but it's just easier to reboot the phone.
- Now, we'll format the partition to something your phone can mount (ext4) and is expecting. Be careful, by doing this, you're actually erasing what's left of your partition and replacing by something clean. Type:
mk2fs /dev/block/mmcblk0p3
If all went well, you should see some kind of small report about what was just done.
- To mount this we'll need a mounting point. Type:
mkdir /efs
this will create an /efs folder in root, if it doesn't exist already, and to mount, type:
mount -t ext4 /dev/block/mmcblk0p3 /efs
- if all went well, you now have access to the /efs folder and can copy you files back:
cp -r /externalsd/efs/* /efs
where externalsd was my external sd card mounted on my phone.
- Check if your /efs folder has it's contents properly
ls /efs
I had to reboot the phone to recovery once more at this point and use the "fix permissions" option again.
After this, my phone booted up normally again.
Click to expand...
Click to collapse
I have restored my s6 edge by following this method. The EFS partition name is "sda3" for s6 edge if anyone want to restore s6 edge. There is typo in command "mk2fs /dev/block/mmcblk0p3" it should be mke2fs i think.
After restoring EFS my phone recovered from boot loop. But the imei is still invalid. Do you know any method to repair imei for s6 edge?. Thank You
---------- Post added at 02:18 PM ---------- Previous post was at 02:14 PM ----------
Blackwatch said:
I am getting stuck trying to fix this as I have a boot loop or corrupt /efs or something. I have tried to get my phone working by installing my ROM ( Omega v58 ) and also by trying to flash the latest stock 4.3 through Odin v3.09. I havent tried total stock 4.0.3 yet. No matter what I have done though I can't get past the boot logo ( or the walking Omega droid ). My phone just sits there and hangs
I have followed your steps and I have Philz ( 6.07.9.19 ) installed ( but not busybox unless it is sat there somehow from the Omega install ) but when i try to get adb shell running nothing happens or works..as you can see
What am i doing wrong? OR is my phone totally borked?
Click to expand...
Click to collapse
You don't have to run "su" command. "#" shows you already have root access.

[Guide] How to recover IMEI having no backups at all

Hey guys! This thread for such difficult cases when IMEI (CSPSA parittion) is lost and you don't have any backups for this partition.
It's a long story, how exactly I recently turned my phone into a tablet without RIL working but the long story short - both EFS and CSPSA parrtitions were messed up without any obvious ways to recover the latter, since I had no backup.
First of all, I should thank @ace2nutzer since he first found in JB firmware utility, that sets the IMEI to default one (15 zeros). The below is code taken from one of JB codinap firmware:
Code:
#TA Loader to write default IMEI
service ta_load /system/bin/ta_loader recovery
user root
group radio
oneshot
The legality of the use of this I'll leave out the scopes of this topic (and thus this is up to Samsung / ST-Ericcson vendors since this utility was developed by them) - remember that this guide is not about how to change IMEI, but only to recover your original one. Also remember that changing IMEI is illegal in many of countries.
Ok, let's go to the work, but remember, any even more serious damage that you can do to your phone is not my responsibility!
There are some of prerequisites that must be met in order to recover IMEI:
at least JB 4.1.2 or any newer firmware (2.3.6 is not tested) - device must be rooted
your phone is still able to boot the system (the described below is likely not to work in recovery mode)
baseband and signal level are showed in settings, but *#06# combination shows nothing and thus your phone can't be registered in the network
Android terminal emulator installed or adb
stock CSPSA partition from XXLK2 codina / codinap . The below linked this parittion for codina (I'm not sure if codinap users can use it as well, in such case you need to download XXLK2 2.3.6 firmware and extract this partition manually): http://www.xda.mister-freeze.eu/XDA-files/ChronoMonochrome/misc/cspsa/cspsa_stock.img
proper EFS partition (or backup) - I'll leave EFS recovery out of this topic, since I haven't found much variants of recovery of this parittion other than to ask someone to upload their EFS parition. Over the Internet, you can also find some EFS partitions for Ace 2, but I haven't tested them.
ta_loader binary - can be taken from any 4.1.2 (or higher) firmware (see the path above)
Below is how I finally managed to recover IMEI: (attention! everything listed below is only for those who have messed up CSPSA partition. If you're not sure that this is the case for you - don't follow steps written below.)
firstly, backup your CSPSA partition just in case (if you are sure that this is not usable at all and is not useful anymore for anything - you can skip this step):
Code:
dd if=/dev/block/mmcblk0p6 of=/sdcard/cspsa_backup.img bs=512000
flash cspsa partition from XXLK2 stock:
Code:
dd if=/sdcard/cspsa_stock.img of=/dev/block/mmcblk0p6 bs=512000
and reboot the phone
backup /system/bin/ta_loader to some place (e.g. /sdcard or /ramdisk) and replace sequence of 15 zeroes to your original IMEI (can be found back under the battery) using sed:
Code:
sed -ie "s,000000000000000,<15_digits>," /ramdisk/ta_loader
sed -ie "s,<15_digits>0,<16_zeroes>," /ramdisk/ta_loader
I've used sed twice, because there are two occurences of 15 zeroes in ta_loader binary and we want to change only one of them (the rest occurence is not related to IMEI at all),
<15_digits> stands for your IMEI -> second sed command reverts an unwanted change.
Warning! Don't ever try to change IMEI to a non-original this way, it won't work!
now just type
Code:
/ramdisk/ta_loader recovery
, this will reboot your phone to recovery
reboot to system and voila! Original IMEI is there!
If this guide have saved your bacon then please consider donating to @ace2nutzer or me!
Permission denied
When I try to flash the cspsa_stock.img using terminal emulator, it say permission denied.. please help me..
Try
Code:
su
or:
Code:
sudo -i
Confused the 3rd step
You said to replace 15 zeroes to my imei, then you said that <15_digits> stand for my imei, so do i have to change the <15_digits> with my imei? If yes, which one? the first sed or the second? And what should I do for the <16_digits> ? Thanks
Primen2000 said:
When I try to flash the cspsa_stock.img using terminal emulator, it say permission denied.. please help me..
Click to expand...
Click to collapse
Since you're unfamiliar with image flashing, are you sure you're in the right topic? This one is for these unlike cases where CSPSA partition is broken, you might want to check first if this is not the case before you continue.
Primen2000 said:
You said to replace 15 zeroes to my imei, then you said that <15_digits> stand for my imei, so do i have to change the <15_digits> with my imei? If yes, which one? the first sed or the second? And what should I do for the <16_digits> ? Thanks
Click to expand...
Click to collapse
If yes, which one?
Click to expand...
Click to collapse
Both, consider both commands like one.
And what should I do for the <16_digits> ?
Click to expand...
Click to collapse
there is no <16_digits> mentioned in OP, <16_zeros> stands for the sequence of 16 zeroes.
Worked 100%
Oh Man... I've already give up to this old phone because no sim card detected due to IMEI issue for 1 week. And after buy new smartphone last night (Xiaomi Note 4), Now your tutorial worked. I feel sad and happy.. Thanks a lot you guys..
Permission denied
I have entered the following in an adb shell without any error message
cp /system/bin/ta_loader /sdcard
sed -ie "s,000000000000000,my imei," /sdcard/ta_loader
sed -ie "s,my imei+0,0000000000000000," /sdcard/ta_loader
but when I then try
/sdcard/ta_loader recovery
I get a "permission denied". Shell says I am root and the ta_loader's permissions are -rwxrwx---.
Any ideas? (sorry I am not quite familiar with android...)
andi_ypsilon said:
I have entered the following in an adb shell without any error message
cp /system/bin/ta_loader /sdcard
sed -ie "s,000000000000000,my imei," /sdcard/ta_loader
sed -ie "s,my imei+0,0000000000000000," /sdcard/ta_loader
but when I then try
/sdcard/ta_loader recovery
I get a "permission denied". Shell says I am root and the ta_loader's permissions are -rwxrwx---.
Any ideas? (sorry I am not quite familiar with android...)
Click to expand...
Click to collapse
That command just for rebooting to recovery. You can do it yourself.
bien2004official said:
That command just for rebooting to recovery. You can do it yourself.
Click to expand...
Click to collapse
Obviously, it's not just rebooting to recovery but also writes IMEI to a stock CSPSA partition. If CSPSA partition is already recovered (or not broken) then it will just reboot to recovery.
andi_ypsilon said:
but when I then try
/sdcard/ta_loader recovery
I get a "permission denied". Shell says I am root and the ta_loader's permissions are -rwxrwx---.
Any ideas? (sorry I am not quite familiar with android...)
Click to expand...
Click to collapse
Binaries cannot be run from sdcard partition. Copy binary to e.g. /data/local and retry.
ChronoMonochrome said:
Obviously, it's not just rebooting to recovery but also writes IMEI to a stock CSPSA partition. If CSPSA partition is already recovered (or not broken) then it will just reboot to recovery.
Binaries cannot be run from sdcard partition. Copy binary to e.g. /data/local and retry.
Click to expand...
Click to collapse
Thanks ChronoMonochrome, this has worked. Android now shows the correct IMEI.
But SIM card is still not detected even though its working in another phone (and it worked in the ACE2 before installing CustomROM). In "SIM status" all the points are "not available". Can you give me some ideas how to tackle this?
BTW, ta_loader showed some errors (don't know if relevant)
https://imgur.com/a/HsJQU6P
andi_ypsilon said:
Thanks ChronoMonochrome, this has worked. Android now shows the correct IMEI.
But SIM card is still not detected even though its working in another phone (and it worked in the ACE2 before installing CustomROM). In "SIM status" all the points are "not available". Can you give me some ideas how to tackle this?
BTW, ta_loader showed some errors (don't know if relevant)
https://imgur.com/a/HsJQU6P
Click to expand...
Click to collapse
Have you followed all the steps of this guide?
ChronoMonochrome said:
Have you followed all the steps of this guide?
Click to expand...
Click to collapse
What I did using adb:
1) Took cspsa_stock.img from the download link, copied it to sdcard, and typed dd if=/sdcard/cspsa_stock.img of=/dev/block/mmcblk0p6 bs=512000
2) sed -ie "s,000000000000000,123456789....," /local/data/ta_loader
sed -ie "s,1234567890...0,0000000000000000," /local/data/ta_loader
This gave me a modified ta_loader (pulled it to computer and found my IMEI within) and a second file called "ta_loadere". (Don't know why. Same size, contains my IMEI twice)
3) /local/data/ta_loader recovery
4) Select reboot in recovery
andi_ypsilon said:
What I did using adb:
1) Took cspsa_stock.img from the download link, copied it to sdcard, and typed dd if=/sdcard/cspsa_stock.img of=/dev/block/mmcblk0p6 bs=512000
2) sed -ie "s,000000000000000,123456789....," /local/data/ta_loader
sed -ie "s,1234567890...0,0000000000000000," /local/data/ta_loader
This gave me a modified ta_loader (pulled it to computer and found my IMEI within) and a second file called "ta_loadere". (Don't know why. Same size, contains my IMEI twice)
3) /local/data/ta_loader recovery
4) Select reboot in recovery
Click to expand...
Click to collapse
Hmm, then it might depend on what exactly happened to phone. On mine EFS and CSPSA partitions both were broken, but that was not problem (an EFS partition doesn't contains anything irrecoverable, a backup image can be found here). Flashing a full stock image might help as well (I had MF1 4.1.2 stock ROM installed at the moment I broke CSPSA & EFS partitions).
ChronoMonochrome said:
Hmm, then it might depend on what exactly happened to phone. On mine EFS and CSPSA partitions both were broken, but that was not problem (an EFS partition doesn't contains anything irrecoverable, a backup image can be found here). Flashing a full stock image might help as well (I had MF1 4.1.2 stock ROM installed at the moment I broke CSPSA & EFS partitions).
Click to expand...
Click to collapse
SOLUTION: Flashing the phone with Odin 3.2.1.4 and i8160XXNB1_OXXNB4_Android_4.1.2_service.zip from https://service-gsm.net/Samsung/I8160/i8160XXNB1_OXXNB4_Android_4.1.2_service.zip/ restored SIM card detection.

Categories

Resources