[SOLVED][Guide] How to backup EFS + Modemfs folders

Search This thread

YMatrix

Senior Member
Hello!

So I recently stumbled upon some information that while flashing all kinds of Roms, you might lose your IMEI, thus being left over with a nice paper weight.
To my understanding this information is stored in the EFS folder (though according to this thread it is actually stored in modemfs).
I googled around and saw many options: PC software, terminal commands, apps etc.
Since each phone utilizes this option in different ways, which would be a good way to backup these folders in case of emergency on the S Advance?

Thanks!

SOLUTION:

These are the commands from the ADB shell, but can also be used within the terminal.

Backup Process:
Code:
adb shell
su
dd if=/dev/block/mmcblk0p7 of=/sdcard/efs_backup.img
dd if=/dev/block/mmcblk0p2 of=/sdcard/modemfs_backup.img 
exit
exit
adb pull /sdcard/efs_backup.img efs_backup.img
adb pull /sdcard/modemfs_backup.img modemfs_backup.img

Restore Backup Process:
Code:
adb push efs_backup.img /sdcard/efs_backup.img
adb push modemfs_backup.img /sdcard/modemfs_backup.img
adb shell
su
dd if=/sdcard/efs_backup.img of=/dev/block/mmcblk0p7 
dd if=/sdcard/modemfs_backup.img of=/dev/block/mmcblk0p2 
exit
exit

Thanks to @mr.harsh and @KINGbabasula for help and KINGbabasula for making the script!
Please note that the restore commands haven't been tested out, but theoretically its supposed to work.
If someone has made a backup and wiped his EFS folder, he wont mind testing it out :D
 

Attachments

  • efsbackup.zip
    457.2 KB · Views: 7,163
Last edited:

BOOTMGR

Senior Member
Aug 3, 2010
728
3,395
anoobdevsdiary.blogspot.in
Hello!

So I recently stumbled upon some information that while flashing all kinds of Roms, you might lose your IMEI, thus being left over with a nice paper weight.
To my understanding this information is stored in the EFS folder (though according to this thread it is actually stored in modemfs).
I googled around and saw many options: PC software, terminal commands, apps etc.
Since each phone utilizes this option in different ways, which would be a good way to backup these folders in case of emergency on the S Advance?

Thanks!
in the terminal type:
Code:
su
cp /dev/block/mmcblk0p7 /sdcard/efs_backup
cp /dev/block/mmcblk0p2 /sdcard/modemfs_backup

check that efs_backup is 10MB and modemfs_backup is 16MB.And this is for JB.I don't know about GB but most probably they'll be same...
 

YMatrix

Senior Member
Thank you for your quick reply.
I tested it out and got the sizes you said.
The restore process, if ever needed, is the same cp command only changing the source and destination?
Whats the difference between the CP command and the DD command?
Any way to do this from recovery or ADB?

Sent from my GT-I9070 using Tapatalk 4 Beta
 
Last edited:

KINGbabasula

Inactive Recognized Developer
Jan 28, 2013
2,301
5,167
Treviso
Thank you for your quick reply.
I tested it out and got the sizes you said.
The restore process, if ever needed, is the same cp command only changing the source and destination?
Whats the difference between the CP command and the DD command?
Any way to do this from recovery or ADB?

Sent from my GT-I9070 using Tapatalk 4 Beta

Via adb:
Code:
adb shell
$ su
# cp /dev/block/mmcblk0p7 /sdcard/efs_backup
# cp /dev/block/mmcblk0p2 /sdcard/modemfs_backup
# exit
$ exit
adb pull /sdcard/efs_backup %cd%\efs_backup
adb pull /sdcard/modemfs_backup %cd%\modemfs_backup
 
Last edited:
  • Like
Reactions: YMatrix

YMatrix

Senior Member
cp=copy dd=copy, convert, format. See my reply. I updated

Still don't get the difference DD / CP :p
As for the commands you posted, I was asking for the restore process, so I am guessing it will look like this:
Code:
adb shell
$ su
# cp /sdcard/efs_backup /dev/block/mmcblk0p7 
# cp /sdcard/modemfs_backup /dev/block/mmcblk0p2 
# exit
$ exit
Is there a "push" command also (to be used like the pull command)?
 

KINGbabasula

Inactive Recognized Developer
Jan 28, 2013
2,301
5,167
Treviso
Still don't get the difference DD / CP :p
As for the commands you posted, I was asking for the restore process, so I am guessing it will look like this:
Code:
adb shell
$ su
# cp /sdcard/efs_backup /dev/block/mmcblk0p7 
# cp /sdcard/modemfs_backup /dev/block/mmcblk0p2 
# exit
$ exit
Is there a "push" command also (to be used like the pull command)?

I'm not sure but i think that you need to use dd to restore because you are going to flash 2 partition like flashing kernel.
You can do this (i repeat Im not sure)
Code:
adb push efs_backup /sdcard/efs_backup
adb push modemfs_backup /sdcard/modemfs_backup
adb shell
$ su
# dd if=/sdcard/efs_backup of=/dev/block/mmcblk0p7 
# dd if=/sdcard/modemfs_backup of=/dev/block/mmcblk0p2 
# exit
$ exit

Pay attention cause if you dd to a wrong partition you may brick
 
  • Like
Reactions: YMatrix

YMatrix

Senior Member
I'm not sure but i think that you need to use dd to restore because you are going to flash 2 partition like flashing kernel.

Pay attention cause if you dd to a wrong partition you may brick

Hmmm, so this is a pickle.
Wrong partition is always a problem, but since I also checked a thread by @frapeti, I am assuming the partition numbers are correct, though I don't know about the commands. Since we saved using CP shouldn't we also restore using CP? Otherwise I would say save using DD and then restore using DD.
 

KINGbabasula

Inactive Recognized Developer
Jan 28, 2013
2,301
5,167
Treviso
Hmmm, so this is a pickle.
Wrong partition is always a problem, but since I also checked a thread by @frapeti, I am assuming the partition numbers are correct, though I don't know about the commands. Since we saved using CP shouldn't we also restore using CP? Otherwise I would say save using DD and then restore using DD.

No because cp copy the content of the partition. dd format the partition then copy in the partition
 

YMatrix

Senior Member
No because cp copy the content of the partition. dd format the partition then copy in the partition

Oh, alright, so to sum up so people can use this for future reference:

Backup Process:
Code:
adb shell
$ su
# cp /sdcard/efs_backup /dev/block/mmcblk0p7 
# cp /sdcard/modemfs_backup /dev/block/mmcblk0p2 
# exit
$ exit

Restore Backup Process:
Code:
adb push efs_backup /sdcard/efs_backup
adb push modemfs_backup /sdcard/modemfs_backup
adb shell
$ su
# dd if=/sdcard/efs_backup of=/dev/block/mmcblk0p7 
# dd if=/sdcard/modemfs_backup of=/dev/block/mmcblk0p2 
# exit
$ exit
 

KINGbabasula

Inactive Recognized Developer
Jan 28, 2013
2,301
5,167
Treviso
Oh, alright, so to sum up so people can use this for future reference:

Backup Process:
Code:
adb shell
$ su
# cp /sdcard/efs_backup /dev/block/mmcblk0p7 
# cp /sdcard/modemfs_backup /dev/block/mmcblk0p2 
# exit
$ exit

Restore Backup Process:
Code:
adb push efs_backup /sdcard/efs_backup
adb push modemfs_backup /sdcard/modemfs_backup
adb shell
$ su
# dd if=/sdcard/efs_backup of=/dev/block/mmcblk0p7 
# dd if=/sdcard/modemfs_backup of=/dev/block/mmcblk0p2 
# exit
$ exit

Now i make a script to automate it
 
  • Like
Reactions: YMatrix

arffrhn

Senior Member
Mar 12, 2013
1,583
763
Kuala Lumpur
Hi, I just wanna ask. Can I just copy the efs and modemfs folders to ext sd, then to restore I just copy and replace both files to its actual location using any root explorer (ie: es file manager)? Just asking as I read this guide on backing imei part.
 

frapeti

Inactive Recognized Developer
Mar 23, 2012
1,048
4,224
Cordoba, Argentina
www.groupon.com.ar
Oh, alright, so to sum up so people can use this for future reference:

Backup Process:
Code:
adb shell
$ su
# cp /sdcard/efs_backup /dev/block/mmcblk0p7 
# cp /sdcard/ /dev/block/mmcblk0p2 
# exit

[/QUOTE]

Thats wrong, to backup using cp use something like cp [original efs] [sdcard/backup folder]

I guess it's better to use dd command for this purpose:

dd if=/dev/block/mmcblk0p7 of=/sdcard/efs_backup.img

dd if=/dev/block/mmcblk0p2 of=/sdcard/modemfs_backup.img

To restore just switch if with of (input file / output file)

Sent from my GT-I9070 using xda app-developers app
 

Top Liked Posts

  • There are no posts matching your filters.
  • 7
    Hello!

    So I recently stumbled upon some information that while flashing all kinds of Roms, you might lose your IMEI, thus being left over with a nice paper weight.
    To my understanding this information is stored in the EFS folder (though according to this thread it is actually stored in modemfs).
    I googled around and saw many options: PC software, terminal commands, apps etc.
    Since each phone utilizes this option in different ways, which would be a good way to backup these folders in case of emergency on the S Advance?

    Thanks!

    SOLUTION:

    These are the commands from the ADB shell, but can also be used within the terminal.

    Backup Process:
    Code:
    adb shell
    su
    dd if=/dev/block/mmcblk0p7 of=/sdcard/efs_backup.img
    dd if=/dev/block/mmcblk0p2 of=/sdcard/modemfs_backup.img 
    exit
    exit
    adb pull /sdcard/efs_backup.img efs_backup.img
    adb pull /sdcard/modemfs_backup.img modemfs_backup.img

    Restore Backup Process:
    Code:
    adb push efs_backup.img /sdcard/efs_backup.img
    adb push modemfs_backup.img /sdcard/modemfs_backup.img
    adb shell
    su
    dd if=/sdcard/efs_backup.img of=/dev/block/mmcblk0p7 
    dd if=/sdcard/modemfs_backup.img of=/dev/block/mmcblk0p2 
    exit
    exit

    Thanks to @mr.harsh and @KINGbabasula for help and KINGbabasula for making the script!
    Please note that the restore commands haven't been tested out, but theoretically its supposed to work.
    If someone has made a backup and wiped his EFS folder, he wont mind testing it out :D
    4
    Oh, alright, so to sum up so people can use this for future reference:

    Backup Process:
    Code:
    adb shell
    $ su
    # cp /sdcard/efs_backup /dev/block/mmcblk0p7 
    # cp /sdcard/ /dev/block/mmcblk0p2 
    # exit
    
    [/QUOTE]
    
    Thats wrong, to backup using cp use something like cp [original efs] [sdcard/backup folder]
    
    I guess it's better to use dd command for this purpose:
    
    dd if=/dev/block/mmcblk0p7 of=/sdcard/efs_backup.img
    
    dd if=/dev/block/mmcblk0p2 of=/sdcard/modemfs_backup.img
    
    To restore just switch if with of (input file / output file)
    
    Sent from my GT-I9070 using xda app-developers app
    3
    Hello!

    So I recently stumbled upon some information that while flashing all kinds of Roms, you might lose your IMEI, thus being left over with a nice paper weight.
    To my understanding this information is stored in the EFS folder (though according to this thread it is actually stored in modemfs).
    I googled around and saw many options: PC software, terminal commands, apps etc.
    Since each phone utilizes this option in different ways, which would be a good way to backup these folders in case of emergency on the S Advance?

    Thanks!
    in the terminal type:
    Code:
    su
    cp /dev/block/mmcblk0p7 /sdcard/efs_backup
    cp /dev/block/mmcblk0p2 /sdcard/modemfs_backup

    check that efs_backup is 10MB and modemfs_backup is 16MB.And this is for JB.I don't know about GB but most probably they'll be same...
    2
    Yeah that's why I asked. Wondering if I do anything wrong and it won't work when restoring.

    Copying the folders in theory should also work, its just safer to back them up using the DD command since you get the original structure, permissions, dates etc. of the partitions.
    Thus when restoring its as if you never tampered with them, while the "copy folder" method doesn't give you the original data structure.
    Again, it shouldn't make a difference (in theory), but we always like to be closest to the original ;)
    2
    Hi,

    I was trying to take backup of these folders, but before that, i thought of having a look at the actual folder in the root for their sizes.

    efs = 87 files, 12 folder. total six=ze is 4.84Kb
    modemfs = This folder is empty.

    Now please tell is if these are normal sizes. If it is normal then how come their backup is 10 & 16 Mb respectively.
    Regards,
    Fred

    I am surprised that your modemfs folder is empty :eek:
    As for the folder size vs. backup size, this is because that these folders are actually partitions on the phone. when backing up using DD / CP commands you are backing up the whole partition (even the "empty" bits of data), which is why you get the according sizes (these are the partition's sizes).