
Yes, the title is just a
scootch self-aggrandising, but I m rather chuffed
with myself at the moment, so please forgive me.
It all started with my phone (a regular Samsung Galaxy S3) suddenly refusing
to boot, stuck at the initial splash screen ( Samsung Galaxy SIII
GT-I9300 ). After turning it off and on again a few times (I know my basic
problem-solving strategies) and clearing the cache, I decided to start
looking deeper. In contrast to pretty much every other Android debugging
experience ever, I almost immediately found a useful error message in the
recovery system:
E:Failed to mount /efs (Invalid Argument)
Excellent! , thought I. An error message. Google will tell me how to fix
this!
Nope. The combined wisdom of the Internet, distilled from a great many
poorly-spelled forum posts, unhelpful blog posts, and thoroughly pointless
articles, was simple: You re screwed. Send it back for service.
I tried that. Suffice it to say that I will never,
ever buy anything from
Kogan ever again. I have learnt my lesson. Trying to deal with their
support people was an exercise in frustration, and ultimately fruitless.
In the end, I decided I d have some fun trying to fix it myself after
all, it s a failure at the base Linux level. I know a thing or two about
troubleshooting Linux, if I do say so myself. If I really
couldn t fix
it, I d just go buy a new phone.
It turned out be relatively simple. Here s the condensed version of my
notes, in case someone wants to follow in my footsteps. If you d like
expansion, feel free to
e-mail me. Note that
these instructions are specifically for my Galaxy S3 (GT-I9300), but should
work with some degree of adaptation on pretty much any Android phone, as far
as I can determine, within the limits of the phone s willingness to flash a
custom recovery.
-
Using heimdall,
flash the TeamWin recovery onto your
phone (drop into download mode first hold VolDown+Home+Power):
heimdall flash --recovery twrp.img
-
Boot into recovery (VolUp+Home+Power), select Advanced -> Terminal ,
and take an image of the EFS partition onto the external SD card you
should have already in the phone:
dd if=/dev/block/mmcblk0p3 of=/external_sd/efs.img
-
Shutdown the phone, mount the SD card on your computer, then turn your
EFS partition image into a loopback device and fsck it:
sudo losetup -f .../efs.img
sudo fsck -f /dev/loop0
With a bit of luck, the partition won t be a complete write-off and
you ll be able to salvage the contents of the files, if not the exact
filesystem structure.
Incidentally, if the filesystem was completely stuffed, you could get
someone else s EFS partition and change the IMEI and MAC addresses and
you d probably be golden, but that would quite possibly be illegal or
something, so don t do that.
-
Now comes the fun part putting the filesystem back together. After
fscking, mount the image somewhere on your computer:
mount /dev/loop0 /mnt
In my case, I had about a dozen files living in lost+found, and I
figured that wasn t a positive outcome. I did try, just in case,
writing the fsck d filesystem image back to the phone, in the hope that
it just needed to mount the filesystem to boot, but no dice.
Instead, I had to find out where these lost soul^Wfiles were supposed
to live. Luckily, a colleague of mine also has an S3 (the
ever-so-slightly-different GT-I9300T), and he was kind enough to let me
take a copy of his EFS partition, and use that as a file location
template. Using a combination of file sizes, permissions/ownerships,
and inode numbers (I knew the -i option to ls would come in handy
someday!), I was able to put all the lost files back where they should
be.
-
Unmount all those EFS filesystems,
losetup -d /dev/loop0, and put the
fixed up EFS partition image back onto your SD card for the return trip to
the phone.
-
Now, with a filesystem image that looks reasonable, it s time to write
it back onto the phone and see what happens. Copy it onto the SD card,
boot up into recovery again, get a shell, and a bit more
dd:
dd if=/external_sd/efs.img of=/dev/block/mmcblk0p3
-
With a bit of luck, your phone may just boot back up now. In my case,
I d done so many other things to my phone trying to get it back up and
running (including flashing custom ROMs and what have you) that I needed
to flash Cyanogen, boot it, and wait at the boot screen for about 15
minutes (I shit you not, 15 minutes of Gah is my phone going to
work?!? ) before it came up and lo! I had a working phone again. And
about 27 SMSes. Sigh, back to work
So, yeah, neener-neener to the collected wisdom of the tubes. I fixed my
EFS partition, and in the great, grand scheme of things, it wasn t even all
that difficult. For any phone which (a) allows you to flash a custom
recovery and (b) you can find another of the same model to play with, EFS
corruption doesn t necessarily mean a fight with tech support.
Incidentally, if you happen to have an S3 exhibiting this problem, but
you re not comfortable fiddling with it, I m happy to put your EFS back
together again if you pay shipping both ways. It s about a 5 minute job now
I know how to do it.
E-mail me.