[Q] How to move obb data from internal SD to internal storage? - Android Q&A, Help & Troubleshooting

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)

Related

[EXPANDSD] Join your external SD with internal SD!

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

[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

[Q] Configure a permanent mount -o bind in init.d

I want to set the cache folder of Google Music to the external sdcard using mount -o bind command
I created a file (without extension) that contains the following
Code:
#!/system/bin/sh
mount -o bind /emmc/Android/data/com.google.android.music/ /sdcard/Android/data/com.google.android.music/
I made sure the target folder exists and saved the file to /system/etc/init.d, but in fact it looks like the script isn't executed.
P.S. the script file's properties are: -rwxr-xr-x, Owner: 00000 root, Group: 02000 shell.
Storing permanent data
How?

[Q] Hosts file ressetting on reboot

Does anybody know why my hosts file gets reset after a reboot no matter whether I change with adaway or adblock or if I manually replace the hosts file myself and set to read only. Have searched about and only solution I read about was get a custom kernel. Although I am already on a custom kitkat ROM and using dorimanx kernel for galaxy s2. Also never had problems with hosts resetting on jb or ICS. Even creating a symlink to data/data/hosts doesn't work. On reboot the symlink just gets replaced with the original useless hosts file.
Sorry to bump but it is irritating and can't find a solution.
just some hints,
hosts file is located on /system partition which should be read only mounted during runtime.
check:
Code:
# mount | grep /system
/dev/block/mmcblk0p9 /system ext4 ro,seclabel,relatime,user_xattr,barrier=1,data=ordered 0 0
ro is ok. If so, the file can be changed only during boot (some init script) or later by app with root permission.
check if some init script is not involved:
Code:
# grep hosts /init*
Code:
#grep hosts /system/etc/init.d/*
Is there any output of the commands? I'm on i9100/CM10.2 and there is no output.
Then would be good to revoke root permissions to all apps (not unroot) and see if the issue is still there.
and also check the time of last change of the file:
Code:
ls -l /system/etc/hosts
is it realy during boot?
After spending entirely too much time on this I finally have a working solution. Save the contents of this script to your internal SD card. Ensure the last line is a blank carriage return.
Code:
#!/system/bin/sh
sleep 10
mount -o rw,remount /system
cp /storage/emulated/0/Download/working/hosts /system/etc
Install Script Manager (SManager), and set this script as: on boot, executable, as root. This will then copy your custom "hosts" file under your SDcard to /system/etc after 10 seconds.
Using this script through init.d didn't work for me, which I guess means whatever was over-writing my "hosts" file was doing after the init.d process.
Definitely remount system partition to read only again. Append following line to your script:
Code:
mount -o ro,remount /system
d0gd3v said:
Definitely remount system partition to read only again. Append following line to your script:
Code:
mount -o ro,remount /system
Click to expand...
Click to collapse
good call, thanks

Categories

Resources