Monday, March 6, 2017

internal storage - Confused by the many locations of the virtual /sdcard/


Some devices (like my Nexus 4) don't have an external slot for an SD Card. Instead, there's a root folder called /sdcard/ that is treated the same way. But I also find other paths that all point to the same files -- there must be some kind redirects going on (I think this is called symlinks in Linux).


All these paths contain the same files:


/sdcard/
/storage/sdcard0/
/storage/emulated/0/

/storage/emulated/legacy/

Which path is the "actual" one? What about the other paths? What are they used for, why do they exist?



Answer



Recommended lecture: Why did /sdcard/ turn into /sdcard/0/ with 4.2?.


In short: It has to do with the multi-user functionality introduced with Jelly Bean:



  • /storage/emulated/0/: to my knowledge, this refers to the "emulated MMC" ("owner part"). Usually this is the internal one. The "0" stands for the user here, "0" is the first user aka device-owner. If you create additional users, this number will increment for each.

  • /storage/emulated/legacy/ as before, but pointing to the part of the currently working user (for the owner, this would be a symlink to /storage/emulated/0/). So this path should bring every user to his "part".

  • /sdcard/: According to a comment by Shywim, this is a symlink to...


    • /mnt/sdcard (Android < 4.0)

    • /storage/sdcard0 (Android 4.0+)



  • /storage/sdcard0/: As there's no legacy pendant here (see comments below), the "0" in this case rather identifies the device (card) itself. One could, eventually, connect a card reader with another SDCard via OTG, which then would become /storage/sdcard1 (no proof for that, just a guess -- but I'd say a good one)


Though one might get to the conclusion there should be a /storage/sdcard/legacy as well, there isn't (see comments) -- which completely makes sense with my assumption of the numbers here are not related to the user, but rather to possible multiple cards: "0" would always be the one in the card-slot of the device, so no need for a "legacy symlink" here.


No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...