Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
paulobrien
Old
#1  
paulobrien's Avatar
Senior Member - OP
Thanks Meter 5241
Posts: 4,390
Join Date: Nov 2003
Location: Norwich
Default 18 Aug: EFS auto backup script (for devs)

I have now seen a number of cases of the EFS partition getting wiped / corrupted on the SGS II, leaving users with an effectively useless phone.

With this in mind, i've written a little init.d script for my ROM which backs up the EFS partition on boot if a backup does not already exist. A non intrusive safety net for users if you will.

The script just needs a suitable boot image that runs init.d, although it could easily be tacked onto the end of install-recovery.sh if that's not the case.

I'd love to encourage all developers to use this script for users' sake!

You can download the script here - http://cl.ly/2j0p0R3F07052m2T2u0e - but it's very simple, here's the code...

Code:
#!/system/bin/sh
# EFS auto backup script for Samsung Galaxy S II
# By @paulobrien - http://s2.MoDaCo.com

mount /dev/block/mmcblk0p11 /sdcard

if [ ! -f /sdcard/efs.autobackup.img ];
then
        dd if=/dev/block/mmcblk0p1 of=/sdcard/efs.autobackup.img
fi

umount /sdcard


Note the manual mount / umount of sdcard is necessary because this happens late in the boot process.

Cheers!

P
Follow me on Twitter - http://twitter.com/paulobrien

Follow MoDaCo Android on Twitter - http://twitter.com/modaco

Want to donate? MoDaCo is raising money for the Multiple Sclerosis society.

The Following 13 Users Say Thank You to paulobrien For This Useful Post: [ Click to Expand ]
 
tolis626
Old
#2  
tolis626's Avatar
Senior Member
Thanks Meter 586
Posts: 2,441
Join Date: Dec 2009
Location: Amaliada
Hats of to you Paul.Although I have already made a backup of my EFS folder,such a script would save MANY people from A LOT of trouble.
 
haasgo
Old
#3  
haasgo's Avatar
Senior Member
Thanks Meter 136
Posts: 522
Join Date: May 2011
Location: Hamburg

 
DONATE TO ME
Quote:
Originally Posted by tolis626 View Post
Hats of to you Paul.Although I have already made a backup of my EFS folder,such a script would save MANY people from A LOT of trouble.
i havent...never did. i think i wiped about a hundred times now and flashed and reflashed...is it possible to recover the efs folder?
If you like what you are reading press "Thanks!"
 
Teio
Old
#4  
Senior Member
Thanks Meter 66
Posts: 317
Join Date: Sep 2009
Location: London

 
DONATE TO ME
Quote:
Originally Posted by haasgo View Post
i havent...never did. i think i wiped about a hundred times now and flashed and reflashed...is it possible to recover the efs folder?
If your phone is working, it means your EFS partition is still there...

You can back it up using the many tutorials out there in the forum...

Sent from my GT-I9100 using XDA Premium App
 
JJEgan
Old
#5  
Senior Member
Thanks Meter 3563
Posts: 18,026
Join Date: Oct 2010
Problem is that the users who read how to backup EFS folder fall in to two category s those that read up first and would have backed up EFS and those that only pick the manual up after something is broke .
This script would be a saver for many of the second group and big thanks to Paul and i hope devs do run with it .

jje
 
brainmaster
Old
(Last edited by brainmaster; 18th August 2011 at 07:03 PM.)
#6  
brainmaster's Avatar
Recognized Developer
Thanks Meter 3993
Posts: 3,711
Join Date: Dec 2006

 
DONATE TO ME
I would like to adapt your script for Nexus S.

Once i got the img file of efs partition, how do can a make a script for restoring thet img file to efs partition?

Or what to do with that img file?

EDIT: @ paul - One more question - how do I mount /sdcard on Nexus S through the script? mount command in the Terminal Emulator shows my /dev/blocks/vold/179:3 as mount point, but if I use that mount point in the script it won't mount the /sdcard. Any idea?

EDIT2: I got it working with this command:

mount /dev/block/platform/s3c-sdhci.0/by-name/media /sdcard

and I got the efs.autobackup.img on my sdcard.

How do I restore the efs.autobackup.img to efs partition?
 
mynamesteve
Old
#7  
mynamesteve's Avatar
Recognized Contributor
Thanks Meter 210
Posts: 858
Join Date: Mar 2009
Location: Derby
Thanks Paul this is a very useful utility hope it gets sticky

May i ask what conditions these people are falling foul of getting the EFS wiped? Is it rouge roms/cwm zips, wiping to much in recovery, Odin flashing?

Curious so i may steer clear, have a backup but staying away is half the battle
 
brainmaster
Old
#8  
brainmaster's Avatar
Recognized Developer
Thanks Meter 3993
Posts: 3,711
Join Date: Dec 2006

 
DONATE TO ME
Quote:
Originally Posted by paulobrien View Post
You can download the script here - http://cl.ly/2j0p0R3F07052m2T2u0e - but it's very simple, here's the code...

Code:
#!/system/bin/sh
# EFS auto backup script for Samsung Galaxy S II
# By @paulobrien - http://s2.MoDaCo.com

mount /dev/block/mmcblk0p11 /sdcard

if [ ! -f /sdcard/efs.autobackup.img ];
then
        dd if=/dev/block/mmcblk0p1 of=/sdcard/efs.autobackup.img
fi

umount /sdcard
Hi Paul, I have modified your script so that it makes a tar file, tar file keeps the permissions for the efs partition and its easier to restore. Here it is:

Code:
#!/system/bin/sh
# EFS auto backup script for Samsung Galaxy S II
# By @paulobrien - http://s2.MoDaCo.com

mount /dev/block/mmcblk0p11 /sdcard

if [ ! -f /sdcard/efs_autobackup/efs-backup.tar.gz ];
then
  mkdir /mnt/sdcard/efs_autobackup
  busybox tar zcvf /sdcard/efs_autobackup/efs-backup.tar.gz /efs
fi

umount /sdcard
 
pulser_g2
Old
#9  
pulser_g2's Avatar
Developer Admin / Elite Recognized Developer
Thanks Meter 8063
Posts: 18,419
Join Date: Nov 2009
Location: United Kingdom Likes: Galaxy Note 2 Dislikes: Noobs
Quote:
Originally Posted by mynamesteve View Post
Thanks Paul this is a very useful utility hope it gets sticky

May i ask what conditions these people are falling foul of getting the EFS wiped? Is it rouge roms/cwm zips, wiping to much in recovery, Odin flashing?

Curious so i may steer clear, have a backup but staying away is half the battle
Some hit "wipe EFS" in ODIN.

It's possible to mess up a zip badly enough to wipe EFS

A normal wipe shouldn't do it, but a bad CWM build could in theory do it...

A dodgy "virus" could do it, if it were targetting rooted phones, or had a root exploit.

That's why I keep an EFS backup on my PC and off-site


Having trouble getting an answer? | What is XDA about? | How to ask for help?

if [ $PM.incoming.type = $type.question.ROM.how_to_use ] || [ $PM.incoming.type = $type.question.ROM.silly_question ]; then mv $PM.incoming /.trash; PM.response($responsetype.ignore); $PM.sender.ignore_in_future=true; init.sequence($boy_who_cried_wolf); fi;


If you wish to apply for one of the Recognized Themer/Contributor titles, or have a question, please DO NOT send me a PM about it. Instead please contact your device's forum moderator, or a senior moderator, who will deal with your application. Thanks
 
Odia
Old
#10  
Odia's Avatar
Recognized Developer
Thanks Meter 676
Posts: 653
Join Date: Jan 2009
Location: FEED0002 & CAFE0018

 
DONATE TO ME
Quote:
Originally Posted by brainmaster View Post
Hi Paul, I have modified your script so that it makes a tar file, tar file keeps the permissions for the efs partition and its easier to restore.
Nope dd is much better, but safer to have both, but dd should be used with bs=4096k option.

 
Post Reply+
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...

XDA PORTAL POSTS

Boot Animation Paradise for your Android Device

The default boot animations on any device, no matter whichmanufacturer, are generally pretty … more

Flash Custom ROM and Recovery to Samsung Galaxy S 4

After reading about Dan Rosenberg’s bootloader exploit for the Samsung Galaxy S 4,I … more

Windows-Based Multi-Tool for the Sony Xperia U

If you are a flashaholic and an owner of the Sony Xperia U, you may be interested in the … more

XDA University: Crafting Recovery-Flashable Packages

Those of us who use Linux on a day to day basis don’t think twice about sinking … more