Android: Can someone explain to me its folder structures?

Discussion in '*nix Software' started by lopri, Dec 13, 2012.

  1. lopri

    lopri Elite Member

    Joined:
    Jul 27, 2002
    Messages:
    12,032
    Likes Received:
    84
    The whole root, system partition, sdcard thing confuse me. As you will see I am a total noob in this area so please bear with me and hopefully someone will educate me.

    I have heard some people talking about moving their applications to sdcard to save space in the system partition (is that the correct term?). I do not know what that means so I decided to see for myself, and gained root access in my Nexus 7. Browsing the folder structure, I am completely lost because I have no idea which is which. I tried to draw what I am trying to learn about;

    [​IMG]

    1. /sdcard/ (along with /root/ directory and other system-level directory)
    2. /storage/emulated/0/
    3. /storage/emulated/legacy/
    4. /storage/sdcard0/

    Prior to root access, I believe I was looking at #2, which would be /storage/emulated/0/. That's where I saw some application folders as well as data folders. Upon gaining root access, however, I found three more folders that seem to contain identical contents.. I suppose they are not duplicates (four copies of everything?), but I am terribly confused.

    My questions (for now):

    - What are these 4 for? And which one is "real" in a physical sense? (does it even make sense to refer it as "real" instead of "shortcuts" or "aliases"?)
    - Which one is the system partition, or ROM? Are they referring to the same thing?
    - Which one is "external storage"? Do "external storage" and "sdcard" mean the same thing? And which is "internal storage"?
    - When people talk about moving stuff to sdcard (e.g. "app to sdcard"), which one is the starting point and which one is the end point?

    Obviously appreciated.
     
    #1 lopri, Dec 13, 2012
    Last edited: Dec 13, 2012
  2. Loading...

    Similar Threads - Android explain folder Forum Date
    The completely unofficial Android-x86 thread *nix Software Feb 22, 2015
    How to build an OS like Android but for an e-ink based e-reader? *nix Software Feb 24, 2014
    Debian 7 on Android phone *nix Software Aug 22, 2012
    DNLA, Pulse and android *nix Software Jan 2, 2012
    Explain this one! *nix Software May 30, 2009

  3. lxskllr

    lxskllr Lifer

    Joined:
    Nov 30, 2004
    Messages:
    45,792
    Likes Received:
    333
    That's different from my current, and previous tablets. Both of mine have /mnt/sdcard and /mnt/extsd

    /mnt/sdcard is builtin(extra) storage, and /mnt/extsd is a removable sdcard. I'd guess /sdcard is the proper place, but I don't know for sure.

    Edit:
    BTW, if you want to manipulate files on the device itself, GhostCommander will let you manipulate files as root as long as you have root access. It gives a nice dual pane commander-like interface

    http://f-droid.org/repository/browse/?fdid=com.ghostsq.commander&fdpage=7

    ^^^That's the main repository I use for apps. It's sparse compared to Play store, but it's all libre apps that have source code available. Most are completely clean, but three's a couple that have hindrances. They either track, or have ads. Those are very few, and clearly marked though. I guess someone just has to rip out the offending bits.
     
    #2 lxskllr, Dec 13, 2012
    Last edited: Dec 13, 2012
  4. lopri

    lopri Elite Member

    Joined:
    Jul 27, 2002
    Messages:
    12,032
    Likes Received:
    84
    I have a Nexus 7, and it doesn't have any slots for external/removable sd cards. Yet people refer certain part as "internal storage" (system partition, or ROM?) and "external storage" (which was another confusion that I understood quickly)
     
    #3 lopri, Dec 13, 2012
    Last edited: Dec 13, 2012
  5. lxskllr

    lxskllr Lifer

    Joined:
    Nov 30, 2004
    Messages:
    45,792
    Likes Received:
    333
    My "internal" storage is /data/app
     
  6. postmortemIA

    postmortemIA Diamond Member

    Joined:
    Jul 11, 2006
    Messages:
    7,584
    Likes Received:
    14
    there's separate partition where apps are installed by default, and that is never on external card but on the internal.
     
  7. lopri

    lopri Elite Member

    Joined:
    Jul 27, 2002
    Messages:
    12,032
    Likes Received:
    84
    Thank you for the suggestion but I do have a file/folder manager. I am not trying to manipulate files (yet), but rather trying to understand what I see.. Right now I don't even understand what exactly /sdcard/ means. (internal? external? emulated?)
     
  8. lopri

    lopri Elite Member

    Joined:
    Jul 27, 2002
    Messages:
    12,032
    Likes Received:
    84
    Which one would it be, among the 4 I found? Is it #1? (system partition) Where is the line drawn? And why "emulated"?

    The thing is, I see exact same contents in all 4 folders I listed. (I could be wrong since I did not check one by one, but they looked the same to me)
     
  9. lxskllr

    lxskllr Lifer

    Joined:
    Nov 30, 2004
    Messages:
    45,792
    Likes Received:
    333
    I spoke wrong earlier. My root apps(ROM) are in /system/app, and downloaded apps are in /data/app

    I still don't know about the rest of your setup :^D
     
  10. lopri

    lopri Elite Member

    Joined:
    Jul 27, 2002
    Messages:
    12,032
    Likes Received:
    84
    OK I took screenshots. Big pictures below.

    This is as deep as I can go with root privilege. Note /sdcard/ and /storage/ are here together, as well as /system/. (is /sdcard/ system partition, and /storage/ external storage?)

    [​IMG]

    And from here, when I go to /sdcard/, I see this (which is #1 in my origianl thread. Check the top tree).

    #1 [/sdcard/][​IMG]

    If I go to /storage/ from the first screen, I see this.

    [​IMG]

    Then

    #2 [/storage/emulated/0/]: [​IMG]
    #3 [/storage/emulated/legacy/]: [​IMG]
    #4 [/storage/sdcard0/]: [​IMG]
     
    #9 lopri, Dec 13, 2012
    Last edited: Dec 13, 2012
  11. lxskllr

    lxskllr Lifer

    Joined:
    Nov 30, 2004
    Messages:
    45,792
    Likes Received:
    333
    I dunno man. Android is a different beast than GNU/Linux. I was starting to get into it early this year, but broke my tablet, so I quit playing with it. I never got to understanding how it all goes together. I'm wondering how much it varies per manufacturer, because my setup isn't like that.

    If you don't get any love here, you may want to read some Android specific forums. If you go that route, take some time to learn before you ask questions. There's a lot of noobs with Android devices, and they get in the forums and ask questions that were answered on the same page they were asking on. It's easy to burn out the people with knowledge when they get asked the same questions over and over. I knew almost nothing, and I was getting burned out repeating what little I did know. You should be able to find some good stuff here...

    https://www.xda-developers.com/
     
  12. vshah

    vshah Lifer

    Joined:
    Sep 20, 2003
    Messages:
    18,981
    Likes Received:
    16
    all the weird /emulated/0 stuff is a result of the new multi user profiles in 4.2.
    you'll see what appear to be the same files in several different places. i think it's using a lot of symlinks or something, and it swaps them out when you swap user profiles.

    of course, the multi user profiles aren't enabled on the Nexus 4, only the Nexus 10. so us N4 users just get stuck with the weird folder structure.
     
  13. lopri

    lopri Elite Member

    Joined:
    Jul 27, 2002
    Messages:
    12,032
    Likes Received:
    84
    vshah, could you enlighten me as to the following?

    - When people talk about "internal storage" and "external storage" (think of an app like app2SD), which folder is "internal storage" and which folder is "external storage" in Jelly Bean? Of course we're not talking about removable disks or SD slots.

    - Is it correct to view that some of these folders are indeed partitions on the volume? In other words, unlike alphabets in Windows (e.g. C: drive, E: drive, etc,.) Android uses folders to denominate partitions (mounted, perhaps?)? (but they are actually partition on the disk of Android device?)

    - Is it correct to view, both the internal storages and external strages exist on same physical disk, just in different partitions? Or perhaps they are separated by different NAND memory chips? Do you happen to know how much internal storage is reserved in Android?

    - Is it correct to view, the folders that I had access to prior to root access (in my case that was /storage/emulated/0/ ) is an external storage, considering that I had the total control of it? So if I use a tool such as "app2sd," that is where the app2sd will try to move stuff to?
     
    #12 lopri, Dec 14, 2012
    Last edited: Dec 14, 2012
  14. lopri

    lopri Elite Member

    Joined:
    Jul 27, 2002
    Messages:
    12,032
    Likes Received:
    84
    Or is it the opposite? If you look at the first screenshot I posted earlier,

    [​IMG]

    You can see

    /sdcard/
    /storage/
    /system/

    Again, the screen seen above is the highest at the folder hierarchy with root access in my Nexus 7. If you were to guess, which one is which (a partition, a folder, an internal, an external, etc,.?)

    If I were to guess that /sdcard/ is external storage partition, and /system/ is a folder residing in /storage/, which is an internal storage partition - does it sound plausible?
     
  15. vshah

    vshah Lifer

    Joined:
    Sep 20, 2003
    Messages:
    18,981
    Likes Received:
    16
    on nexus devices since the nexus S, there is only one partition.

    /sdcard, /storage/emulated/0 etc. are all pointing to the same place, and that is the "sdcard" or "External storage" as far as apps are concerned.

    "internal" storage is everything else you see at the top level:
    /data - apps are installed to /data/app and store their data in /data/app-asec among other subfolders.

    /system contains components of the android OS. /system/app contains system apps like the launcher. you'll find your SU binary in /system/xbin


    it doesn't make any sense to use apps2sd on a nexus device, since it's all one partition. you can fill up the "internal storage" part, or you can fill up the "external storage" part, it makes no difference.
     
  16. imagoon

    imagoon Diamond Member

    Joined:
    Feb 19, 2003
    Messages:
    5,199
    Likes Received:
    0
    This function is built in to Android. You do it in the app management section of the GUI. You don't have to root the system or do anything in the file system.

    App management -> click the app -> "Move to SDCard."

    As for the rest... Android FS is a maze and I can't offer anything there.
     
  17. vshah

    vshah Lifer

    Joined:
    Sep 20, 2003
    Messages:
    18,981
    Likes Received:
    16
    while it is built in, OP won't see it on his Nexus 7 since there's only one partition so moving an app to "sdcard" would have no effect on storage utlization.
     
  18. imagoon

    imagoon Diamond Member

    Joined:
    Feb 19, 2003
    Messages:
    5,199
    Likes Received:
    0
    Well ok, then what is the point of the OP request? Also I think the proper term is "one mount point." My Nexus has 1 partition with /sdcard mounted to the internal storage chip.

    Anyway my original question stands. I would be interested to see the fdisk list out from a terminal emulator.
     
  19. lxskllr

    lxskllr Lifer

    Joined:
    Nov 30, 2004
    Messages:
    45,792
    Likes Received:
    333
    I think it gets slow if the file system gets too full, but I don't know how much "too full" is. I've been moving my apps to the root partition. Deleting a bunch of default apps, and putting my own in.
     
  20. lopri

    lopri Elite Member

    Joined:
    Jul 27, 2002
    Messages:
    12,032
    Likes Received:
    84
    I did some reading today and vshah, I thank you very much. Your post (#14 specifically) cleared a lot of things that I was confused about. And your explanation totally makes sense. (obviously, since you're stating facts) No wonder I did not see any kind of physical partitions with those low-level diagnostic tools.

    I am still digesting and "indoctrinate" myself on this new knowledge. I am likely to have more questions, but I want to thank everyone trying to help me. Again, I am not done and will probably (more like definitely) have further questions.
     
  21. vshah

    vshah Lifer

    Joined:
    Sep 20, 2003
    Messages:
    18,981
    Likes Received:
    16
    No worries, the new folder structure threw me for a loop when I first encountered it as well
     
  22. rileyrg

    rileyrg Junior Member

    Joined:
    Oct 20, 2013
    Messages:
    2
    Likes Received:
    1
    If you dont know, then why reply? It stuff like this that litters google and pollutes it with false leads.
     
  23. lxskllr

    lxskllr Lifer

    Joined:
    Nov 30, 2004
    Messages:
    45,792
    Likes Received:
    333
    Awe, did someone come here expecting to be spoon fed, and left empty handed? Sucks having to put in effort, doesn't it? That thinking stuff is hard.

    This is a discussion forum. Truth is found by bouncing ideas around, and narrowing possibilities to the fewest. It isn't your personal free help desk. if you want personal support, you're free to pay someone for it. If you want discussion, and a degree of self help, you join a forum.
     
  24. 000_Cthulhu_000

    000_Cthulhu_000 Junior Member

    Joined:
    Nov 28, 2013
    Messages:
    1
    Likes Received:
    0
    I'm gonna bump this one as a new user and get it back on track.

    I'm having the same curiousities as the OP.

    My file structure on my Galaxy Nexus, 4.3 Jelly Bean is exactly the same.

    My 'abnormality' is that I am still working with Windows Vista (...irk...:hmm:) and as windows explore displays it from My Computer - 'Internal Storage'.

    This I assume is the same with other people. As I browse through each file structure; comparing the Android that has;

    /sdcard/
    /emulated/0
    /legacy/

    ...etc...

    Windows has simply...a completely different appearance...what I mean is folders that don't exist on the above mentioned folder structure appear in Windows Explorer...this causes a nuisance with media and other files.

    I want to work around this and find the real 'internal storage' on the /root/ that Android does not display. I've also, read that it may be a seperate patition all together. Any thoughts...?

    PICTURES....!!!!

    https://www.dropbox.com/s/c9793o0elabnmcw/Windows.jpg

    https://www.dropbox.com/s/ea7hbew6rmcb6ya/Windows2.jpg

    https://www.dropbox.com/s/w71yknm6z2xk1p5/Screenshot_2013-11-28-11-34-24.png

    https://www.dropbox.com/s/i4u70jtoal5nt1o/Screenshot_2013-11-28-11-41-09.png

    https://www.dropbox.com/s/3jll4o284o9sggk/Screenshot_2013-11-28-11-42-46.png