[Q] apps2sd and cache2sd on the fly (WITHOUT reboot) for HTC builds - Android

okay
topic is related to apps2sd, cache2sd and symlinking. The end goal is to produce a process on HTC code based ROMs where we can just "move" both apps and dalvik-cache from internal to the sd ext and back WITHOUT having to reboot the phone
Through shell scripts run from Terminal or GScript I have been able to get dalvik-cache (/data/dalvik-cache - /system/sd/dalvik-cache) to move back and forth on the fly with no ill effect (at least that I have been able to find). BUT apps (/data/app and /data/app-private - /system/sd/app and /system/sd/app-private) are more complicated in that they no longer show up in the app drawer of the lancher program.
A few relevant points on the .apk files:
* I can run the script that moves the app files then via root explorer use the install command and they show up again...
* I can run the script that moves the app files and then reboot the phone and all apps show up again...
SO my questions are:
1) What are all the meta-data and system data locations that are populated when .apks are installed?
2) What specific setting are out of place that causes the app to not show after moving the physical files and establishing (or removing) directory symlinks?
3) How can we force sync so that we can just "move" apps on the fly WITHOUT reboot similar to CyanogenMod builds...
seems like there is just a setting in a db or xml file somewhere that needs to be refreshed after the files are move and the directories are symlinked (or symlinks are removed) :/
If helpful I have attached a .zip file including the following shell script files I use in the process
* 04apps2sd - run via the init.d boot process to check if sd card and ext partition are available and then basically sets and stores a system property of sdactive.
* apps2sd.xtr - runs when executed and checks that proper directories are in place, moves app and app-private files and creates symlinks
* apps2internal.xtr - runs when executed and checks that proper directories are in place, moves app and app-private files and removes symlinks
* cache2sd.xtr - runs when executed and checks that proper directories are in place, moves dalvik-cache files and creates symlinks
* cache2internal.xtr - runs when executed and checks that proper directories are in place, moves dalvik-cache files and removes symlinks

1. Data for the apks are located in /data/data. Each application has its own folder under that.
2. Ran into this very issue with Darktremor 2.7 update 3r1 and 2.7.5 Preview Fix. The issue I had was that, when I copied the files, I wasn't copying the permissions.
It's was actually a simple fix:
Code:
Old way: /system/xbin/busybox cp -f /data/app/* /system/sd/app
New way: /system/xbin/busybox cp -fp /data/app/* /system/sd/app
The -p command copies the file while leaving the permissions intact. Once I changed all the cp lines to use -p, all worked correctly.
3. I know I never reboot when I move applications from internal to sd (or vice versa). The programs follow. However, it could be setting permissions on /data/app and /data/app-private. I usually use chmod 777 (overkill, I know) and it works fine for me.
I do a reboot when I move dalvik-cache, but that is because a few apps have issues when the dalvik-cache is moved while they are running. Technically, it isn't necessary.
zach.xtr said:
SO my questions are:
1) What are all the meta-data and system data locations that are populated when .apks are installed?
2) What specific setting are out of place that causes the app to not show after moving the physical files and establishing (or removing) directory symlinks?
3) How can we force sync so that we can just "move" apps on the fly WITHOUT reboot similar to CyanogenMod builds...
seems like there is just a setting in a db or xml file somewhere that needs to be refreshed after the files are move and the directories are symlinked (or symlinks are removed) :/
If helpful I have attached a .zip file including the following shell script files I use in the process
* 04apps2sd - run via the init.d boot process to check if sd card and ext partition are available and then basically sets and stores a system property of sdactive.
* apps2sd.xtr - runs when executed and checks that proper directories are in place, moves app and app-private files and creates symlinks
* apps2internal.xtr - runs when executed and checks that proper directories are in place, moves app and app-private files and removes symlinks
* cache2sd.xtr - runs when executed and checks that proper directories are in place, moves dalvik-cache files and creates symlinks
* cache2internal.xtr - runs when executed and checks that proper directories are in place, moves dalvik-cache files and removes symlinks
Click to expand...
Click to collapse

Thanks I will try this out...

Okay well thanks for the code but i have tested this and no success
To be clear i am running on the phone, not adb, via gscrips or terminal and the apps still do not show in app drawer unill phone is rebooted...
Any other ideas?
Sent from my Eris using XDA App

try to modify this files /data/system/packages.xml i think this file tells the system where the apks are located.

Related

[HOW-TO] Manually backup 3rd-party application settings and data--by cyricc

From the original post by cyricc in the G1 Android Development forum:
HOW TO: Manually backup 3rd-party application settings and data
I just didn't want to be the guy posting only a link. Please post any questions, comments, or thanks in the original thread I deserve NO CREDIT for this post.
##############################
This tutorial will explain how to backup application data and settings for 3rd-party apps that do not have an export/import settings feature. Looking to upgrade your ROM but don't want to lose your todos/highscores/whatnots after a data wipe? Then read on..
(I've never used apps to SD, so I'm not completely sure how the data is stored with that. I'm assuming the entire data partition is moved to the SD though, so the procedures outlined in this guide are not necessary / do not apply to apps2sd)
Tools needed:
adb
Backing up settings
Run a adb shell in the command prompt and navigate to /data/data
Code:
c:\android-sdk-windows-1.5_r1\tools> adb shell
# cd /data/data
Find the folder of the app whose settings you want to backup. In android 1.5, M/SMS are stored in com.android.providers.telephony and bookmarks are in com.android.browser. For third party apps, you can use ls to list all installed apps and find your app folder manually, or use find - say I want to find the app folder for the Astrid todo app:
Code:
# ls
<.....lots of directories....>
com.timsu.astrid
<.....more directories....>
# find *astrid* -maxdepth 0
com.timsu.astrid
Now open a separate command prompt and use adb pull to copy the application's data folder to your computer. This does not copy the app itself, only its saved data and settings. App .apks reside in /data/apps, which you can also adb pull out if you want. In this example I pull out settings for Astrid:
Code:
c:\android-sdk-windows-1.5_r1\tools> adb pull /data/data/com.timsu.astrid d:\desktop\com.timsu.astrid
Feel free to replace d:\desktop with the location of your choice, of course. Repeat the above for each app folder you want to backup.
Restoring settings after a wipe
First thing to do is reinstall the apk, from sdcard, adb install, market, whatever. After the app is installed, you can restore settings in one of two ways: the easy way or the hard but safe (paranoid) way.
The Easy Way:
This quick and dirty method will give everyone full read/write/execute permissions on the application's settings/data. This is normally a Very Bad Idea with a normal linux computer, but realistically there is very little risk of this posing any real security issues on a device like a phone.
First, adb push the settings into the data folder, overwriting the app's stock settings (in this example, the astrid data I backed up) then adb shell into the phone and navigate to /data/data:
Code:
c:\android-sdk-windows-1.5_r1\tools> adb push d:\desktop\com.timsu.astrid /data/data/com.timsu.astrid
Done
c:\android-sdk-windows-1.5_r1\tools> adb shell
# cd /data/data
Now give full permissions to the app's data folder and its contents:
Code:
# chmod 777 com.timsu.astrid
# cd com.timsu.astrid
# chmod 777 * */*
And that's it. Launch the app and your settings/data should be restored.
The Hard Way
I'm not going to go into this in detail because if you're reading this, you probably know the commands to do this anyway. After you reinstall the app, the general idea is to run ls -l on the stock app data directory and its subdirectories to display the owner and permissions of each file/folder as setup by the android system. Write these down then adb push the backup app data folder in, which overwrites everything with directories and files owned by root. Then use chown and chmod to restore the original owners and permissions for each file and directory. Needless to say this can be quite a hassle if you're dealing with more than a few application backups.
i made a script that copies ALL of the applications off of the phone as a backup to a folder on your sd card. the sd card MUST HAVE a folder called "app" in order for this to work.
Code:
@ECHO OFF
adb shell cp data/app/* /sdcard/app
pause
then here is one to reinstall ALL of the apps from that "app" folder back onto your android, keeping the update notifications.
Code:
@ECHO OFF
adb remount
adb shell busybox install sdcard/app/*.apk /data/app
pause
exit
either type those commands into a command prompt or you can make a .bat file and put those commands in.

[Q] mount -o bind at boot on stock rom

Hi !
I have an application (CamScanner) with large amount of data (~8Gb). This app doesn't support transfering data do external SD card, so I checked mount -o bind command to bind directory with data stored on external SD to directory in /sdcard and it's working correctly. Question is where I can put this command so that system will run it at boot time after external sd card is ready. There is no /etc/init.d directory on my SGS2 (stock XXKI4). I prefer not to install any applications to perform such a simple task...
Thanks for help, regards !
slig said:
I prefer not to install any applications to perform such a simple task...
Click to expand...
Click to collapse
I think you have no choice, as stock kernels do not have init.d support. You'd need to go down the route of either using an app to run a script on boot, install a kernel with init.d support, or stick with your current method of manually running a script when you need to use the app.
Also, you could try asking the developers kindly to allow saving to external_sd. There's an Email Developer link on the Android market, and a Contact Us link on their website
Thanks for response. I found script named init.rc located in "/", it has several mount commands inside, wonder if it can be used...
Also discovered that app Tasked has ability to run shell scripts with root privileges (at boot or at application start). I suppose I have to put this shell script in /system because in /sdcard owner permissions cannot be set so that file cannot be modified (vfat does not support that) and a security hole would be created...
I think that I'll also ask developer for this feature as You suggest.
slig said:
Thanks for response. I found script named init.rc located in "/", it has several mount commands inside, wonder if it can be used...
Click to expand...
Click to collapse
Everything in "/" is initramfs, a volatile ramdisk changes to which would be lost
on reboot. Only exception are directories in which actual partitions are mounted,
like /system and /data (you can check which directories with "mount" command).
Have you tried just using symbolic link?
INFO
This may be the best solution, try something like:
Code:
mkdir /sdcard/AppFolder
ln -s /sdcard/AppFolder /data/data/com.your.application.data.folder
Just in case you don't know, you can execute those command using
Terminal Emulator. You were considering modifications to /, so I guess you already have root.
Yes, I have rooted my SGS2 via ZergRush.
I didn't know that / is volatile initramfs, thanks for that information.
As for symbolic link - unfortunately on my stock ROM both /sdcard and /sdcard/external_sd filesystems are vfat and don't support symbolic linking. Only working way I discovered is bind mount.
In my case, I have the following:
mount -o bind /sdcard/external_sd/CamScanner /sdcard/CamScanner
And application runs OK, all data is accessible and doesn't consume internal flash memory.
I'll take a look how hard would be to write some small application to do just this task - define some pairs of source and target directories and mount - bind them at start.
I've somehow missed the fact that you're need redirection from /sdcard
to /sdcard/external_sd, I was thinking about symlink on /data...
Anyways, there another nice trick you can do - if you can devote your SD card
to this one application, then just edit /system/etc/vold.fstab to make SD card
mount in /sdcard/CamScanner instead of /sdcard/external_sd.

[SOLVED] Filesystem - problem with /system/bin - nested bin folders (SE LwW)

Hello everybody,
I have a "problem" with /system/bin/ and bin folders (however, the phone works just fine, hence those quotation marks :angel.
Let's stick with /system/bin/: Inside I have the files that should be there, but there is also another bin folder with exactly the same files inside and another bin folder inside ... and so on, about 20 times/levels(?) nested.
Not sure what it is ... some hardlink problem?
The same is in /bin/ folder.
ES File Explorer says that there are about 7000 files/ 230 MB in the first nested bin subfolder.
I tried the following:
1. Delete the nested bin folders from ES File Explorer (root access granted) - unsuccessful ("can't delete ...")
2. From CWM: format /system/ + Factory reset + wipe + ROM reflash
3. Search the forum for this issue - maybe I can't search properly, but found nothing ... sorry
As I said, the phone works fine. But I think that it is not good to have such a mess inside the system folders.
I didn't try complete reflash (ftf file) ... I'm trying to avoid doing everything from scratch .
Can you help me, please?
Thanks a lot,
J.
Phone: Sony Ericsson Live With Walkman WT19i, unlocked bootloader (the Sony way), MESA Kernel 3.6 stock, Real ICS lite r4.
Update: It's a chain of symlinks. The depth of the chain is 40 (counted in DroidExplorer).
What else didn't work:
mount /system in TWRP, then starting file editor, deleting bin (even with chmod)
All attempts to delete the symlink via PC file managers (e.g. Droid Commander)
Solution {rooted phone):
It was a symlink in system/bin pointing to self,
1. Install Android Terminal Emulator (free at Google Play)
2. Start it
3. Then
Code:
# su
(allow root access)
Code:
# mount -o remount, rw /system
# cd /system/bin
# rm bin
That's it

[Q] How to move obb data from internal SD to internal storage?

I have a xperia u, which has not external SD card slot..
Data partition is MUCH bigger than what I need (I'm using 500mb of 2gb) and I want to move obb files to data partition to free some space in SD partition..
Is that possible?
You might try to move the file to the data partition and then create a symlink where the file was originally.
From a shell with root access:
# ln -s /your/data/partition/filename.obb /original/place/filename.obb
I'm doing the same moving apk and dalvik-cache but I have the problem that after reboot files are still there but the app is disabled.
You can check it here: http://forum.xda-developers.com/showthread.php?t=2597924
I would suggest to try it on an app that it's not important for the system and I don't assume any responsability
P.S.
partition where you create symlink must be ext2/3/4
I think I understand how this works.. Lets say symlinks are some kind of 'windows direct access' for files that can be recognized by the system.. Am I right?
How can I figure out what format are my partitions?
I want to move /mnt/sdcard/Android/obb/com.package.name/file.obb to /data/data/com.package.name/file.obb
Assuming that partitions are in the correct format, I'll have to move files with a root file browser, then connect phone with debug on and type this:
-adb shell
-su
-ln -s /data/data/com.package.name/file.obb /mnt/sdcard/Android/obb/com.package.name/file.obb
Is that ok?
Yest that's the use, I don't know about "windows direct access" because I'm linux user
To check how is your partition formatted there are different ways from console but I just tried this app and it works:
https://play.google.com/store/apps/details?id=com.cls.partition
If both partitions are ext2/3/4 remember also to set the same user, group and permissions, you can do that copying the file from shell.
The whole sequence should look like this:
Code:
$ adb shell
$ su
# cp -a /mnt/sdcard/Android/obb/com.package.name/file.obb /data/data/com.package.name/file.obb
# rm /mnt/sdcard/Android/obb/com.package.name/file.obb
# ln -s /data/data/com.package.name/file.obb /mnt/sdcard/Android/obb/com.package.name/file.obb
cp - a to copy preserving permissions and rm to remove the file.
/data is ext4.. /mnt/sdcard is vfat D=
No symlink then
I never used it but you can still mount bind folders (not files) in fat, something similar to symlink:
Code:
$ adb shell
$ su
# mkdir /data/data/com.package.name/obb/
# cp -a /mnt/sdcard/Android/obb/com.package.name/* /data/data/com.package.name/[B]obb/[/B]
# rm -r /mnt/sdcard/Android/obb/com.package.name/*
# mount -o bind /data/data/com.package.name/[B]obb/[/B] /mnt/sdcard/Android/obb/com.package.name/
if it works you need to find a way to excute that on boot maybe with a init script.
And if there is not crucial data you could even bind all the obb folder together like:
Code:
# mount -o bind /data/data/com.package.name/[B]obb/[/B] /mnt/sdcard/Android/obb/
You can also check this thread:
http://forum.xda-developers.com/showthread.php?t=1410262
Double check everything because I never tried it
Is it possible to add init.d support to my current rom and execute a sh file from it to initialize bind on boot?
No idea sorry
You can try asking in your phone section: http://forum.xda-developers.com/xperia-u
I found how to add init.d support!
Not sure if it works for any device/rom/kernel, but it worked for my Xperia U with GingerBeanSS v3.5 (Sony GB based)..
If anyone is interested, go to this link: http://forum.xda-developers.com/showthread.php?p=32716432
Now I suppose I can create a "BindOBB.sh" with the script you mentioned before in any place of /system, and make a "bindobb" file in /system/etc/init.d/ to execute that script..
So theoretically binding folders should work on every boot!
I used windows my entire life.. I'm not completely sure about linux scripts..
Sorry about making so much questions!
I really appreciate your help!
No problem I'm glad if I can help.
Init script is usually named starting with two numbers like: 00script, 20script, 99script that should give the order scripts are excuted.
For the script itself you need to follow the sample you donwloaded so it will be something like this:
Code:
#!/system/bin/sh
#Comment
busybox mount -o bind /data/data/obb/ /mnt/sdcard/Android/obb/
This is to mount all obb folder or, if you want to mount only some, you can write them all in the script or keep a list of packages in another file and make the script read that.
Remember to make a backup and you might try first with only one package
Ok, I've understood everything (thanks google! ) and done it..
mount -o bind[...] isn't executed by init script.. Maybe a syntax error as it is my first time doing it..
The same command (without 'busybox' at first, of course) seems to work via ADB, because in SolidExplorer when I go to obb folder BEFORE running the script it is empy, but after running it all packages' folders and files appear!
Now problem is that when running a game that need obb data, it closes by itselfs (no FC nor 'missing data' warning)..
Same problem with a 3rd party TTS engine that needs obb data too..
The first problem could be that when you try to execute the command partitions are not mounted yet. Check 00 script used to test if init is enabled to mount them.
Another solution could be to use a sleep command to make the script wait some seconds but the first one should do the trick.
For the second problem check permissions. You copied files as root so you need to be sure the apps can access those files as well, in fat system there is no use of users, group and permissions but moving to ext you need to check that.
To be sure you can set obb folder and all files an directories inside as 777 (rwx for all)
Let me know if it's working
Sent from my ZP980 using Tapatalk
NeriL said:
I want to move /mnt/sdcard/Android/obb/ to /data/data/
Click to expand...
Click to collapse
you can easy create a directory bind using luckypatcher with the folder with obb and the folder where you would like to put it
remember to reboot or rescan your sd else it wont work
i use it to play asphalt and fifa
MrCrayon said:
The first problem could be that when you try to execute the command partitions are not mounted yet. Check 00 script used to test if init is enabled to mount them.
Another solution could be to use a sleep command to make the script wait some seconds but the first one should do the trick.
For the second problem check permissions. You copied files as root so you need to be sure the apps can access those files as well, in fat system there is no use of users, group and permissions but moving to ext you need to check that.
To be sure you can set obb folder and all files an directories inside as 777 (rwx for all)
Let me know if it's working
Sent from my ZP980 using Tapatalk
Click to expand...
Click to collapse
I deleted my custom init script and wrote following command at the last line of '00test' script:
busybox mount -o bind /data/obb/ /mnt/sdcard/Android/obb/
Mount then worked fine
(By the way, my custom script was named '99bindobb', so it was supposedly executed after everything else)
Also checked permissions: /data/obb/ and com.package.name folders inside it were rwxrwxrwx, but files inside were rw-------!
Changed permission of files to rwxrwxrwx..
Now everything works flawlessly at each boot!
Thank you so much! =D =D
You saved about 500Mb of my 4Gb!
And also I learned a lot about linux scripts, busybox and file system permissions!
You are welcome
For the 99 script that only define the order between the user init scripts so it still depends when they are called during boot.
Enjoy the power of Linux
Sent from my ZP980 using Tapatalk
Hi MrCrayon..! I'm here again
I changed rom and did the same as before to use /data insted of /mnt/sdcard for apps files..
This is exactly what I did:
I copied the script I used to sd (my edited 00test), changed rom (switched from Sony based GB rom to Sony Stock ICS rom), added init.d support (/data/Test.log indicates that it works), copied script to /system/etc/init.d/, changed script permissions to 777, created folders /data/AndroidData/ and /data/obb/ with 777 permissions and moved files from sd folders to custom folders in /data..
Finally updated busybox just in case
Script doesn't work, but executing 'mount -o bind' commands from ADB does! How can I fix that?
This is my init script:
#!/system/bin/sh
#Init.d Test
if [ -e /data/Test.log ]; then
rm /data/Test.log
fi
echo Ryuinferno @ XDA 2013 > /data/Test.log
echo Init.d is working !!! >> /data/Test.log
busybox mount -o bind /data/obb/ /mnt/sdcard/Android/obb/
busybox mount -o bind /data/AndroidData/ /mnt/sdcard/Android/data/
busybox set_perm_recursive(0, 0, 0777, 0777, /data/AndroidData, /data/obb)

KitKat and /data/app moving

Hello!
I am working with andoid filesystem and stuck with moving /data/app catalog
In previous version it was very easy:
I move /data/app to /data/something/app
And make symlink "ln -s /data/something/app /data/app"
In 4.4.x this leads to forceclose of apps and I cant find out why - every other catalog in /data/ symlinked with ease
I changed owner of /data/something/ to system, changed its group to system,
made symling under system user - no effect, apps shown in drawer but dont start. Somebody have explanation to this?

Categories

Resources