Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,777,893 Members 50,788 Now Online
XDA Developers Android and Mobile Development Forum

[HOWTO]Comprehensive IMEI/EFS Backup

Tip us?
 
WildZontar
Old
(Last edited by WildZontar; 3rd September 2012 at 10:51 PM.)
#1  
WildZontar's Avatar
Member - OP
Thanks Meter 176
Posts: 98
Join Date: Jul 2010
Location: Scranton, PA
Default [HOWTO]Comprehensive IMEI/EFS Backup

Update 9/1/2012: A user has successfully restored with this method! Continue to "Testimonials" for more info!
Update 9/2/2012: TrevE has now come up with a way to leverage Samsung's built-in restore to your advantage! Read below for more!
Update 9/3/2012: Changed adb commands to reduce Operation not permitted problems.

Thanks to the efforts of some great developers, there is now *possibly* a more comprehensive method to backup your IMEI. While I have not personally tested a restore using this method, a user in IRC has done a manual NVRAM wipe and restored it using this method, without the roaming issues caused by a occasionally-bungled QPST restore or manual IMEI injection. In addition, posts in this thread indicate a successful restore from an actual occurrence of the problem, all without the use of QPST and also without any roaming issues!

Before I go any further, the same old disclaimer still applies; you accept all responsibility for what you do to your own device!

Theory:
The theory is that the S3 has, in the boot process, a routine which is "tripped" when it detects an error condition. This routine is designed to "save" your IMEI by restoring images from two built-in backup blocks. The problem is, it actually does the opposite; for whatever boneheaded reason, the default backup blocks contain dummy images with an IMEI of 0 and no carrier identification. This is why your phone forgets what carrier it's on and what its IMEI number is; the restore routine actually overwrites the phone's only copy of the IMEI data with a dummy. Because much more data is lost than just the IMEI, this is also why a QPST injection (not a QCN restore) persistently leaves you on roaming.

In an initial attempt to solve this problem, users have attempted to "dd", or create an image of, a single block supposedly containing the IMEI when the phone is still in a good state. This is the efs.sbn method that you may have seen. However, upon further inspection, it turns out the IMEI data is actually spread across five different block devices, hence why the efs.sbn method is either ineffective or leaves you on roaming! After the block devices were identified, a SynergyROM team member created an easy-to-use recovery zip that allows you to image these five blocks, allowing you to reflash them should the Samsung boot process overwrite your IMEI! Re-flashing these blocks after they've been crapped up virtually ensures your phone has been fully restored to its pre-IMEI-loss condition, thereby preventing roaming or data issues seen consistently with a manual injection, or intermittenly with a QPST restore. You do not need SynergyROM to use this tool; I've done it from full stock.

But wait: there's more. About a week after the development of this tool, several unused boot entry points were discovered that revealed a way to control Samsung's built-in "safety" feature and actually make it work properly! Two backup blocks were put in by Samsung themselves; "fsg" and "backup". The great news is that, although these images may contain dummies by default, you can instruct the bootloader to write your good NVRAM data to them so that the good data is what's written to NVRAM in the event of an error. That is, instead of restoring a dummy image over your good IMEI...it restores a good backup instead and you don't lose a thing! How awesome is that?

Developers are now recommending a new IMEI backup regimen, leveraging Samsung's built-in IMEI backup and SynergyROM's manual backup, together with an optional QCN backup you can do for good measure. Of course I can't make any guarantees, but doing this backup should leave you in such a good spot that almost nothing can total your IMEI or leave you in a roaming state. Here are the new instructions on how to backup your IMEI, iron-clad. Do Parts A and B, in order, C is optional but will give you added peace of mind.

Backup:
Part A (Samsung's built-in backup):
1. If your phone does not have Terminal Emulator installed, you will need to use ADB. Download and install the Android SDK platform-tools for your platform. This is a bit non-trivial as it requires the installation of the Android SDK, however, you can find a guide for installing adb here. After installing, open a command prompt and navigate to the "platform-tools" folder within the SDK, where adb is stored. If you need additional help on this, simply ask in this thread.

If your phone is rooted and has Terminal Emulator installed, you don't need to do any of this. Simply open up the Terminal Emulator and go to step 2.

2. For ADB: Connect your phone to the computer and ensure it is in "Debug Mode" (Settings->Developer Options->USB debugging). Then. in the command prompt, type the following:
Code:
adb reboot nvbackup
For Terminal Emulator: The actual "beef" of the command is the "reboot nvbackup" line. Therefore, if you have Terminal Emulator installed, you can just run the command straight off your phone. Enter these two commands from the app:
Code:
su
reboot nvbackup
3. Your phone will reboot and copy the contents of two IMEI partitions to the two built-in backup blocks. You may see tiny blue text on the bootloader screen indicating that it is copying.
4. Allow it to finish and then reboot back into Android. The "fsg" and "backup" block devices now contain your IMEI information as they should have in the first place.

Part B (SynergyROM's "Plan B" manual backup):
1. Download the attachment at the bottom of this post. This is an update ZIP you can run right from recovery.
2. Reboot into recovery. On stock this can be done by turning off the phone and then turning it back on while holding UP and HOME.
3. CWM: Use VOL UP and VOL DOWN together with HOME to select "install zip from sdcard" then "choose zip from sdcard". Navigate to the folder you downloaded it to (most likely Download/). Select the zip you just downloaded to "flash".
TWRP: Touch "install" and navigate to the folder you downloaded the zip to (most likely Download/). Swipe to confirm flash.
4. Allow the backup to complete successfully. "Flash" is a bit of a misnomer; this is actually just a script that will safely backup your EFS and radio information to /sdcard/synergyrom/backup without touching your ROM at this point. When the script completes, reboot.

Part C: Backup with QPST:
Once the gold standard of IMEI backup, this method (in my opinion) should now be done only in the event of an unlikely complete catastrophe where neither Samsung's built-in restore nor SynergyROM's restore works. Simply follow the instructions here for extreme peace of mind; you don't need to do this if you don't want to, but I personally did.

Restore:
Do not do this unless your IMEI has been lost!
Performing Part A of the backup should ensure that you never lose your IMEI in the first place; the theory being that the Samsung built-in backup now has a good image to restore itself, as opposed to a dummy image. However, things may still happen. If you've still lost your IMEI, perform each of these methods in order of priority, "A" being the first.

Restore Plan A:
Run the following command from adb, just like when you backed up (have Android SDK installed, connect phone, and ensure USB debugging is enabled):
Code:
adb reboot nvrestore
This method triggers Samsung's built-in IMEI restore; except this time, you got good images on your side. Simply allow the phone to restore and reboot itself when completed. NEVER PERFORM THIS COMMAND WITHOUT DOING PART A OF "BACKUP" FIRST; THIS WOULD RESTORE THE DUMMY IMAGES INSTEAD AND WIPE YOUR IMEI!

Restore Plan B:
Sometimes a fluke happens and the nvrestore does not work. That's why this one is Plan B and not Plan A. Good thing you did Part B of "Backup"! Rather than instructing Samsung's bootloader to restore your NVRAM, this method will do so manually from recovery using a manually done backup.

It's just like when you backed up, except now you want to flash the zip containing your NVRAM info that the other zip built for you. This zip is located in /sdcard/synergyrom/backup. Simply navigate to this path and flash the zip beginning with "keybackup"; this will write images to 5 block devices from a time when your IMEI was all good. Reboot the phone; if all went well, you now have your IMEI back with no roaming!

Restore Plan C:
Both methods above may fail you in extremely unlikely circumstances. At this point, you'll need to try using QPST to get your IMEI back. If you did Part C in "Backup", you can follow instructions in that same thread to get you back up and running. In most QPST restores, you shouldn't have any issues with data or roaming.

Restore Plan D:
The planets have lined up, the Cubs have won the World Series, and all three above methods have failed you in what is surely a sign of the apocalypse. Far more likely, though, is that you didn't have a backup of anything and your IMEI is gone for good. The good news is that you can still get your phone working; the bad news is that you'll be stuck on roaming and may have problems with data. You'll need to perform an "IMEI injection" which is a kludgy last-resort restore method that manually writes the IMEI to NVRAM; the link I provided in Part C of "Backup" will tell you how to do it.

Testimonials:
This method has been tested good by the following users in this thread!

Quote:
Originally Posted by amaury48 View Post
Just flashed CM10 09-01 nightly and lost data, confirmed I lost my IMEI. I had used the process in the OP a while ago to backup my IMEI. Just would like to confirm that I just flashed the backup it created and happy to report all is well again. Thanks for the post of this tool........saved my butt......
Quote:
Originally Posted by alee View Post
I'll join the club. Lost my IMEI while doing the latest CM10 nightly. Restored and was back in action in no time.
Quote:
Originally Posted by Nght12
Hey, used your backup method and ended up having to use it later in the day. It works. I'd reply but I can't yet due to being a new member here
Please continue to let everyone know if this restore has worked for you after an IMEI loss!

Happy flashing!
The Following 157 Users Say Thank You to WildZontar For This Useful Post: [ Click to Expand ]
 
con247
Old
#2  
con247's Avatar
Retired Recognized Developer
Thanks Meter 3115
Posts: 3,070
Join Date: Sep 2010
Location: Ann Arbor
Quote:
Originally Posted by TrevE View Post
The other trickery we ran into is partitions do not like to be written to for whatever reason outside of package_extract_file right outa the zip. dd'ing directly back failed over and over, I have no clue why, poor esc must have flashed 100 zips before I gave up looking into it. So the updater zip restore uses only package_extract_file, actually writing partitions out properly. I have high hopes that it will actually work, but until tested otherwise do as many types of backups as you can
Your restore dd commands won't work.
Current Phone: iPhone 5[s]
Check out my GS3 Splash Screen Changer
 
WildZontar
Old
#3  
WildZontar's Avatar
Member - OP
Thanks Meter 176
Posts: 98
Join Date: Jul 2010
Location: Scranton, PA
Quote:
Originally Posted by con247 View Post
Your restore dd commands won't work.
Good catch. I'll revise the guide appropriately.
 
xCHPx
Old
#4  
Senior Member
Thanks Meter 19
Posts: 367
Join Date: Oct 2010
So will this work on any ROM?

Sent from my SCH-I535 using xda app-developers app
Motorola Original Droid X > HTC Thunderbolt > Samsung Galaxy S3 > HTC One M8
 
tu3218
Old
#5  
Senior Member
Thanks Meter 253
Posts: 2,468
Join Date: Apr 2009
Yeah I'm on stock rom just rooted an cwm. Can I flash this zip an since I don't have synergy, where will the backup be stored?

Sent from my SCH-I535 using xda app-developers app
 
thekendog
Old
#6  
thekendog's Avatar
Senior Member
Thanks Meter 64
Posts: 296
Join Date: Jul 2011
Worked on CM10.
The Following User Says Thank You to thekendog For This Useful Post: [ Click to Expand ]
 
Travisimo
Old
#7  
Senior Member
Thanks Meter 56
Posts: 147
Join Date: Oct 2010
I'm all for redundancy of backups, so here's hoping this method fully works when restoring. I have not experience a loss of IMEI myself, but I definitely want to be safe. I know the original efs backup method was proven to be an incomplete backup, but I thought the QPST NV backup method was proven to work? Are you saying that restoring with tthe QPST method (where you have an NV backup before you lose IMEO) does not work and will still having roaming issues?

At any rate, it will be interesting to see if this is the "one true backup" to rule them all for IMEI. So basically, you flash the zip in recovery and it creates another zip with the backed up contents. And in the event of an IMEI loss, you just flash the new zip and should be good to go? At least, that's the theory, right?
 
con247
Old
#8  
con247's Avatar
Retired Recognized Developer
Thanks Meter 3115
Posts: 3,070
Join Date: Sep 2010
Location: Ann Arbor
Quote:
Originally Posted by Travisimo View Post
I'm all for redundancy of backups, so here's hoping this method fully works when restoring. I have not experience a loss of IMEI myself, but I definitely want to be safe. I know the original efs backup method was proven to be an incomplete backup, but I thought the QPST NV backup method was proven to work? Are you saying that restoring with tthe QPST method (where you have an NV backup before you lose IMEO) does not work and will still having roaming issues?

At any rate, it will be interesting to see if this is the "one true backup" to rule them all for IMEI. So basically, you flash the zip in recovery and it creates another zip with the backed up contents. And in the event of an IMEI loss, you just flash the new zip and should be good to go? At least, that's the theory, right?
You nailed it!
Current Phone: iPhone 5[s]
Check out my GS3 Splash Screen Changer
 
nyjumpman
Old
#9  
Senior Member
Thanks Meter 17
Posts: 112
Join Date: Aug 2012
Location: NYC
Nice, I'm assuming this is similar to what the Synergy ROM team is now including?
 
con247
Old
#10  
con247's Avatar
Retired Recognized Developer
Thanks Meter 3115
Posts: 3,070
Join Date: Sep 2010
Location: Ann Arbor
Quote:
Originally Posted by nyjumpman View Post
Nice, I'm assuming this is similar to what the Synergy ROM team is now including?
Its the same. Just a standalone version.

Sent from my SCH-I535 using Tapatalk 2
Current Phone: iPhone 5[s]
Check out my GS3 Splash Screen Changer

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes