Flashing an 4.2.2 rom and file structure issue.

smatherlee

Senior Member
Mar 5, 2011
746
418
0
Behind my M24 (Retired)
I decided to start this thread as both assistance for some as well as a collaberation on workarounds when you a person flashes a 4.2.2 rom coming from a 4.1.2.

Just like some (maybe most) I flashed CM 10.1 and played around a bit with it and decided it was just not ready to be run as a daily. Being the flashalohic that I am, I made sure I backed up before flashing CM 10.1 so when I went into recovery and went to restore imagine my surprise when it was blank, yep nothing was there. Why did this happen? Well doing some research and reading/searching I found out that the update from Android 4.1.2 to 4.2.2 changes the file structure of the 'virtual' sdcard on our devices. Actually it changes it for every device. What has changed is that the ability to add user accounts, similar to any regular computer, has been implemented. However, if the proper steps are not taken before you flash a new 4.2.2 Rom, you will end up with a huge mess and run out of room on your device in a hurry.

The actual location when viewed with a root file manager has been here on 4.1.2:

/data/media

And though you will see the same files in /sdcard and /storage/sdcard0, those are just symlinks to the same info, just like a shortcut (on a windows box) or alias (on a mac box). Once you flash a 4.2.2 ROM, the actual location gets changed (and all the files moved) to here:

/data/media/0

And the symlinks get changed to /sdcard/0 and /storage/sdcard0/0. On the surface, no big deal, right? Wrong. The problems arise if the version of your custom recovery is not compatible with a 4.2.2 ROM. If it is not and you keep flashing 4.2.2 ROMs you might soon end up in trouble. If, while using the 'older' custom recovery, you continue flashing, your sdcard ends up somewhere around here:

/data/media/0/0/0/0/0/0 (etc.) with all your files copied to every '0' directory and your symlinks end up the same way, and your device quickly runs out of space (the dreaded "your device is low on storage" message).

This may also make it very difficult to restore your nandroid of a 4.1.2 ROM as well. If you are already in that situation, not to worry, the solution for that is later in this post.

So far I have only been able to to copy all the files found in the last /data/media/0/0/0/0 (?) folder to my computer. Then using a file manager that will show hidden files and folders, copy/move the files in the last '0' directory to:

/data/media/0

And then use file explorer to delete all the other '0' directories until I have just this one:

/data/media/0

leaving nothing else in the symlinks but /sdcard/0 and /storage/sdcard0/0. This techniques is if you end up with a huge file structure.

****BACK UP YOUR SD CARD FIRST!!!!! before deleting any 0 folders!!!****

NOTE: A reboot of your device is essential at this point.


If after flashing a 4.2.2 ROM you decide you don't like it and want to restore your nandroid to your saved 4.1.2 ROM, how does that work out?


1.) Get yourself a (good) root file browser.
2.) Brows to /data/media/0
note: this is where android (and almost everything else that uses a Linux kernel) mounts anything that is considered "external" storage.
3.) Do all of your file fixing from here. It will make changes universally.
4.) select all within /data/media/0 and then paste everything back into /data/media selecting merge and/or overwrite. Once done, just delete the /data/media/0 folder, reboot your phone and Profit.

This is a pain and I agree but at this point is the only way I know how to get around this. If anyone knows other ways please share.

* While writting this I came across this info from user elfaure. I havent tried this yet as I am at work and get crappy signal but please post results if you try and if it works, please thank him! *

elfaure: Ok folks for next guy who decides to upgrade to 4.2 but does NOT want the multi-user environment, give this a try.

1. Download the attached file
2. Remove the .txt extension
3. Copy it to your /data directory
4. Open Android Terminal Emulator (Free Market app if you don't already have it)
5. At the prompt type "cd /data"
6. Type "chmod 644 .layout_version" on the file in /data (/data/.layout_version)


Code:
cd /data
chmod 644 .layout_versionNow when you upgrade to 4.2 you should stay single user and have no /data/media/0 directory when you are done. If anyone tries this please let me know if it works and thank me if it does.

ps-its just a special file in a special location, the presence of which tells Android NOT to upgrade your system to a multi-user environment. If you later decide you want multi-users, delete the file and reflash (from recovery) the stock or custom firmware or ROM or recovery. If your custom ROM or recovery wipes the entire /data partition less /data/media including this file, obviously then this will not help, but with latest versions of ROMs and recoveries that should not happen any more.

http://forum.xda-developers.com/showthread.php?p=40911246#post40911246

It also looks as if he may be working on a script to help as well and I will keep track and update as needed.


So far this is what I have come up with and I hope it helps some and I hope others that are smarter than I can correct me if I am wrong on any of the above or other add information on other ways to correct this.
 

Attachments

Jun 11, 2010
27
3
0
Golden, CO
I think this is part of my issue but I don't have any 0 folder under data?

I too flashed the 4.2.2 ROM, and noticed that every everything on my sd card had somehow moved to my internal memory? When I went to reflash the ROM it failed. It I also tried to reflash the ROM I was originally running and it too failed. Luckily I was able to do a nandroid restore so the phone is "usable" but TWRP 2.5 still does not see my my external sd and that seems to be that make reason I can not do anything within in the recovery.

Any suggestions?
 
Jun 11, 2010
27
3
0
Golden, CO
I think this is part of my issue but I don't have any 0 folder under data?

I too flashed the 4.2.2 ROM, and noticed that every everything on my sd card had somehow moved to my internal memory? When I went to reflash the ROM it failed. It I also tried to reflash the ROM I was originally running and it too failed. Luckily I was able to do a nandroid restore so the phone is "usable" but TWRP 2.5 still does not see my my external sd and that seems to be that make reason I can not do anything within in the recovery.

Any suggestions?
Let my clarify:

I have used two different file managers and even used to terminal emulator using ls -la to make sure i have no hidden files

sdcard0/data/ there is no media directory

Maybe this isn't my problem, since I don't see any file/dir with a 0, but all this mess started when I loaded up a 4.2.2 ROM?
 

smatherlee

Senior Member
Mar 5, 2011
746
418
0
Behind my M24 (Retired)
I couldn't get it to work, the attachment. However the new recovery I linked to looks to have promise but I haven't tested it yet cause I'm remote right now and need my phone at the moment. Will give it a go this weekend.

Sent from my HTCONE using Tapatalk 2
 
R

Rirere

Guest
Weighing in, worked like a charm for the most part. TWRP recreated another TWRP folder inside its original TWRP folder (it has to be left at /data/media/0/TWRP for you to be able to reinstall a nandroid backup) [also forgoing obvious yo dawg joke here], but besides that my phone is back to being right as rain.
 

Darkryft

Member
Jun 27, 2010
26
4
0
I'm sure it wouldn't work for doing a nandroid restore, but on my Galaxy Nexus I would just make certain I had the latest version of TWRP, boot into recovery, format the SD card, and then push the rom files to /data/media/ and flash. That is my only complaint about this change, really...truly "clean" installations are inherently more risky or difficult, dependent on your knowledge level.
 

Bseagull

Senior Member
Jul 2, 2013
171
19
0
I think it moved my ROM data into the 0 folder, how do I get it out? Everything else from the 0 folder is deleted except for ViperROM's folder, and whenever I try to move or delete it, it just fails the operation. I already have a copy out of the 0 folder, but I still want it out, because otherwise I can't flash things, since it just shows the the almost* empty sdcard/0 folder. Help? Should I just put my mods in the 0 folder and deal with it?
 

smatherlee

Senior Member
Mar 5, 2011
746
418
0
Behind my M24 (Retired)
I think it moved my ROM data into the 0 folder, how do I get it out? Everything else from the 0 folder is deleted except for ViperROM's folder, and whenever I try to move or delete it, it just fails the operation. I already have a copy out of the 0 folder, but I still want it out, because otherwise I can't flash things, since it just shows the the almost* empty sdcard/0 folder. Help? Should I just put my mods in the 0 folder and deal with it?
No. There is a script out there you can flash that will help. Check out post # 10.

Sent from my One using Tapatalk 4
 

ivwonka

Senior Member
Sep 9, 2008
483
97
0
Kansas City
So can we delete the legacy file now? I haven't done anything with my internal storage since coming from 4.1.2 for the first time. It looks like twrp 2.6.3 copied all my files correctly to the 0 file but all the files are still also in "legacy" folder. Is it duplicate that I can delete from legacy or are they just symlinked? I am never going back now that we have official 4.3 release.
 

smatherlee

Senior Member
Mar 5, 2011
746
418
0
Behind my M24 (Retired)
So can we delete the legacy file now? I haven't done anything with my internal storage since coming from 4.1.2 for the first time. It looks like twrp 2.6.3 copied all my files correctly to the 0 file but all the files are still also in "legacy" folder. Is it duplicate that I can delete from legacy or are they just symlinked? I am never going back now that we have official 4.3 release.
I am not certain to be honest. It looks like the file structure didn’t change with the release of 4.3 so it’s possible that they are symlinked. If all your files are moved to the /0/ folder and you have nothing in the legacy folder it would make sense that you would be able to but I have yet to test this.

I suppose this weekend I could back up the phone and file tree and give it a shot
 
  • Like
Reactions: ivwonka