[HOW TO] /efs Folder backup + Restore NV_DATA.BIN

Search This thread

Candanga

Senior Member
May 22, 2007
201
131
Pocri
I’ve compiled a quick guide to instruct how to make a copy of the /efs folder. I’ve found in many threads suggestions about backing up this folder but the methods itself are very general. Most of the times they suggest to “root and copy the folder” with Root Explorer or similar, but usually it’s not that easy or it just doesn't work for everyone (my case).

This guide ASUMES you have read this Excellent Guide by Darkstrikerfirst:
H E R E
<-- Make sure to read the ADB Guide.

I recommend doing this with a Mobile just taken out of the box or with any Official ROM of its Service Provider. If you have already Flashed your phone with another ROM but its working fine, then you can use that /efs also.

Why the /efs folder?
This is a very sensitive system folder that contains Phone-specific information such as the IMEI (encrypted in the nv_data.bin), wireless devices MAC addresses, product code (also in the nv_data.bin), and much more. Often users trying to change product codes or trying to unlock the mobile will end up corrupting data in this location.

Why back it up?
Well, let’s resume it saying that backing-up this little folder will keep you away from Samsung service centers.

***WARNING: I take no responsibility to any damage caused by the methods cited and/or written here. Their sole purpose is to back-up data and not to alter in any way the integrity of the original files of the mobile***

Please don’t ask how to recover your IMEI if you have previously messed your SGS without backing up this folder. I’m not familiar with such methods plus it is UNRELATED to this thread.

What you will need:
  • Rooted SGS to get permissions as a SU (Super User) and perform the backup
  • I would suggest learning a little about the terminal commands used (in case you are not familiar with them), as it’s better to know what you are doing rather than typing strings like a little chimp without knowing what they are; if you are a little lazy, then you have a good chance bricking your mobile.<- Busybox Commands(or Google them)
  • Terminal Emulator by Jack Palevich (available from the market) <-Terminal Emulator or use ADB which is included in the SDK Development Tools

IMPORTANT: If getting "error: device not found" under ADB (happened to me under CM7 2.3.4), you need to update your ADB drivers. Go HERE and follow the instructions to download the USB Driver for Windows, Revision 4 (Nexus S Support). Then update the drivers under your Windows Device Manager.
--------------------------------------
Backup commands
--------------------------------------

Depending on the type of root, you might have to use “busybox” at the beginning of the sting or just the string:

The standard prompt of terminal (adb) is a $ sign. Once you enter “SU” it will become a # Sign.

***NOTE: Make sure to keep an eye on the screen of your SGS during this process, because it will request SU permissions; else, you will get an error (just if it’s the first time). In Terminal Emulator you will need to reset the app after granting permissions cause it usually freezes***

*Remember: to use ADB you need to enable USB DEBUGGING under Applications/Development in your SGS. Once you are finished with the files, you need to turn it off so you can get the files.

Code:
su
tar zcvf /sdcard/efs-backup.tar.gz /efs        or

busybox tar zcvf /sdcard/efs-backup.tar.gz /efs


After this, you will end up with the file efs-backup.tar.gz in your INTERNAL SDCARD, which is a “tarball” or a ZIP of the /efs folder. That file is your backup. You can expand it with Winrar.

In another forum I also saw a recommendation to back up the st13 under /dev/block which can support greatly to recoveryour IMEI in case of a screw-up:

Code:
su
cat /dev/block/stl3 > /sdcard/efs_dev-block-stl3.img         or

busybox cat /dev/block/stl3 > /sdcard/efs_dev-block-stl3.img

Same thing, the target is the INTERNAL SDCARD, so go ahead and copy the file.

----------------------------
nv_data.bin - Restore
----------------------------

In case you screwed your IMEI by playing with the nv_data.bin and you are experiencing issues like:

  • Fake IMEI (usually 004999010640000)
  • Unable to download apps from the market
  • Unable to unlock your SIM card using your PIN
  • Weird apps are downloading automatically from the market
  • Blinking SIM card icon on the top tray… ETC

You may want to upload your fresh copy of this file back to the phone. Use this commands:
(thanks to Methyldioxide method to recover the product code http://forum.xda-developers.com/showthread.php?t=780509 )

Copy the file from your backup (efs-backup.tar.gz) and paste it in the INTERNAL SDCARD:

Code:
cp /sdcard/nv_data.bin /efs/nv_data.bin 
rm -rf /efs/nv_data.bin.md5 OR

busybox rm -rf /efs/nv_data.bin.md5
Reboot your SGS
The md5 hash/signature is removed (rm) as the system will generate a new one.

**Most likely your SIM code won’t work after this and you won’t be able to log into the phone**
Pop off your SIM card, boot your SGS and execute the following commands to change ownership of the file under ADB or Terminal as well:

Code:
su
busybox chown 1001:1001 /efs/nv_data.bin  or

chown 1001:1001 /efs/nv_data.bin

Hope this can help anyone with doubts. Cheers!
 
Last edited:

allotrios

Senior Member
Sep 20, 2010
213
24
funny thing

the other day i messed up nv_data.bak trying to get my old product code back

the phone would not recognise the sim card

i deleted the whole /efs folder and the phone made a new one

i got my imei but no product code

sim card started working everything looked ok appart from sgs tools reporting nothing as phone !?!

i did restore /efs from a backup i had and then my product code came back

weird though

I was on jpo when all this happened
 

Candanga

Senior Member
May 22, 2007
201
131
Pocri
I guess you find it entertaining if people messed up their IMEI, well we all have our kinkiness.

@EarlZ - I myself was a victim of this, but I managed to make a duplicate of my nv_data.bin as per instructions of the guide that I was following to unlock my SGS.

The only "tip" that I can give you (geez.. Im going against my own disclaimer lol :rolleyes:) is to try to flash it back to JM1 or the earliest release of your mobile. I think I remember to get my IMEI back doing this, but then lost it flashing to a newer ROM. AGAIN, my "research" didn't go past this as I managed to get my IMEI back, reason why I got inspired to throw this little guide. :)

Hope this can get you started on your IMEI recovery journey.

Cheers mate.
 

gtg2

Senior Member
Aug 12, 2010
286
42
Thanks for the HowTo.

I ended up deleting my nv_data files in order to restore the backup files to get back the orig product code. As far as I can tell, it worked perfectly.

Code:
busybox rm -rf /efs/nv_data.bin
busybox rm -rf /efs/nv_data.bin.md5
 

cellgeek

Senior Member
Dec 24, 2006
149
11
Seattle
In case you really boink your EFS

I wanted to add a small piece to this thread that not really consolidated anywhere I can fine. I toasted my /EFS yesterday - to the point of no cellular unless I was at JF6. I couldn't use tar because I'd get "out of room" errors and "numerical value out of range". I mean I SERIOUSLY borked the /EFS. But then I've been flashing this phone from the day it was available from AT&T.

I used ODIN to restore my /EFS. I have a permanent generic IMEI.

There are several good threads on backup of the /EFS, but not on restoring. If you follow the OP post to backup, here's a good discussion on how to restore.

http://forum.xda-developers.com/showthread.php?t=882039

What wasn't clear in Da_G's thread is the you don't have to use DD to use ODIN to restore. There's no discussion on using the .img file to restore. That's scattered across a couple of threads and lots of reading. I'm not a linux guy, so I had to figure this out. . . .:eek:

Deep in rotohammer's following thread, there is a discussion about using a cat .img file to do create an ODIN .rfs file that allows you to restore from ODIN.

http://forum.xda-developers.com/showthread.php?t=850359

So here's what I did to restore my /EFS to functional. You MUST have a backup of your functional /EFS using either dd or cat and ADB installed.

On your PC do the following:
c:\Android\tools> adb shell
$ su (you're now on your phones Android command line; watch your home screen on the phone in case Superuser comes up asking for permission)
#

Now we're going to take the efs_folder_backup_stl3.img that you did with the cat file and make it usable by ODIN. Change directory locations to your cat .img location. Mine is on /sdcard/external_sd/.

#cd /sdcard/external_sd/
#busybox cat efs_folder_backup_stl3.img > /sdcard/efs.rfs (this is the key step!!)
# cd /sdcard
# tar -cf efs.tar efs.rfs
# exit
$ exit

Now your back at your PC. Do the following step to get the .tar file off your phone.

c:\Android\tools> adb pull /sdcard/efs.tar

Almost done. Move the efs.tar file to the same direction as ODIN and the follow the last directions in Da_G's thread. I'll post them below for just for clarity.

"Now, get into download mode, open odin, stick efs.tar in PDA slot, and press start. Bam! EFS fixed"

This worked for me, several times. Once you have the /EFS directory in ODIN flashable tar format - you really have to work hard to brick your phone.

Hope this helps!
 

Fuma

Senior Member
Nov 12, 2010
245
15
Hi
backedup my efs folder through this thread in combination with roto.

cellgeek in your post you say : " busybox cat efs_folder_backup_stl3.img > /sdcard/efs.rfs (this is the key step!!)"
But i never made an .img file/folder.
both the dd and cat created an rfs file which i turned to tar.
am i missing a step?
thank you for your little extra guide.
 

cadusir

Senior Member
Dec 29, 2010
110
19
Thanks that was very useful but I have a problem here.
When I copy my nv_data.bin file to efs directory I can only change the ownership but not the group!
I tried both of this:
su
busybox chown 1001:1001 /efs/nv_data.bin or

chown 1001:1001 /efs/nv_data.bin
and
su
busybox chown radio:radio /efs/nv_data.bin or

chown radio:radio /efs/nv_data.bin
 

Top Liked Posts

  • There are no posts matching your filters.
  • 44
    I’ve compiled a quick guide to instruct how to make a copy of the /efs folder. I’ve found in many threads suggestions about backing up this folder but the methods itself are very general. Most of the times they suggest to “root and copy the folder” with Root Explorer or similar, but usually it’s not that easy or it just doesn't work for everyone (my case).

    This guide ASUMES you have read this Excellent Guide by Darkstrikerfirst:
    H E R E
    <-- Make sure to read the ADB Guide.

    I recommend doing this with a Mobile just taken out of the box or with any Official ROM of its Service Provider. If you have already Flashed your phone with another ROM but its working fine, then you can use that /efs also.

    Why the /efs folder?
    This is a very sensitive system folder that contains Phone-specific information such as the IMEI (encrypted in the nv_data.bin), wireless devices MAC addresses, product code (also in the nv_data.bin), and much more. Often users trying to change product codes or trying to unlock the mobile will end up corrupting data in this location.

    Why back it up?
    Well, let’s resume it saying that backing-up this little folder will keep you away from Samsung service centers.

    ***WARNING: I take no responsibility to any damage caused by the methods cited and/or written here. Their sole purpose is to back-up data and not to alter in any way the integrity of the original files of the mobile***

    Please don’t ask how to recover your IMEI if you have previously messed your SGS without backing up this folder. I’m not familiar with such methods plus it is UNRELATED to this thread.

    What you will need:
    • Rooted SGS to get permissions as a SU (Super User) and perform the backup
    • I would suggest learning a little about the terminal commands used (in case you are not familiar with them), as it’s better to know what you are doing rather than typing strings like a little chimp without knowing what they are; if you are a little lazy, then you have a good chance bricking your mobile.<- Busybox Commands(or Google them)
    • Terminal Emulator by Jack Palevich (available from the market) <-Terminal Emulator or use ADB which is included in the SDK Development Tools

    IMPORTANT: If getting "error: device not found" under ADB (happened to me under CM7 2.3.4), you need to update your ADB drivers. Go HERE and follow the instructions to download the USB Driver for Windows, Revision 4 (Nexus S Support). Then update the drivers under your Windows Device Manager.
    --------------------------------------
    Backup commands
    --------------------------------------

    Depending on the type of root, you might have to use “busybox” at the beginning of the sting or just the string:

    The standard prompt of terminal (adb) is a $ sign. Once you enter “SU” it will become a # Sign.

    ***NOTE: Make sure to keep an eye on the screen of your SGS during this process, because it will request SU permissions; else, you will get an error (just if it’s the first time). In Terminal Emulator you will need to reset the app after granting permissions cause it usually freezes***

    *Remember: to use ADB you need to enable USB DEBUGGING under Applications/Development in your SGS. Once you are finished with the files, you need to turn it off so you can get the files.

    Code:
    su
    tar zcvf /sdcard/efs-backup.tar.gz /efs        or
    
    busybox tar zcvf /sdcard/efs-backup.tar.gz /efs


    After this, you will end up with the file efs-backup.tar.gz in your INTERNAL SDCARD, which is a “tarball” or a ZIP of the /efs folder. That file is your backup. You can expand it with Winrar.

    In another forum I also saw a recommendation to back up the st13 under /dev/block which can support greatly to recoveryour IMEI in case of a screw-up:

    Code:
    su
    cat /dev/block/stl3 > /sdcard/efs_dev-block-stl3.img         or
    
    busybox cat /dev/block/stl3 > /sdcard/efs_dev-block-stl3.img

    Same thing, the target is the INTERNAL SDCARD, so go ahead and copy the file.

    ----------------------------
    nv_data.bin - Restore
    ----------------------------

    In case you screwed your IMEI by playing with the nv_data.bin and you are experiencing issues like:

    • Fake IMEI (usually 004999010640000)
    • Unable to download apps from the market
    • Unable to unlock your SIM card using your PIN
    • Weird apps are downloading automatically from the market
    • Blinking SIM card icon on the top tray… ETC

    You may want to upload your fresh copy of this file back to the phone. Use this commands:
    (thanks to Methyldioxide method to recover the product code http://forum.xda-developers.com/showthread.php?t=780509 )

    Copy the file from your backup (efs-backup.tar.gz) and paste it in the INTERNAL SDCARD:

    Code:
    cp /sdcard/nv_data.bin /efs/nv_data.bin 
    rm -rf /efs/nv_data.bin.md5 OR
    
    busybox rm -rf /efs/nv_data.bin.md5
    Reboot your SGS
    The md5 hash/signature is removed (rm) as the system will generate a new one.

    **Most likely your SIM code won’t work after this and you won’t be able to log into the phone**
    Pop off your SIM card, boot your SGS and execute the following commands to change ownership of the file under ADB or Terminal as well:

    Code:
    su
    busybox chown 1001:1001 /efs/nv_data.bin  or
    
    chown 1001:1001 /efs/nv_data.bin

    Hope this can help anyone with doubts. Cheers!
    3
    An alternative to the backup part is to use Root Explorer and zip the whole /efs folder onto your external sd card. (or wherever you want)
    3
    In case you really boink your EFS

    I wanted to add a small piece to this thread that not really consolidated anywhere I can fine. I toasted my /EFS yesterday - to the point of no cellular unless I was at JF6. I couldn't use tar because I'd get "out of room" errors and "numerical value out of range". I mean I SERIOUSLY borked the /EFS. But then I've been flashing this phone from the day it was available from AT&T.

    I used ODIN to restore my /EFS. I have a permanent generic IMEI.

    There are several good threads on backup of the /EFS, but not on restoring. If you follow the OP post to backup, here's a good discussion on how to restore.

    http://forum.xda-developers.com/showthread.php?t=882039

    What wasn't clear in Da_G's thread is the you don't have to use DD to use ODIN to restore. There's no discussion on using the .img file to restore. That's scattered across a couple of threads and lots of reading. I'm not a linux guy, so I had to figure this out. . . .:eek:

    Deep in rotohammer's following thread, there is a discussion about using a cat .img file to do create an ODIN .rfs file that allows you to restore from ODIN.

    http://forum.xda-developers.com/showthread.php?t=850359

    So here's what I did to restore my /EFS to functional. You MUST have a backup of your functional /EFS using either dd or cat and ADB installed.

    On your PC do the following:
    c:\Android\tools> adb shell
    $ su (you're now on your phones Android command line; watch your home screen on the phone in case Superuser comes up asking for permission)
    #

    Now we're going to take the efs_folder_backup_stl3.img that you did with the cat file and make it usable by ODIN. Change directory locations to your cat .img location. Mine is on /sdcard/external_sd/.

    #cd /sdcard/external_sd/
    #busybox cat efs_folder_backup_stl3.img > /sdcard/efs.rfs (this is the key step!!)
    # cd /sdcard
    # tar -cf efs.tar efs.rfs
    # exit
    $ exit

    Now your back at your PC. Do the following step to get the .tar file off your phone.

    c:\Android\tools> adb pull /sdcard/efs.tar

    Almost done. Move the efs.tar file to the same direction as ODIN and the follow the last directions in Da_G's thread. I'll post them below for just for clarity.

    "Now, get into download mode, open odin, stick efs.tar in PDA slot, and press start. Bam! EFS fixed"

    This worked for me, several times. Once you have the /EFS directory in ODIN flashable tar format - you really have to work hard to brick your phone.

    Hope this helps!
    2
    Thanks that was very useful but I have a problem here.
    When I copy my nv_data.bin file to efs directory I can only change the ownership but not the group!
    I tried both of this:

    and

    Today I screwed my IMEI upgrading to MIUI 2.3.4, cause the OS loaded a wrong nv_data.bin and failed to back-it up properly. I followed the same steps posted here and got it working [and several other times I messed the nv_data] :)

    When you first reboot after replacing the nv_data.bin and deleting the md5 hash, the phone will reboot (if you have the SIM card in), it won't ask for your SIM code. You validate the IMEI by using the: [busybox chown 1001:1001 /efs/nv_data.bin] string. I am not familiar with the other one you posted about changing the group, why would you want to do that?

    Cheers.
    1
    Sorry to revive if this is old;

    Why won't rm -rf /efs/nv_data.bin.md5 work in terminal? It gives me an error along the lines of this is a read-only file etc?

    Try "busybox rm -rf /efs/nv_data.bin.md5"