Android File Structure explaination? - Asus Transformer TF700

This probably sounds like a total noob question, but its legit. I've become very comfortable with the Linux File Structure over the years as they are self explanatory.
/home - where home folders to users exist.
/root - OK, Don't know why it wasn't put in home, but understandable to what it is
/etc - config files go here
/lib - library files go here
/sbin - superuser binaries/executables go here.
/bin - binaries/executables
/usr - user shared files
/var - variable files such as logs?
I'm sure we get the gist of it, but why did android not keep this structure? Does android's structure better suite it? To me it just seems like crap is lying everywhere with barely any forethought as to where it should be placed. Could someone explain the file structure to me?
Android wannabe dev,
Darksurf
Sent from my ASUS Transformer Pad TF700T using xda premium

I don't think there is so much difference if you have a better look at it. Most of it is just in /system, for the same reason (one of them, actually) you were wondering why /root isn't in /home under Linux - you can have different partitions at these paths (security, storage/quota management, etc.). And as there are no user accounts, there is no need for /home.
Plus, there is need for more modules that are loaded and unloaded, there's different apps cache management under Android, these things have to be in separate places.
Having said that, I sometimes miss simple /var/log/ stuff and things like that by default too (you forgot /dev, btw). I would like the /system partition to be more Linux-like in case of directories, but I like how /data and /sdcard are handled, it's pretty clear and easy to manage.
IMHO the main difference is the division into /system and /data (+ /sdcard or other removables mount points in the case of the Infinity), which, as you've probably noticed, has its very practical purposes and have to be clearly distinguished, especially on a non-rooted device, where the permissions are clearly set (but comes helpful when rooted, so you won't mess up too much by a missclick ;>).

Related

Directories with spaces adb shell

Having a problem locating directories with spaces on my sdcard using adb shell.
Say I have to get to cd /sdcard/Misc Data
When I type the above I get bad data error or something like that.
I can go to /sdcard/music
but nothing with spaces. Is there like a %20 or something that I need use in place of the space?
In most Linux shells, you can type the whole location in quotes if there are spaces.
mount "/dev/this directory" /system
Another alternative is to use the backslash as an escape character before the space.
mount /dev/this\ directory /system
I haven't tested either with Android, but I'm assuming it'll work.
Well I guess I just don't understand that Android is basically Linux?
That means I don't need Debian since I don't program, wish I did.
Thanks man that worked perfectly.
beartard said:
In most Linux shells, you can type the whole location in quotes if there are spaces.
mount "/dev/this directory" /system
Another alternative is to use the backslash as an escape character before the space.
mount /dev/this\ directory /system
I haven't tested either with Android, but I'm assuming it'll work.
Click to expand...
Click to collapse
Yes, Android uses a Linux kernel as its base. Not sure what that has to do with Debian and programming (except for the similar kernels). But I'm sure you know better what you want to do that I do.
This is very oversimplified and non-technical, but here goes, from the bottom up:
The Linux kernel is the base. It controls all the low-level stuff like hardware, drivers, filesystems, etc.
On top of Linux sits Dalvik, a Java virtual machine.
Applications (even what we'd consider "Android OS" from a user perspective) run as separate processes in Dalvik.
Glad those terminal tips helped. If you need anything else, feel free to ask or google for "bash" or "busybox" for a bigger command and syntax reference.

android2sd

Hi All,
Here is my second contribution to the Android community, android2sd!
I tried to make the installation a bit more straight forward and the readme very verbose.
There is NO going into recovery and wiping of the Android to install this construct. (Of course you can if you want to have a clean slate to build from but it is by your choice only!)
Remove .zip from filename, then unrar (sorry to zip users, zip was too big) the package and copy the android2sd.sh install script to the Android say /data/local and make executable with something like chmod 0750 and copy the android2sd.img install image to the sdcard. (Detailed instructions are in the readme file.) Once the install is complete, you can delete both install files.
Execute the script {where ever you installed it}ie:
/data/local/android2sd.sh and follow the instructions.
Included are several of my scripts (updated from the ones in data2sd) and the rules still apply, adjust or remove as you see fit. The readme explains them all.
I have noticed an improvement in speed based on the install, but you can judge for yourself and tweak as you see fit!
The construct uses Overlay Profiles to overlay the Android system and thus any changes to the Android once loaded, are actually done to the overlay profile thus you have like a safe mode which is the untouched Android under the overlay.
Hope you find it useful!
Darkstrumn
Darkstrumn said:
Hi All,
Here is my second contribution to the Android community, android2sd!
I tried to make the installation a bit more straight forward and the readme very verbose.
There is NO going into recovery and wiping of the Android to install this construct. (Of course you can if you want to have a clean slate to build from but it is by your choice only!)
Remove .zip from filename, then unrar (sorry to zip users, zip was too big) the package and copy the android2sd.sh install script to the Android say /data/local and make executable with something like chmod 0750 and copy the android2sd.img install image to the sdcard. (Detailed instructions are in the readme file.) Once the install is complete, you can delete both install files.
Execute the script {where ever you installed it}ie:
/data/local/android2sd.sh and follow the instructions.
Included are several of my scripts (updated from the ones in data2sd) and the rules still apply, adjust or remove as you see fit. The readme explains them all.
I have noticed an improvement in speed based on the install, but you can judge for yourself and tweak as you see fit!
The construct uses Overlay Profiles to overlay the Android system and thus any changes to the Android once loaded, are actually done to the overlay profile thus you have like a safe mode which is the untouched Android under the overlay.
Hope you find it useful!
Darkstrumn
Click to expand...
Click to collapse
Damn man. Good work.
sounds interesting, what is this all about?
brilliant?!? I think.
So basically, this is a non-destructive method that enables us to run new roms on the G1 without flashing? Am I reading this right? If so... wow.
edit: or, erm... maybe not... i think i've been up too long. Gonna have to watch this thread to get a better grasp on this. interesting nonetheless.
Rename To RAR
Darkstrumn said:
Remove .zip from filename, then unrar (sorry to zip users, zip was too big) the package and copy the android2sd.sh install script to the Android say /data/local and make executable with something like chmod 0750 and copy the android2sd.img install image to the sdcard. (Detailed instructions are in the readme file.) Once the install is complete, you can delete both install files.
Click to expand...
Click to collapse
very interesting .. at first i failed to see this part as i'm sure many pay skip over the whole "rename to rar" thing - LOL - so this loads profiles from the SD to the phone
for anyone having trouble with the whole "rename" process try this:
http://files.lucidrem.us/jf/android2sd.rar
as i know windows with hidden file extensions does not allow a rename easily
So what exactly does this do? I see install instructions, but no description.
Overlay Profiles...
tr.slate said:
So what exactly does this do? I see install instructions, but no description.
Click to expand...
Click to collapse
Well,
I've worked up the natural progression to this XXX2SD business, and have made an Android2SD construct which can expand the Android similarly to the the previous constructs, but puts /system, /data and /cache on sd.
So let me explain the overlay thing:
An overlay profile is a snapshot of the Android file system, namely /system, /data, and /cache.
The initial profile is called 'android2sd' and is a snapshot of your android at the time of install, plus the file system structure as explained in the readme adding the mnt/ dir structure and additional scripts in bin/ (which you can remove or adjust as you need).
Typically I reckon folks would only have the one profile and under it your original Android. But you can create additional profiles and set them up however you like. The overlay is overlayed on top of the Android file system with any changes or edits to the system affecting the profile and not the Android under.
The effective change is that the /system /data/, cache are moved to the sdcard thus expanding them to however large your sdcp2 is; on a class 6 card also improving access time.
A second benefit is that the underlying Android is safe from alteration and can be booted into like a 'safe mode'. (It can also serve as the base for new profiles, or you can make new profiles from active overlays. These snapshots can serve as a form of backup, but that is a fringe benefit.
It cannot protect the Android from update.zip installs exactly, as those will modify the Android directly, but say you try a theme and it gafs your 'droid...you can reapply the firmware update to clean out the theme, then copy the desired profile back to the Android and restore the Android to the state of the profile. (I would recommend having a 'base' profile of the Android but not using that as an active profile which will thus serve as a backup) Note: To restore the Android as described above, you cannot restore using a profile with 250+ apps in /data as the Android doesn't have the space for it!
Originally I used unionfs for the overlays but it was too slow.
Hope that explains things here; the readme has far more detail.
I've gotta go, but if I see that I've been as clear as mud, I'll try to explain better when I have more time.
Hmm just out of curiosity: What are you using now? Bind mounts?
I got a little bit lost in setup, I am not sure if I had problems because I was using Cyanogens latest or something else but either way Im going back to JF to try this.
I installed it using the "-COMMIT" addition
But when I made it to installing/linking apps things wouldnt link
Maybe I will let a few other people try it first.
More info...
[email protected] said:
Hmm just out of curiosity: What are you using now? Bind mounts?
Click to expand...
Click to collapse
Yes. Originally it was to have a multi profile layered system using unionfs: union0 the ro base snapshot and union1 the rw profile containing the copy-on-write data. But as the tests went on, the unionfs was too slow to use for /data; Android is unforgiving of unresponsiveness and was ANR'ing the apps that didn't respond fast enough.
The faster bind mount means that union1 is now not used and union0 is rw.
The reason I wanted the union0,union1 path was that the union0 could serve as base and various profiles could be layered over any part of the file system granting "Lego" like flexibility in how the user could adjust their a2sdLoader.sh script (the android2sd loader which controls the overlay process).
You could have a pristine base and several "change" profiles that you layered to your liking and could change any sub layer to different effect.
While you still can under this paradigm, it is not as compact.
But the unionfs option is not completely done away with. It can still be used for the above layering but shouldn't be used for that apps and package system.
An example of the layering I'm on about:
The Android 0-layer which the base layer is a snapshot of.
The base layer is pristine (fully configured settings, but minimal apps loaded, maybe a particular base launcher layout and wallpaper).
A change profile containing my apps and package system
A change profile containing a version of etc with reconfigured bluetooth settings.
A change profile with a theme (manually installed, or snapshot to profile and restored to pristine)
Now I could take these 4 profiles and arrange several different setups:
'base' with all apps loaded, themed with custom bluetooth
'base' with all apps loaded, themed with normal bluetooth
'base' with all apps loaded with custom bluetooth
'base' with all apps loaded with normal bluetooth
'base' with all apps loaded
'base' themed with with custom bluetooth
'base' themed with normal bluetooth
'base' with custom bluetooth
'base' with normal bluetooth
...
Those would be set to serve as the ro union0 and the rw union1 which will hold the copy-on-write changes to the overlay (which preserves the sub layers)
You could have several more theme profiles and have a script that randomly chooses one at boot...
You could simply use the overlay to protect a favored configuration. Should anything untoward happen such as accidentally damaging the packages.xml file while experimenting with the system, you could simply delete the change profile, make a new blank change profile and the damaged files are undone.
The things one can do with the overlay concept are limited only by your imagination and need (and if they slow down app processing too much causing ANR's)
It vary well could if done correctly allow one to have multiple roms as profiles and switch them based on the selected profile, but I have yet to experiment on that...I reckon that is my next move! (Note that this path would have a high space cost as the roms are about 40MB zipped!)
brandenk said:
I got a little bit lost in setup, I am not sure if I had problems because I was using Cyanogens latest or something else but either way Im going back to JF to try this.
I installed it using the "-COMMIT" addition
But when I made it to installing/linking apps things wouldnt link
Maybe I will let a few other people try it first.
Click to expand...
Click to collapse
Taken from [Rom] CyanogenMod:http://forum.xda-developers.com/showthread.php?t=518851
"DO NOT RUN ANY OTHER APPS2SD APPLICATIONS ON THIS BUILD. YOU WILL BREAK YOUR SYSTEM. THEY ARE NOT NECESSARY BECAUSE THIS ROM WILL DO A2SD AUTOMATICALLY AND BETTER!"
The android2sd construct pretty much falls into the A2SD category and thus is likely the reason you had issues with the install.
My Android is based on JF 1.51... and thus your mileage will vary based on the rom you are using. I reckon with a rom derived from theh JF roms, the install may work as intended.
As I go into the next construct build process, I will see if I can't make it multi-rom compatible (to support multi-rom profiles) I'm sure it will take some time to do as I would have to use my actual Android to test with, but no worries!
Hope that helps a little. Sorry it's not better news though.
An excellent "misuse" of this concept would be to run ion (picking it for its speed and almost stock nature) with a hero overlay (picked due to known instability as we are still developing it) so that ion would serve as a "safe mode" for when you crash hero.
I have a spare phone if i crash this and a secondary sd for if that gets corrupted. Let me know if you need help testing.
twistedumbrella said:
An excellent "misuse" of this concept would be to run ion (picking it for its speed and almost stock nature) with a hero overlay (picked due to known instability as we are still developing it) so that ion would serve as a "safe mode" for when you crash hero.
Click to expand...
Click to collapse
Interesting thought, and if this could be done, I suppose it would be possible to have bluetooth working in ION while using a Hero overlay?
Request for feedback...
Hi All,
Those who've installed android2sd, how is it going?
Can you give some pros and cons of your experience so I may improve things going forward? (Hopefully no cons exists!)
I know that roms that already make use apps2sd will encounter issues as the apps2sd and android2sd function similarly and thus step on each other. I may be able to detect this condition and adjust for it going forward...we'll see.
Thanks in advance for your input!
Darkstrumn
LucidREM said:
very interesting .. at first i failed to see this part as i'm sure many pay skip over the whole "rename to rar" thing - LOL - so this loads profiles from the SD to the phone
for anyone having trouble with the whole "rename" process try this:
http://files.lucidrem.us/jf/android2sd.rar
as i know windows with hidden file extensions does not allow a rename easily
Click to expand...
Click to collapse
Thanks for putting the rar up, XDA wouldn't take the .rar and I didn't want to signup to a file-share site just yet.
And it being seemingly natural to make windows show file extensions, it didn't cross my mind to make a note about that.
Thanks again!
Darkstrumn said:
Thanks for putting the rar up, XDA wouldn't take the .rar and I didn't want to signup to a file-share site just yet.
And it being seemingly natural to make windows show file extensions, it didn't cross my mind to make a note about that.
Thanks again!
Click to expand...
Click to collapse
How come no one is trying this? It seems to me an excellent idea and would be really cool to boot mutipe roms if someone figures that out. I'm not testing this because I'm using appstosd and didn't want conflicts...but no one else with jf1.51 Rom is testing this idea?
Just curious
so wait a second. let me get this straight ... if I have a class 6 8gb card i might be able to install a hero build without rosie or widgets with the original launcher on the sd card that might actually come sorta, kinda, a little close to a speed that might be bearable? at least for like 5 minutes?
Can this be adapted to install bigger roms such as hero without the dangerspl .
XD
Ill try this with ion later tonight
wow this is beautiful work! now to test it!
Im trying so hard to understand this lol.. Correct me on my errors but from what i read this is my hypothesis on what i think this does..
This is like a apps2sd but with data and that type thing from the build we are using? And you Said this takes snapshots So we can create several profiles of the phone? Like for example have a profile with some apps loaded and another profile with all removed and be able to switch between them at will?

[Q] [DEV][Android Platform]Creating partitions through script in init.rc

Context/Resume:
-I´m changing the android platform to create two partitions in a SD Card. I need to do this as early as possible. I´m currently trying at init.rc
-It would be nice to obfuscate the access to one of the partitions. If i could keep ithidden would be better
And...the long story:
I´m trying to create new partitions in a sdcard in a device, and i need to be done as early as possible. I thought that the init.rc should be the best location for this, so i tried to add a script call to perform the task, but i´m unable to create these partitions ( or get information of the reason of fail ) First of all, is this premiss valid? Should i be able to do this?
I call the script by:
service myscript /system/bin/logwrapper /system/bin/myscript.sh
disabled
oneshot
at init-time
And the content´s of the .sh file is
fdisk /dev/sdcard < mykeys.input
where "mykeys.input" is the sequence os keys used to perform the taks of create the partitions.
Well, is this the recommended way to do this?
thanks!
Not to sure bout the boot order and its effect on what you are trying to achieve. What phone and os? You might want to look at your phones logs to see in what order what/which/where is going on when. As that could explain your issues a bit more clearly and possibly even provide the mystery errors. If not try running it in an emulator where you can make the boot up verbose and boot log it.
As for hiding the partition have you tried formatting the sdcard outside the phone environment. The hiding ability should be able to be gotten if you were to format in gparted I.e. Format it how you want size wise and format wise, then for the partition you want hidden flag it lba. Not sure if lba hides from your phone or not, but worth a shot.
*edit* what are you trying to achieve again? Dual booting os on phone? If so, I would take a look more towards the /dev/loop and chmod approach. Also keep in mind if this is what you are aiming at you might want to make 3 partitions as a swap partition would be beneficial.
Sent while wearin my foam helmet ridin the short bus.
Hy blackadept:
What i want: Ensure that there is two partitions in a sdcard as early as possible. ( i must create them if needed ). My focus now is in how to create. The logic of "if/when" todo a will deal later.
Why i want this: Project requirement. Not negotiable.
What will be stored: Part1 : User acessible. Nothinf special. Part2: Special Data user by an apk.
"Phone model": It´s a tablet. STI´s tablet. Android 2.2
Well the partitions will be there just from formatting the card, as to whether or not the init sees that I am not sure. I'm one of them poor simple folk who ain't got no money....aka I don't have the fun fancy toys like a tablet. haha. Only reason I bring that up is for the fact that being as I am not around them, literally haven't even seen one let alone hold lmao, not sure how it's boot up goes.
Have you tried creating a partition and formatting it with various flags such as lba to hide it from the OS? If we are talking small sizes here then I'd think you could hide it within such a flagged partition surrounded by fluff. Throw some encryption into the mix and your gtg. At that point all that's left for you to do would be writing script to navigate the maze and unlock it. If that would work then it would be a fairly easy out.
Otherwise we could go back to the "dual booting" that I brought up in the last post. Being as my phone can't mnt to bin *droid x.....hate u Motorola* I have done all of my dual and triple boots via looping thru /dev. This could work for you as well, tho again I'm not familiar with the tablets. If you did that tho..... well you could hide it in a myriad of ways.... flags, encryption, straight up "Where's Waldo" type shenanigans....
Have you ever put an ARM OS onto an android device before? If so, maybe give it a shot and let me know? Only question I'm wondering, tho, is android's ability to see the flag and be able to handle it. Also as to the level of root that particular device has (regular not-so-super user like my phone or is it completely unlockable?) would determine a game plan too in a way. If you have full access then you could just format the card thrice (sorry always wanted to use that in a sentence and feel all smert), making a special ext3 partition with the flags or encryption, make note in the root mnt's of it's existence thru your init script (tho just giving physical note to it.... not size or content). Write your .apk or specialized script with the UUID or GUID or w/e the *beep* android uses this week, and again you win at android....
Sorry for the long winded verbal response....lately I always seem to post when I ain't slept for 2-3 days as opposed to when I ain't delirious...

Zip align and defrag

Hey guys just wondering if anyone knows if there is a way to do a zip align and defrag, kind of like the revolver rom does, but to do it manually? I'm using prime rom right now and would really like to be able to do that, although I don't know how much it might help anything
Thanks guys
Sent from my Transformer TF101 using xda premium
you can try APKMultitool, it has a zipalign option though I've never tried the option before myself.
http://apkmultitool.com/node/3
Sent from my Transformer TF101 using Tapatalk
In Prime there is a shell script in /system/xbin, called zipalign_apks. This gets called from the init script Roach setup in /etc/init.d and uses the onboard zipalign program (idk if it's part of Android or just added to custom ROMs) but it could just as easily be put on a cron job or by hand.
To do what you want in Prime, I would remount /system as rw, comment out the line in the init script, remount /system ro, and then decide how I want to run zipalign_apks - probably a weekly cronjob. I'm not sure if there would be a problem with doing it /after/ the system is a fully operational battle statation^H^H^H^H^H^H^H^H^H^Hdroid.
Sent from my Transformer TF101 using Tapatalk
So it does a zipalign on boot then?
I can just run it manually as well. I like Prime, but I'm torn between Prime and Revolver.
What are the benefits of these features anyways ??
xMini said:
What are the benefits of these features anyways ??
Click to expand...
Click to collapse
i want to know that too pls!
This is from the dev guide, it talks about doing it to the actual package when it is created. Hopefully someone can explain as to what it does when things have already been installed
"zipalign is an archive alignment tool that provides important optimization to Android application (.apk) files. The purpose is to ensure that all uncompressed data starts with a particular alignment relative to the start of the file. Specifically, it causes all uncompressed data within the .apk, such as images or raw files, to be aligned on 4-byte boundaries. This allows all portions to be accessed directly with mmap() even if they contain binary data with alignment restrictions. The benefit is a reduction in the amount of RAM consumed when running the application."
FunkyMcBain said:
This is from the dev guide, it talks about doing it to the actual package when it is created. Hopefully someone can explain as to what it does when things have already been installed
"zipalign is an archive alignment tool that provides important optimization to Android application (.apk) files. The purpose is to ensure that all uncompressed data starts with a particular alignment relative to the start of the file. Specifically, it causes all uncompressed data within the .apk, such as images or raw files, to be aligned on 4-byte boundaries. This allows all portions to be accessed directly with mmap() even if they contain binary data with alignment restrictions. The benefit is a reduction in the amount of RAM consumed when running the application."
Click to expand...
Click to collapse
I assume it does the same thing, execpt on our devices instead of the developers workstation - I'm not sure how well the whole thing works in the end but it's easy enough to profile scientifically if anyone wants to put in the effort
Sent from my Transformer TF101 using Tapatalk

android and rsync = perpetual re-copying

I've been using rsync to keep my iTunes Music folder on my mac sync'ed to the Music folder on my sdcard. As long as I only sync in one direction and carefully choose my rsync options it works pretty well. But if I make changes on my phone and try to sync them back to my mac, it gets messy. Every time I switch direction rsync thinks it needs to sync a bunch of stuff even though the files are all already identical.
I think the culprit is some combination of: 1) the vfat filesystem, which has an incompatible permissions and ownership model, and 2) the mount options, which include a umask that prevents rsync from replicating permissions from my mac, maybe including mtime?
I tried for awhile to switch my sdcard to ext4, but can't get it working. Then I tried to run a mount -o remount to change the umask, but that didn't seem to work. I'm stuck.
Old thread, but the answer is still valid: The problem here is that vfat stores time with a 2-second resolution only. rsync will detect files as changed even though they didn't change at all.
Use the "--modify-window=1" cmdline switch to ignore difference in time up to one second.
From the rsync manpage:
--modify-window
When comparing two timestamps, rsync treats the timestamps as being equal if they differ by no more than the modify-window value. This is normally 0 (for an exact match), but you may find it useful to set this to a larger value in some situations. In particular, when transferring to or from an MS Windows FAT filesystem (which represents times with a 2-second resolution), --modify-window=1 is useful (allowing times to differ by up to 1 second).
Click to expand...
Click to collapse

Categories

Resources