[EXPANDSD] Join your external SD with internal SD! - Galaxy S II Original Android Development

WARN: For developer only.
attachment is the EXPANDSD script.
Why use it?
So many applications use /sdcard for mass data storage(gameloft, navigation...),
but I9100's internal_sd size is limit to 11G, so we need external_sd's space.
But these applications dosen't know how to use external_sd, old method is hack the apk for external_sd, but this will change apk's signature, and need smali/baksmali to work. My method work in system level, don't need change any apk file.
How to use:
1.make expandsd.ownhere dirctory in external_sd root directory.
2.move internal_sd's directory(for example:/gameloft) to expandsd.ownhere
3.run init_expandsd.sh
Theory:
use 'mount --bind' feature, bind external_sd's dir to internal_sd.
Because the sd card using fat32 partition format, the 'ln -s' command does not work, so the "mount --bind" is the only way to dynamically change the directory content.

Hi mate,
Thks for your shares. I have a question. How run init_expandsd.sh?

I tried gscript and init.d, but doesn't seem to be working

woohoo a great dev has come. glad you got here mate! love your work on Desire section.

harrynghiem said:
Hi mate,
Thks for your shares. I have a question. How run init_expandsd.sh?
Click to expand...
Click to collapse
you can try to use terminal emu, just type su then navigate to folder where the script located, then type sh init_expandsd.sh then enter. this might do the trick to execute .sh

dexterdave said:
you can try to use terminal emu, just type su then navigate to folder where the script located, then type sh init_expandsd.sh then enter. this might do the trick to execute .sh
Click to expand...
Click to collapse
Does it work for you?

It's a great idea thanks a lot for your work. I was wondering why ln was not working.
But too bad it does not work for me, i get the following error :
[1] Segmentation fault
Do you have any idea why ?
Thanks again

problems when connecting phone to pc
hi,
tried the "mount --bind" in order to try your script.
works fine. the directory contents is shared between the 2 path's,
but i have a problem when i connect the phone to a pc.
when i try to disconnect, the sdcard and external_sd are not
available anymore until i reboot the phone
note: the commands that i have executed are:
Code:
mkdir /mnt/sdcard/external_sd/foo
echo "test" > /mnt/sdcard/external_sd/foo/test
mkdir /mnt/sdcard/foo
mount --bind /mnt/sdcard/external_sd/foo /mnt/sdcard/foo

Can this script be placed in init.d folder for autorun at boot?
Edit: sorry, already answered above: no, it cannot.
Sent from my GT-P1000 using Tapatalk

Seems abandoned by @ownhere
Sent from my GT-I9100

Idan73 said:
Seems abandoned by @ownhere
Sent from my GT-I9100
Click to expand...
Click to collapse
too bad, it could be very useful..

TheFirstBen said:
It's a great idea thanks a lot for your work. I was wondering why ln was not working.
But too bad it does not work for me, i get the following error :
[1] Segmentation fault
Do you have any idea why ?
Thanks again
Click to expand...
Click to collapse
got the same problem please help

How to use?

ownhere said:
WARN: For developer only.
attachment is the EXPANDSD script.
Why use it?
So many applications use /sdcard for mass data storage(gameloft, navigation...),
but I9100's internal_sd size is limit to 11G, so we need external_sd's space.
But these applications dosen't know how to use external_sd, old method is hack the apk for external_sd, but this will change apk's signature, and need smali/baksmali to work. My method work in system level, don't need change any apk file.
How to use:
1.make expandsd.ownhere dirctory in external_sd root directory.
2.move internal_sd's directory(for example:/gameloft) to expandsd.ownhere
3.run init_expandsd.sh
Theory:
use 'mount --bind' feature, bind external_sd's dir to internal_sd.
Because the sd card using fat32 partition format, the 'ln -s' command does not work, so the "mount --bind" is the only way to dynamically change the directory content.
Click to expand...
Click to collapse
thanks,
this is genius
I'm not using your script (have myself some ux & scripting skills) but did not know about the -bind option on android
Ridiculously simple and efficient
Did it my own way and it works great
Thanks a lot for this

dawabz94 said:
thanks,
this is genius
I'm not using your script (have myself some ux & scripting skills) but did not know about the -bind option on android
Ridiculously simple and efficient
Did it my own way and it works great
Thanks a lot for this
Click to expand...
Click to collapse
Then why not share with us please !
Let us know how you did

Yes I'd like to know another method also.!
Sent from my GT-I9100 using XDA

Chairmansaab said:
Then why not share with us please !
Let us know how you did
Click to expand...
Click to collapse
Hi,
it's very easy indeed, once you got the point.
I do most of my stuff using an "adb shell" session so I'll post here my steps to get it working.
Also I like simple implementation so my script is the strict minimum needed to mount necessary folders
I assume you have a rooted device with working busybox and a kernel that supports /etc/init.d/
I suggest you do the test on a dummy folder before applying on a real folder.
So start by creating a folder called /sdcard/dummy
Do it the way you want , I do it with an "adb shell" session
Code:
cd /sdcard
mkdir dummy
Then copy some files in it (photos for examples)
Code:
cd /sdcard
cd DCIM
cd Camera
cp `ls -1 |tail -5` /sdcard/dummy
From now on, we consider we want to move transparently /sdcard/dummy to the external SD
1. move the folder to the external sd
CAUTION : I'm running a CM9 rom => my external sd is mounted on /mnt/emmc
Standard samsung sdcard mount is /sdcard/external_sd
The path might be different according to your brand and rom
Moving the folder code
Code:
cd /sdcard
mv dummy /mnt/emmc/
2. Create the mount point in the indernal SD
Code:
cd /sdcard
mkdir dummy
3.a Check the mount is successful by manually doing it
Code:
mount --bind /mnt/emmc/dummy /sdcard/dummy
3.b Check you see exactly the same thing on both folders
Both commands should return exactly the same output
Code:
ls -l /sdcard/dummy
Code:
ls -l /mnt/emmc/dummy
If everything is fine, then you're good to go
4. Automate mount at boot time
Create a script in /etc/init.d to automate the mount at boot time
I personally use "vi" but most people prefer graphical UIs, I can't recommend any here, do it your own way
So basically you would go root,remount /system in read/write mode and create the file
Code:
su
mount -o remount,rw /dev/block/mmcblk0p9 /system
cd /etc/init.d
vi 90binds
Insert following lines, save and exit
Note that the "sleep 60" is to let the system boot up before mounting partitions (thanks to the initial script shared here)
Code:
#!/system/bin/sh
sleep 60
mount --bind /mnt/emmc/dummy /sdcard/dummy
Change owner and permissions, flush disk cache and remount /system in read only
Code:
su
mount -o remount,rw /dev/block/mmcblk0p9 /system
cd /etc/init.d
chown root:shell
chmod 6755 90binds
sync
mount -o remount,ro /dev/block/mmcblk0p9 /system
To check, run
Code:
su
cd /etc/init.d
ls -l 90binds
The output should look like this :
Code:
-rwsr-sr-x 1 root shell [I]0 MMM D HH:MM[/I] 90binds
5. Now you can reboot and check - after reboot - that the mount is done
Both commands should return exactly the same output (always ran in an "adb shell" session)
Code:
ls -l /sdcard/dummy
Code:
ls -l /mnt/emmc/dummy
6. Now you're good to move other folders
Basically, you move the folder to external SD
Create the mount point on the internal SD
Append the mount command in the 90binds script
And that's it
Hope this helps
---------- Post added at 11:09 AM ---------- Previous post was at 11:04 AM ----------
benc88 said:
Yes I'd like to know another method also.!
Sent from my GT-I9100 using XDA
Click to expand...
Click to collapse
Just posted
Take time to read and understand the idea

Related

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

How to create terminal script

Hey, can someone tell me how to create a script to run a terminal command. I looked up google but didn't find any good results.
Open a new file, and write:
Code:
#!/system/bin/sh
your_command
another_command
another_one_xD
Save the file with sh extension, and run your script as follows:
Code:
su #optional, if your script needs root access.
sh yourscript.sh
If you get an error, probably need to grant permissions to your script, so:
Code:
chmod +x yourscript.sh
And try again.
Granting su is
$ su
Correct?
And thanks for the reply :]
Sent from my XT862 using Tapatalk 2
Yep
When you set the permissions, you only have to do that once right?
Yes.
I'm trying to build a script to move pics and video from my internal storage to external storage. I have the script made and on my phone but when I run it, I get an error: "failed on /storage/sdcard0/DCIM/Camera/*.jpg" - Cross-device link . Any idea what that means?
mmurphmsu said:
I'm trying to build a script to move pics and video from my internal storage to external storage. I have the script made and on my phone but when I run it, I get an error: "failed on /storage/sdcard0/DCIM/Camera/*.jpg" - Cross-device link . Any idea what that means?
Click to expand...
Click to collapse
Move (mv) only move the directory entry, not the actual data. Because of this, you can not move files from one disk to another (e.g. from internal to sdcard), hence the cross device error. You'll have to copy and then delete the original.
kuisma said:
Move (mv) only move the directory entry, not the actual data. Because of this, you can not move files from one disk to another (e.g. from internal to sdcard), hence the cross device error. You'll have to copy and then delete the original.
Click to expand...
Click to collapse
That seems to have done the trick but I have found another issue. When going into multiple directories (/storage/sdcard0/DCIM/Camera) from the script or even the root directory, I get a No Such file or directory error. But I can CD into that directory and manually cp and rm the files. Any idea why that is happening?
mmurphmsu said:
That seems to have done the trick but I have found another issue. When going into multiple directories (/storage/sdcard0/DCIM/Camera) from the script or even the root directory, I get a No Such file or directory error. But I can CD into that directory and manually cp and rm the files. Any idea why that is happening?
Click to expand...
Click to collapse
You've simply done something wrong. Show us the script.
Here is the script I created:
#!/system/bin/sh
#
#
#
#
#Move Pictures from Internal Storage to External Storage media
cp /storage/sdcard0/DCIM/Camera/IMG* /storage/sdcard1/DCIM/Camera
rm /storage/sdcard0/DCIM/Camera/IMG*
#
#
#
#Move Videos from Internal Storage to External Storage media
cp /storage/sdcard0/DCIM/Camera/VID* /storage/sdcard1/DCIM/Camera
rm /storage/sdcard0/DCIM/Camera/VID*
I put the script in the root directory and run it from there. Its permissions are rwxrwxr
mmurphmsu said:
Here is the script I created:
#!/system/bin/sh
#
#
#
#
#Move Pictures from Internal Storage to External Storage media
cp /storage/sdcard0/DCIM/Camera/IMG* /storage/sdcard1/DCIM/Camera
rm /storage/sdcard0/DCIM/Camera/IMG*
#
#
#
#Move Videos from Internal Storage to External Storage media
cp /storage/sdcard0/DCIM/Camera/VID* /storage/sdcard1/DCIM/Camera
rm /storage/sdcard0/DCIM/Camera/VID*
I put the script in the root directory and run it from there. Its permissions are rwxrwxr
Click to expand...
Click to collapse
Does /storage/sdcard1/DCIM/Camera exists? Try add:
mkdir -p /storage/sdcard1/DCIM/Camera
... to the script before you begin the copy. This will create the destination(s) in case of non-existent.
Also, your cp and rm command will fail with this error if there aren't any files named both IMG* and VID* in the source directory.
kuisma said:
Does /storage/sdcard1/DCIM/Camera exists? Try add:
mkdir -p /storage/sdcard1/DCIM/Camera
... to the script before you begin the copy. This will create the destination(s) in case of non-existent.
Also, your script will fail with this error if there aren't any files named both IMG* and VID* in the source directory.
Click to expand...
Click to collapse
Yes it exists. I can navigate to the directory in Root Explorer. I tried running the script in Root Explorer but it didn't move the two pics i have in the /storage/sdcard0/DCIM/Camera directory to the /storage/sdcard1/DCIM/Camera directory.
mmurphmsu said:
Yes it exists. I can navigate to the directory in Root Explorer. I tried running the script in Root Explorer but it didn't move the two pics i have in the /storage/sdcard0/DCIM/Camera directory to the /storage/sdcard1/DCIM/Camera directory.
Click to expand...
Click to collapse
And you DO have files named IMG* and VID* in your source directory?
kuisma said:
And you DO have files named IMG* and VID* in your source directory?
Click to expand...
Click to collapse
Yes. I took to pictures and then tried running it and it still fails. I wonder if its not working cause I'm on CM10?
mmurphmsu said:
Yes. I took to pictures and then tried running it and it still fails. I wonder if its not working cause I'm on CM10?
Click to expand...
Click to collapse
You realise that even with pictures in the directory, you'll still get this error from the next operations you try executing on the videos? Still, the script should a) still copy the images, and b) not terminate due to this error anyway (i.e. consider it a warning).
But you say the images are not copied. Quite odd, I'd say.
Add a path to the script (export PATH=/system/bin:/system/xbin plus the places you need), add a test "echo Running" to make sure the script actually is launched by Root Explorer. And add +x permissions for all, even "other". You can also add:
echo /storage/sdcard0/DCIM/Camera/IMG*
... before the first copy. This will show you what files matching your expression.
I'll just manually move them. I was just hoping for an easier way until CM10 is enabled to save pictures to the external SD card.
mmurphmsu said:
I'll just manually move them.
Click to expand...
Click to collapse
Take this as an opportunity to learn more about script programming, I'd say.
Experience is what we get when we expected something else.
kuisma said:
Take this as an opportunity to learn more about script programming, I'd say.
Experience is what we get when we expected something else.
Click to expand...
Click to collapse
I do a little in UNIX at work that's why I tried this. I really want to learn how to program for actual Android apps. Just need to find something to help me get started, as I have no clue where to start.
Where save the file ?
Hello
I'm french and don't speak english very well ....
I try to do what is explain in this topic ( for tethering with a Sony Ericsson KYNO V - ics 4.0.4 with root access ....
I don't understand where to save the file with sh extension
What i want to run is : #!/system/bin/sh
iptables -P FORWARD ACCEPT
iptables -t nat -A POSTROUTING -o rmnet0 -j MASQUERADE
My script is :
su root
sh scripttether.sh
Thank you very much for your help
BR
RoberGalarga said:
Open a new file, and write:
Code:
#!/system/bin/sh
your_command
another_command
another_one_xD
Save the file with sh extension, and run your script as follows:
Code:
su #optional, if your script needs root access.
sh yourscript.sh
If you get an error, probably need to grant permissions to your script, so:
Code:
chmod +x yourscript.sh
And try again.
Click to expand...
Click to collapse

File copy and replacing in /system directory with root permission programmatically?

Can anyone kind enough show me how to copy files from my app assets folder to /system folder? I know how to get root access and all. For example: I want to copy file from "/assets/lib/libs.so" and check if this file already exist, if it does replace it to new "/system/lib/libs.so".
I think You could create a script (its language should not be too difficult) and make it start on every boot (every scripter Can do this) But I don't know how much time it would take and if You reboot often... Try to look for an app that runs script programmatically
Sent from R'lyeh using Cthulhu app
tsirhcitna said:
I think You could create a script (its language should not be too difficult) and make it start on every boot (every scripter Can do this) But I don't know how much time it would take and if You reboot often... Try to look for an app that runs script programmatically
Sent from R'lyeh using Cthulhu app
Click to expand...
Click to collapse
Sorry I haven't been clearly state that I want to write an app that does this, like in java.
Ooops my fault! I know java for PC but I never studied it for Android (when I tried to program for android the emulator taking twenty minutes to start stopped me). I don't know how to help you but seeing nobody is answering I can suggest you to go on Stack Overflow, it's all about coding, and all the answer I've seen on it where very good (You can also look for file manipulation on some android java tutorial)
Sorry I can't help you more
tsirhcitna said:
Ooops my fault! I know java for PC but I never studied it for Android (when I tried to program for android the emulator taking twenty minutes to start stopped me). I don't know how to help you but seeing nobody is answering I can suggest you to go on Stack Overflow, it's all about coding, and all the answer I've seen on it where very good (You can also look for file manipulation on some android java tutorial)
Sorry I can't help you more
Click to expand...
Click to collapse
can u write java code that wrap around command line that copy file to system folder? this will work, cos i can get su, just need to mount rw /system/lib then copy file from my app assets folder and replace the file in /system/lib
homi3kh said:
Can anyone kind enough show me how to copy files from my app assets folder to /system folder? I know how to get root access and all. For example: I want to copy file from "/assets/lib/libs.so" and check if this file already exist, if it does replace it to new "/system/lib/libs.so".
Click to expand...
Click to collapse
I suppose you're getting Root Permission running su command with Runtime.getRuntime().exec... right?
That's fine, you now need to run another commands:
To check if /assets/lib/libs.so (or any other file) exists:
Code:
ls /assets/lib | grep libs.so
If the file exists, you'll get "libs.so" as output of that command (otherwise, you will not get anything).
To remount /system in RW mode:
Code:
mount -o rw, remount -t yaffs2 /dev/block/mtdblock4 /system
Ok, now you can copy your file (or files, I dunno):
Code:
cp /assets/lib/libs.so /system/lib/libs.so
And finally, remount /system in RO mode again:
Code:
mount -o ro, remount -t yaffs2 /dev/block/mtdblock4 /system
Pretty easy, it isn't? :highfive:
Note: I highly recommend you to use RootTools, it's a lib to run commands as root very easily
RoberGalarga said:
I suppose you're getting Root Permission running su command with Runtime.getRuntime().exec... right?
That's fine, you now need to run another commands:
To check if /assets/lib/libs.so (or any other file) exists:
Code:
ls /assets/lib | grep libs.so
If the file exists, you'll get "libs.so" as output of that command (otherwise, you will not get anything).
To remount /system in RW mode:
Code:
mount -o rw, remount -t yaffs2 /dev/block/mtdblock4 /system
Ok, now you can copy your file (or files, I dunno):
Code:
cp /assets/lib/libs.so /system/lib/libs.so
And finally, remount /system in RO mode again:
Code:
mount -o ro, remount -t yaffs2 /dev/block/mtdblock4 /system
Pretty easy, it isn't? :highfive:
Note: I highly recommend you to use RootTools, it's a lib to run commands as root very easily
Click to expand...
Click to collapse
yes this is what i'm asking for but can you wrap it with RootTools code for me too? it's a bit confusing cos I don't know much about command line.
Ok. It's kinda easy, BTW:
To grant root permissions (If you already have root permissions in other way, you don't need to do this again):
Code:
if (RootTools.isAccessGiven()) {
// your device is rooted!! The fun can begin :)
}else{
// Not rooted... no fun here :(
}
Now, an example using 1 command (you'll need to develop the rest). Checking if /assets/lib/libs.so exists:
Code:
try {
List<String> output = RootTools.sendShell("ls /assets/lib | grep libs.so",-1);
if (output.get(0).equals("libs.so")){ //output.get(0) is the way to read 1 line of the command output
//the file exist... you can continue
}else{
//something is wrong, or the file is missing... =/
}
} catch (Exception e) {
// something went wrong, deal with it here
}
Proceed in the same way to run the other commands. Note that there are ways to run several commands using RootTools, you can check them in the Usage Page (I think will be a bit easy, since you don't need to read the output of the other commands).

Useful Commands in Terminal Emulator

Hi guys!
I created this thread mainly because many useful things can be done in Terminal emulator. I will show you some simple commands which are useful.
Very useful if you don't have Root explorer when you need it.
Make sure you take a Nandroid backup before you try out just in case you can restore when you do something wrong!
You can get terminal Emulator from here: https://play.google.com/store/apps/details?id=jackpal.androidterm&hl=en
Note: Most commands need root. So type su and press enter and grant superuser permissions to Terminal Emulator!
First type this command before using any of the commands below just in case(needs root)
Code:
su
Some useful commands:
Turning device off (Turns your device off very fast!! ):
Code:
poweroff
Rebooting:
Code:
reboot
Rebooting to Recovery
Code:
reboot recovery
Rebooting to download mode:
Code:
reboot download
Forcing Most Apps to install to SDcard(Root needed with Terminal Emulator, no need root with ADB):
Code:
pm setInstallLocation 2
Alternatively, you can type 0 at the end instead of 2 for Auto location install mode or 1 for Internal memory install mode
To check what the current install location is:
Code:
pm getInstallLocation
Mounting R/W in system(Use with caution)
Code:
mount -o rw,remount -t /system
If above one doesnt work, try this.
Code:
mount -o rw,remount -t ext3 /dev/block/mmcblk1p21 /system
Unmounting R/W in system.
Code:
mount -o ro,remount -t /system
If above code doesn't work, try this
Code:
mount -o ro,remount -t ext3 /dev/block/mmcblk1p21 /system
Moving files from sdcard to system (Use after mounting R/W):
Code:
busybox cp /sdcard/<path> /system/<path>
Example: busybox cp /sdcard/demo/framework-res.apk /system/framework/
Changing file permissions to rw-r--r-- (Use after mounting R/W):
Code:
chmod 644 <path>
Example 1: chmod 644 /system/app/mms.apk
Example 2: chmod 644 /system/app/*.apk (This command changes the file permission of all apps in the folder to rw-r--r--)
Changing the current directory:
Code:
cd <path>
Example: cd /sdcard
Listing all the files and folders under the current directory:
Code:
ls
If you want to view all the files and folders in your sdcard, type:
cd /sdcard
ls
Making a new folder:
Code:
mkdir <path>
Example: mkdir /sdcard/newfolder
Removing files (For System files, Use after mounting R/W)
Code:
rm <path>
Example: rm /system/app/demoapp.apk
Removing Folders:
Code:
rmdir <path>
Get info of your build.prop values
Code:
getprop
That's all for now. I will add a few more later!
If you have any more new commands or if I have given an improper command, feel free to post it in the thread
Thanks for reading.
Have you any idea on why if I were to enter pm set-install-location 2(SD card), the next line would be "Killed"?
UserU said:
Have you any idea on why if I were to enter pm set-install-location 2(SD card), the next line would be "Killed"?
Click to expand...
Click to collapse
I don't understand your question...
Anyways...Thanks for reminding me of that command!
system.img said:
I don't understand your question...
Anyways...Thanks for reminding me of that command!
Click to expand...
Click to collapse
No problem. This is the output from the Terminal Emulator. The bold command changes the default install dir to the SD card:
u0 [email protected]:/ $ pm set-install-location 2
Killed
137|u0 [email protected]:/ $
Click to expand...
Click to collapse
UserU said:
No problem. This is the output from the Terminal Emulator. The bold command changes the default install dir to the SD card:
Click to expand...
Click to collapse
I never got that problem on adb.
Let me see....
This:
mount -o remount rw system
Is much easier than the previous one to mount readwrite.
Sent from my GT-P7300 using xda app-developers app
panpjp said:
This:
mount -o remount rw system
Is much easier than the previous one to mount readwrite.
Sent from my GT-P7300 using xda app-developers app
Click to expand...
Click to collapse
Isnt it /system?
ok...will add to op.
Thanks.
system.img said:
Isnt it /system?
ok...will add to op.
Thanks.
Click to expand...
Click to collapse
Not necessary for it to be /system
Sent from my Desire using xda app-developers app
panpjp said:
Not necessary for it to be /system
Sent from my Desire using xda app-developers app
Click to expand...
Click to collapse
Ok....
system.img said:
I never got that problem on adb.
Let me see....
Click to expand...
Click to collapse
Here's a thread which shed some light on the similar issue.
http://forum.xda-developers.com/showthread.php?t=1495423
UserU said:
Here's a thread which shed some light on the similar issue.
http://forum.xda-developers.com/showthread.php?t=1495423
Click to expand...
Click to collapse
I got it.
It needs root.
So type
su
pm set-install-location 2
Then you are done!
wow thanks !!
Bassesh said:
wow thanks !!
Click to expand...
Click to collapse
Welcome!
Useful
A question: once i tried to type
bootanimation
Click to expand...
Click to collapse
The boot animation started but..i couldn't stop it!! I could "use" the phone (i caught 4 or 5 screens) but the only thing i saw was the bootanimation.. i had to pull the battery off and restart my ace.. any solution??
Toni5830 said:
Useful
A question: once i tried to type
The boot animation started but..i couldn't stop it!! I could "use" the phone (i caught 4 or 5 screens) but the only thing i saw was the bootanimation.. i had to pull the battery off and restart my ace.. any solution??
Click to expand...
Click to collapse
That is the use of the bootanimation command. You can stop it either by pulling battery or closing terminal emulator!
But what I did to stop it was to rotate my phone to landscape and somehow close terminal emulator.
But in ADB it is easier to stop using exit command.
how to get info about /system memory and /data memory ?
rajxelton said:
how to get info about /system memory and /data memory ?
Click to expand...
Click to collapse
What info do you exactly want? Free Space, Partition Size or Used space?
system.img said:
What info do you exactly want? Free Space, Partition Size or Used space?
Click to expand...
Click to collapse
partition size. well can you tell me for all.
Anyone know a command to trigger media scanner?
Thanks for the commands. Quite new to all of this and these will help me understand things a little better

[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)

Categories

Resources