• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

[Verizon] Additional work on the /sdcard/0 problem-solutions brewing

elfaure

Newbie
Hey-

Per the original post

http://androidforums.com/verizon-ga...t/649940-4-2-sdcard-sdcard-0-observation.html

Read Gapi's method of restoring CWMs and Nandroids. Seems pretty straight forward. You could create a script to recreate the 4.1 directory tree structure prior to restoring a pre 4.2 backup so it could find its data and targets. Then after restoring, you could recombine all data to /sdcard and make a new backup for 4.2 Its just file management automation and sure beats messing with it afterwards in my opinion. I'm on 4.1 and plan to stay here awhile so I can't test this theory but it *should* work. You could use the same technique for all your mountpoints like /data/media and data/media/0.

To see all your mountpoints

Code:
mount

And to find all your /* and /*/0 pairs (the return is only the /*/0 directories but assuming you don't have any default /*/0 directories [I don't] this will work)

Code:
find */0

or you could expand on this code concept if you're already tripple nested before you figured out what was happening in 4.2

Code:
find */0/0/0

Example for /sdcard and /sdcard/0:

Code:
#!/system/bin/sh
     #Make tmp backup of existing sdcard on external SD
mkdir /Removable/MicroSD/sdcard_tmp
cp -r /sdcard /Removable/MicroSD/sdcard_tmp
     #Copy /sdcard/0 to /sdcard.  This will over write /sdcard and its symlinks. If
     #you want to retain symlinks then change r to R.
cp -rf /sdcard/0 /sdcard
[restore_your_files(ROMs, Nandroids, Recoveries)]
     #Combine backup of existing sdcard and sdcard/0 in /sdcard
cp /Removable/MicroSD/sdcard_tmp/*.* /sdcard
     #Remove tmp backup of pre-existing sdcard on external SD.  If you
     #want to save this directory instead, add a "#" without the quotes before
     #the next line.  Also make VERY sure you don't add a space after "/" and before
     #"Removable/..." below or you will * WIPE * your device if / (root dir) is mounted rw!!!
rm -rf /Removable/MicroSD/sdcard_tmp
[backup_your_files]
 
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_version

Now 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.

[Ref] **********************************[Ref]****************************************[Ref]

And for those of you that are already "nested" with /0 directories, I am working on a script to resolve this and put all your stuff back into /data/media from /data/media/0....or maybe I will change it to work with only /data/media/0/0.... situations merging all to /data/media/0, not sure, need some more 4.2 "find */0" info to decide what to do with it.

These are key code lines (thanks to becomingx, XDA guru) in a script I am working on to help automate the process of finding the /0 nested directories then create variables I can use in paths to move files around accordingly. A FULL Busybox must be installed to run this code.

Code:
VAR="$(find */0 | sed -e 's!/0!!g' | sort -u)"

Code:
VAR1=""
for i in $(find */0); do
  if [ ! -d $i/0 ]; then
    VAR1="$VAR1 $i"
  fi
done

And here's the entire script (not tested yet, still working on it)

Code:
#!/system/bin/sh

VAR="$(find */0 | sed -e 's!/0!!g' | sort -u)"

VAR1=""
for i in $(find */0); do
  if [ ! -d $i/0 ]; then
    VAR1="$VAR1 $i"
  fi
done

for OBJ in $VAR and OBJ1 in $VAR1; do
   #Backup $OBJ to SD
   mkdir /Removable/MicroSD/$OBJ_BAK
   cp -r /$OBJ /Removable/MicroSD/$OBJ_BAK
   #Over write $OBJ with $OBJ1
   cp -rf /$OBJ1 /$OBJ
   #Merge backup and $OBJ
   cp /Removable/MicroSD/$OBJ_BAK/*.* /$OBJ
   #Remove $OBJ backup
   rm -rf /Removable/MicroSD/$OBJ_BAK
done

[Edit] Bummer. I just found out I cannot code two variables together like that on one line. Everything after the first "in" gets treated like the first variable. I am looking into using 2 parallel arrays instead. For only my second script (and my first one was a whopper too), this one's kicken my a%$ right about now.

Quoted from Androidspin.com -

"With Android 4.2, Google introduced multiple users as a new feature. In order to accommodate multiple users, Google is now giving each user a their own folder for storage. If you upgraded to 4.2 from 4.1, then the 4.2 ROM will look for a certain file in /data to determine whether it needs to migrate all of your files to the new multi-user data structure. By default, 4.2 migrates all of /data/media to /data/media/0.

A problem arose though with custom recoveries. A custom recovery retains the /data/media folder during a factory reset. When you factory reset and then boot a 4.2 ROM again, the 4.2 ROM will migrate everything in /data/media again. It will migrate your files every time you factory reset. This multiple migration is what resulted in some people having their files moved to /sdcard/0 or even /sdcard/0/0 etc.

In TWRP 2.3.2.0 we have corrected this problem by ensuring that we do not delete the special file during a factory reset. However, if ended up having your files upgraded you will need to move or merge them back into /sdcard. Also, if you have moved your TWRP folder from /data/media/0 to /data/media so that you could restore backups while using prior TWRP versions, you may now need to move the TWRP folder back into /data/media/0.

What is a data media device? | TeamWin

https://github.com/TeamWin/Team-Win-Recovery-Project/blob/twrp2.5/partition.cpp#L1349
 

Attachments

+1 ^^^ this. The stuff you're coming up with is pretty far above my pay grade, keep it up. I'm also watching your thread here:

http://forum.xda-developers.com/showthread.php?t=2264643&page=3

and hope that when you get a final conclusion you post it in this one.

But does anyone mind if I delete (or ask to be deleted) the two or three posts right after my last one to keep this thread uber clean?

Hey guys this is your thread on your device forum. I'm the one that hijacked your 6 month old thread (but revived it) because it had the most info on the topic I found doing a quick Google search. Your devices came out with the 4.2 update before ours so initially I was learning about this here then cross searching XDA for more info. So you can do whatever pleases you with any part of this thread. In fact its been difficult for me to keep up with the cross posting and you only are getting half the info this way too.

I think it would be best for you to clean this up or move it to a new thread, maybe keep some of the topic discussion and preliminary code as a teaser, then post a cross-link over to the XDA thread. That would be much better for everyone then you can learn what I learn from the horses mouths and you will realize I'm simply the idea guy, pretty much a nOOb myself, but I do have excellent resources to get things done.

Its my XDA buddies who are the best at this and very helpful I might add, and they throw down the mean sed code and amaze me by solving some pretty complex problems with what looks like a single line of syntax that a 4 year old with a blind fold on might type if given a keyboard to play with. I'm convinced at least two of these guys could halt world trade armed with nothing but a smartphone. I've been working with a few of the smartest Android guys you will ever know and they've been gracious enough to help me with numerous things and given me 2 years training in about 3 months. I remember rooting my device back in Feb. '13 and that was the first time I ever used the terminal. I typed "cd /system/xbin" then "ls -al" and saw my su and was hooked from then on. Then I got sick of typing in all those commands so I started scripting. Back in the day I used to spend hours and hours optimizing autoexec.bat and config.sys and QEMM so I have some PC background that allowed me to pick things up quickly with Android.

So why don't you do what you need to do and cross-link back to XDA and I will work on it there and post something final when its done. Also I suggest you check-out my "Multi-Browser2RAM startup script" that replaces Browser2RAM (that's what I will title the new post). Its my first script and its a big hit since it works with 4.2 and B2R doesn't. I guess I'm sloppy because they've asked me to clean that up and make a dedicated thread for it. Its now buried in another thread like this one. I will post a link to it when I get it organized or you can search XDA for my posts and find it too. Just do my a favor and don't delete this thread in its entirety as I am subscribed. Also, if you move this discussion please drop a link here to the new location so I can find it.

************************************************************************************************

[Teaser] Works with Stock, Boat, Dophin, Chrome, Firefox, and Naked browsers. Makes them all haul a$$. I can run about 20 -30 tabs in Chrome with a 100MB RAM cache after loading my script and it doesn't bog a bit. It makes my 3G tether feel like 4G. Its what gave me XDA recognition and allowed me to befriend the gurus who are making this script possible. When I get into a jam, its not for long with these guys in my contacts.

Script here:

http://forum.xda-developers.com/showthread.php?t=2273973
 
Good job. I am subscribed to both the new and the old threads on this. Keep checking over at XDA on any progress. I've been busy with my Multi-browser script for the past few days but I'll get back on this one.

After viewing some of the output structure this one might be more tricky than I originally thought. One guy with a multi-rom had nested /0 directories at multiple levels with regular directories in between the nests in his tree. Not sure I can code a generic solution that will work for everyone after seeing that. I need to think real hard on this now.
 
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_version

Now 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.

Hi new here
I have had CM10.1 on my galaxy tab 10.1 and was a bit disapointed with the file system so put the stock rom back.
I gave rooted the rom and have latest CMRecovery installed.

I want to try this now and reinstall CM10.1 but need to ask a few questions please.
1. Can this be done from a stock rooted rom? I want to go from stock 4.0.4 rooted to CM10.1.
2. When I download this file there is no dot . before the filename...must I put it in?
3. Does this mean we should not format /data during the full wipe process? or should I just wipe cache and dalvic?
Thanks mate, will let you know how it goes
 
Hi new here
I have had CM10.1 on my galaxy tab 10.1 and was a bit disapointed with the file system so put the stock rom back.
I gave rooted the rom and have latest CMRecovery installed.

I want to try this now and reinstall CM10.1 but need to ask a few questions please.
1. Can this be done from a stock rooted rom? I want to go from stock 4.0.4 rooted to CM10.1.
2. When I download this file there is no dot . before the filename...must I put it in?
3. Does this mean we should not format /data during the full wipe process? or should I just wipe cache and dalvic?
Thanks mate, will let you know how it goes

Hey there. Lets see if this works or not. We later discovered a hidden character after the "2" in the file which is NOT in the file you downloaded nor have I had the chance to figure out how to add it, but I think the install will just look for file presence, not actually read the file contents. It may check file size which then could be a problem. I think the worst that could happen is it would fail to see the file then migrate all of your /data/media to /data/media/0 which is what happens by default anyway.

So you are clear, the only purpose of this file is to try to prevent the creation of a multi-user environment and retain /data/media as your mountpoint for sdcard without making a second copy of it in /data/media/0 thereby cutting your sdcard in half for the second user.

I don't have a Samsung device so you will have to speak generic Android to me. 4.0.4 sounds like your Android version and you want to go to CM10.1 (CyanogenMod). No problem. But your recovery is CWM (not CM; ClockworkMod) and that is a problem, at least on my device (Asus TF700T Transformer Tablet). Its recommended to use TWRP 2.5 for recovery as CWM can wipe the wrong partition and leave you SOL, possibly bricked so I discourage its use all together. Doing this all from rooted stock and wiping before installing your new ROM is recommended.

If you insist on using CWM make sure its the latest version and I would suggest not wiping /data/media just to be safe. I would also backup all of /data/media before doing anything. In ALL cases, make a full normal user app and data backup (My Backup, System Tuner, any Gplay Backup app), and a Titanium or Online Nandroid backup. Search on the market for these apps if you don't already have them. The file needs to have the dot before the filename. That is strange to me its not there after you downloaded it but sometime characters and line ends are stripped during the download process. Best way to download is long-click the file. Are you looking at it from the device or the PC? The dot before the filename tells Android its a hidden file so look at it on a PC to make sure you need to add back the dot. Make sure on your device you are showing hidden files.

If its successful then you should not have a /data/media/0 folder when you are done (unless you already have one now - check). If you already do, then this file should already be on your system, don't overwrite it with this one, and prevent further migration (ie: creating /data/media/0/0). Let me know how it goes!
 
Hi guys. Good info here, but it's a bit overwhelming. :D

I ran into problems on my Galaxy Note II when I flashed some roms 4.1 and 4.2 roms. I'm on 4.2 right now but would like to try a 4.1 rom that includes the Touchwiz S-Pen features. I've backed up my sdcard and am going to return to my stock nandroid and see where that leaves me.
 
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_version

Now 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.

Well, I know I am bringing up some old thread but I thought I'd weigh in and say that the file attached in this post did not prevent the creation of the /data/media/0 directory.
 
Back
Top Bottom