LG to Release Octa-Core “Nuclun” SoC in the LG G3 Screen

LG is set to follow the likes of Samsung and other manufacture its own … more

Lockdown Pro 2 Brings Material Design and Media Support

Back in March of this year, we took a look at a rather innovated security application … more

Mural Watchface Brings 500px to Android Wear

On a traditional watch, you can’t really do too much to change its appearance once … more

Android 5.0 Favorite Features, Release November 3rd? – XDA TV

Google Confirms Android 5.0 Lollipop for November 3rd! That and much more … more
Post Reply

[Tools][How-To][Guides] Backup & Restore EFS + Get out from Permanent Safe mode

OP tamirda

5th September 2013, 10:53 PM   |  #1  
tamirda's Avatar
OP Recognized Developer
Thanks Meter: 12,057
 
3,295 posts
Join Date:Joined: Jul 2010
Donate to Me
More
Note to forum managers: Please make it a Sticky Thread, It should help to all users and there is no use for this tutorial if it is in page 3

Hello XDA Users,

I think some people here know who I am, so I will jump on the "Introduction of myself" for now.

Recently, I have faced many questions & problem of fake IMEI, of damaged EFS folder. So I made a little experiment on my device(GN2).

First, I backuped my EFS folder in 2 types - one is .img and the second is tar.gz.

Then, I deleted my EFS folder using ES Root Explorer. Which made my device to be on somethine called "Permanent Safe Mode" - You can not get out untill you fix your EFS folder and change some values.
This is permanent safe mode:



After I did my "research" I have managed to make several methods to backup & restore EFS, which should make your life easier and better.


First of all, Disclaimer:


I'm not responsible for any damage caused by using these methods, all methods tested by me, so it should work on your device too.
This is for I9505 Only!!!!!!!



Let's continue.

What you must have:
  • Latest base with latest modem and latest kernel - very important since in the latest versions samsung prevented the option to install old modems/kernels, so if you install old kernell/modem it can show you wrong IMEI.
  • Rooted device with the latest Super User
  • Latest busybox
  • PhilZ Recovery
  • Terminal Emulator
  • Root explorer - Can be ES File Explorer with working root option or just a root explorer from the market
  • A working EFS backup(In order to restore it...)
  • Time & Patient.



Important Notes:
  • When installing/downgrading firmwares, several people suffered from Fake IMEI. This is because the new firmware messed up your EFS folder, which means that you can not restore EFS backup until you are on the latest version, latest modem and latest stock kernel, recommended is XXUBMH1(right to 05/09/2013)
  • Some custom roms include modem installation in their rom installer. Due to modem flashing in recovery, some devices might get Fake IMEI. My recommendation is before even starting to use this guide, please try to install the latest modem via odin from this thread:
    http://forum.xda-developers.com/show....php?t=2192025

    When installing modem via odin, make sure you select PHONE and not PDA
  • You will find at least one method that works on your device, so don't give up after one method.
  • Read all guide and pay attention to all small details.

Backup methods

Method 1 - .img backup

First method, is an automatic backup/restore software.


Special thanks to A.S._id for his software.

The software:
Quote:

I9505 EFS Backup / Restore

Help to preserve and restore the image of EFS partition:
* Need Root

For Windows

* Extract from the archive, connect the device to the USB debugging mode (System settings/Developer options/USB debugging) and run selected .bat (depending on the backup or restore)
* To retain the image of efs.img must be in a folder with Restore_EFS.bat





* Extract from the archive, connect the device to the USB debugging mode (System settings/Developer options/USB debugging) and run RUN_ME into terminal (double click), select option...


What is EFS, Why it is necessary to backup



Method 2 - .img backup


Method number 2 will create you efs.img backup on your internal sd. After that you can copy it to your computer.

What you have to do is this:
Quote:

  1. Open terminal emulator
  2. Write the following:
    Code:
    su
    Then click enter. It will ask for super user permission, give it permissions.
  3. Then write:
    Code:
    dd if=/dev/block/mmcblk0p10 of=/sdcard/efs.img bs=4096
    Then click enter.
  4. When it finishes, check if you have efs.img on your phone memory. If so, copy it to comupter, if not, you did something wrong try again.



Method 3 - .tar.gz backup

This method will compress your efs folder into tar.gz file. This method is the same as choosing backup EFS folder in my rom(PhoeniX ROM)/Omega/Wanam/etc.

A tar.gz backup should look like this(On some devices there might be more files, but this picture was taken from Note II N7100 backup and it fully works):


What you have to do is this:
Quote:

  1. Download this and copy it to your device:
    http://d-h.st/SaK
  2. Reboot into recovery
  3. Flash the zip
  4. Reboot your device.
  5. Connect your device to your pc, and copy the backup in "efs_backup" folder.



Restore methods

Now the fun begins

You will have to restore your backup when you have one or more of the folowing problem:
  • Fake IMEI (usually 004999010640000) or "null" IMEI
  • Blinking SIM card icon on the top tray… ETC
  • Unable to unlock your SIM card using your PIN
  • Fake Serial Number (usually 0000000) or "null" Serial
  • Unable to register to the network (usually comes with Fake IMEI & Fake Serial so check them.)

Attention please,
If you are 100% that your EFS folder is damaged and you have a working EFS backup with the right IMEI number, my recommendation is this:

Quote:

  1. With root explorer, go to your efs folder and delete all files inside
  2. Long press on power button will turn off your device.
  3. Then turn on the device, you will be in "Permanent Safe Mode".
  4. Continue to one of the following methods.



Method 1 - restore .img backup

First method, is an automatic backup/restore software.


Special thanks to A.S._id for his software.

The software:
Quote:

I9505 EFS Backup / Restore

Help to preserve and restore the image of EFS partition:
* Need Root

For Windows

* Extract from the archive, connect the device to the USB debugging mode (System settings/Developer options/USB debugging) and run selected .bat (depending on the backup or restore)
* To retain the image of efs.img must be in a folder with Restore_EFS.bat





* Extract from the archive, connect the device to the USB debugging mode (System settings/Developer options/USB debugging) and run RUN_ME into terminal (double click), select option...


What is EFS, Why it is necessary to backup




Method 2 - Restore .img backup


Method number 2 will restore your efs.img backup from your internal sd.

What you have to do is this:
Quote:

  1. Put your efs.img on your phone memory(not external sd card!) in the main memory, not inside folder.
  2. Open terminal emulator
  3. Write the following:
    Code:
    su
    Then click enter. It will ask for super user permission, give it permissions.
  4. Then write:
    Code:
    dd if=/sdcard/efs.img of=/dev/block/mmcblk0p10 bs=4096
    Then click enter.
  5. Now, reboot your device. If you still don't have IMEI/You are still in Safe Mod, reboot again.
    In the second reboot, the bootanimation might stuck and the device will reboot automatically again. Don't worry, it is ok because it installs your efs.img.




Method 3 - restore .tar.gz backup



This method will restore .tar.gz backup.
A tar.gz backup should look like this(On some devices there might be more files, but this picture was taken from Note II N7100 backup and it fully works):


If you have like this, continue to the guide:
Quote:

  1. Create on your Phone Memory(Not Extrenal sd!!) a folder called "efsbackup"(without quotes)
  2. Copy all files & folders from the EFS backup into "efsbackup" folder(The files are like in the picture)
  3. Download this script & copy it to your device:
    http://d-h.st/zwR
  4. Reboot into recovery
  5. Go to mount section and click on(Very important!):
    Quote:

    Mount /efs

  6. Now install the script you have downloaded.
  7. After it finishes, reboot.
  8. Now everything should be fixed, of course if your backup is 100% ok.
    If it doesn't work, try method 4.




Method 4 - restore .tar.gz backup


This method will restore .tar.gz backup.
A tar.gz backup should look like this(On some devices there might be more files, but this picture was taked from Note II N7100 backup and it fully works):


If you have like this, continue to the guide:
Quote:

  1. Create on your Phone Memory(Not Extrenal sd!!) a folder called "efsbackup"(without quotes)
  2. Copy all files & folders from the EFS backup into "efsbackup" folder(The files are like in the picture)
  3. Using root explorer, go to "efsbackup folder, select all files & folders there, and click Copy.
  4. Still in root explorer, go to "efs" folder of your device(It is located where all main folders like data, system, etc.).
  5. In "efs" folder, click paste. It will ask you if you want to replace your files, select replace to all files(So all your files from "efsbackup" folder will be in "efs" folder)
  6. Now open terminal emulator
  7. Write the following:
    Code:
    su
    Then click enter. It will ask for super user permission, give it permissions.
  8. Now write:
    Code:
    busybox chown 1001:1001 /efs/nv_data.bin
    Then click enter.
  9. Now write:
    Code:
    busybox chmod 06755 /efs/nv_data.bin
    Then click enter.
  10. Reboot device. Now everything should work.




Exit "Permanent Safe Mode"

When you in "Permanent Safe Mode" situation, it means that your EFS folder is broken.
If you succeeded in restoring your IMEI and you still stuck in this Safe Mode, use this guide:

Method 1

Quote:

  1. Open root explorer.
  2. Navigate to /efs/FactoryApp/
  3. Open "factorymode" file as Text and edit it:
    Change this:
    Code:
    OFF
    To:
    Code:
    ON
  4. Open "keystr" file as Text and edit it:
    Change this:
    Code:
    OFF
    To:
    Code:
    ON
  5. Reboot device.



Method 2

Quote:

  1. Open Terminal emulator
  2. Write the following:
    Code:
    su
    Then click enter. It will ask for super user permission, give it permissions.
  3. Write the following & click enter:
    Code:
    rm /efs/FactoryApp/keystr
  4. Write the following & click enter:
    Code:
    rm /efs/FactoryApp/factorymode
  5. Write the following & click enter:
    Code:
    echo -n ON >> /efs/FactoryApp/keystr
  6. Write the following & click enter:
    Code:
    echo -n ON >> /efs/FactoryApp/factorymode
  7. Write the following & click enter:
    Code:
    chown 1000.1000 /efs/FactoryApp/keystr
  8. Write the following & click enter:
    Code:
    chown 1000.1000 /efs/FactoryApp/factorymode
  9. Write the following & click enter:
    Code:
    chmod 0744 /efs/FactoryApp/keystr
  10. Write the following & click enter:
    Code:
    chmod 0744 /efs/FactoryApp/factorymode
  11. Reboot your device




This is all I can do for you friends, Worked alot on these methods to give you the best information.
Each method was tested by me and fully works.


If this helped you please press the "Thanks" button & Rate this thread 5 Stars.
If you like & appreciate my work please consider a donation!






Credits:
  • shnizlon
  • Candanga
  • A.S._id
  • dhiru1602
  • UtkarshGupta
  • P.M If you think that I forgot you

XDA:DevDB Information
Backup & Restore EFS + Get out from Permanent Safe mode - I9505, a Tool/Utility for the Samsung Galaxy S 4

Contributors
tamirda

Version Information
Status: Stable

Created 2013-09-05
Last Updated 2013-09-05
The Following 22 Users Say Thank You to tamirda For This Useful Post: [ View ]
27th September 2013, 09:29 AM   |  #2  
tamirda's Avatar
OP Recognized Developer
Thanks Meter: 12,057
 
3,295 posts
Join Date:Joined: Jul 2010
Donate to Me
More
Amm i guess no one need it?
The Following User Says Thank You to tamirda For This Useful Post: [ View ]
27th September 2013, 09:52 AM   |  #3  
port76's Avatar
Senior Member
Thanks Meter: 118
 
1,163 posts
Join Date:Joined: Jan 2011
Donate to Me
More
they do need it and i for one would like to thank you for the guide and time and effort in sharing ..mods and fixes are always welcome on xda thanks man:thumbup::thumbup:

Sent from my GT-I9505 using XDA Premium 4 mobile app
27th September 2013, 09:56 AM   |  #4  
tamirda's Avatar
OP Recognized Developer
Thanks Meter: 12,057
 
3,295 posts
Join Date:Joined: Jul 2010
Donate to Me
More
Quote:
Originally Posted by port76

they do need it and i for one would like to thank you for the guide and time and effort in sharing ..mods and fixes are always welcome on xda thanks man:thumbup::thumbup:

Sent from my GT-I9505 using XDA Premium 4 mobile app

Thanks first real comment in the thread

Sent from my GT-N7100 boosted by PhoeniX ROM
27th September 2013, 12:47 PM   |  #5  
port76's Avatar
Senior Member
Thanks Meter: 118
 
1,163 posts
Join Date:Joined: Jan 2011
Donate to Me
More
:thumbup:its ok any time my friend ....iv told my friends about the fix and I'm sure they will pop into this very useful and informative thread .. Thanks again iv added it to my subscribed topics and I'm sure people will be popping in to view and post on the thread thanks :thumbup::thumbup:

Sent from my GT-I9505 using XDA Premium 4 mobile app
The Following User Says Thank You to port76 For This Useful Post: [ View ]
28th September 2013, 02:27 PM   |  #6  
Senior Member
Thanks Meter: 64
 
250 posts
Join Date:Joined: Apr 2012
Nice guide, the command line is the best!
28th September 2013, 06:36 PM   |  #7  
Member
Thanks Meter: 30
 
38 posts
Join Date:Joined: Feb 2012
Will heimdall work as an alternative to restore the efs.img? Like this: heimdall flash --efs efs.img ?
It is used from download mode, like odin, so would work even if you cannot boot.

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Galaxy S 4 i9505 Android Development by ThreadRank