[Q] How to mount with bind/rbind under ICS - General Questions and Answers

I want to make a script which will allow me to mount (mount bind) one folder to another folder.
I need this way to work with my navigation and to switch maps folder.
When I try with adb shell this commands - everything is fine:
Code:
mount -o rbind /mnt/sdcard/Sygic/Maps.NT /mnt/sdcard/Sygic/Maps
Next I made a script:
Code:
#!/system/bin/sh
#umount -l /sdcard/Sygic/Maps
mount -rw -o rbind /mnt/sdcard/Sygic/Maps.NT /mnt/sdcard/Sygic/Maps
am start -a com.sygic.aura -n com.sygic.aura/com.sygic.aura.SygicNaviActivity
exit 0
That point forward started problems - can't start this script, never mind if it's on SDCard or /system/app or where else (perm. rw-r-r-)
After that tried SManger - won't work neither like executable as root or script as root
Last try was to make brand new script within SManger, made it simplest like only one row:
Code:
mount -o rbind /mnt/sdcard/Sygic/Maps.NT /mnt/sdcard/Sygic/Maps
or
Code:
/sbin/mount -o rbind /sdcard/Sygic/Maps.NT /sdcard/Sygic/Maps
but w/o success
I need help, how to make this mount within script, will prefer SM Widget to start one or another mount.
Need advice, thanks to anyone !

Related

something up with my shell scripts.

I seem to be frequently flashing or messing up my G1 so I decided to write some shell scripts to help out but they seem to only half work if at all. Actually I'm not sure what they did because they displayed no output.
This script is supposed to backup the default init.rc and mountd.conf files then replace the existing ones with the modified ones.
Though it does not work.
Code:
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
mkdir /system/sd
busybox cp -a /system/etc/mountd.conf /sdcard/recovery/mountd.conf.bak
busybox cp -a /system/init.rc /sdcard/recovery/init.rc.bak
busybox cp -a /sdcard/recovery/mountd.conf /system/etc/mountd.conf
busybox cp -a /sdcard/recovery/init.rc /system/init.rc
then this is the next set to move the apks and the program caches which doesn't work.
Code:
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
busybox cp -a /data/app /system/sd
rm -r /data/app
ln -s /system/sd/app /data/app
busybox cp -a /data/app-private /system/sd/app-private
rm -r /data/app-private
ln -s /system/sd/app-private /data/app-private
rm -R /data/data/com.android.browser/cache/webviewCache
ln -s /sdcard/cache/webviewCache /data/data/com.android.browser/cache/webviewCache
rm -R /data/data/com.android.vending/cache
ln -s /sdcard/cache/marketCache /data/data/com.android.vending/cache
rm -R /data/data/com.google.android.street/cache
ln -s /sdcard/cache/streetCache /data/data/com.google.android.street/cache
reboot
Plus both run and output no errors either. Who knows what problems I'll run into because I have no idea what they actually did.
Anyone see anything wrong here?
Well I'll help you.
1-) After you back up the mount and stuff and put the other back, you MUST reboot before keep going.
2-)After boot then you can copy the files or make the symlink. I suggest you dont copy the app to the sdcard on teh scrip since they should be there already. so do that manually once then the script just delete the folders and then crate the symlinmks.
I have a menu that does that and I have got some experience as why it works one day and not the other.
Rafase282 said:
Well I'll help you.
1-) After you back up the mount and stuff and put the other back, you MUST reboot before keep going.
Click to expand...
Click to collapse
I took the reboot out after the mountd.conf and init.rc did not appear to copy due to the lack of /dev/mmcblk0p2 hoping to see some sort of output why it did not run. Unfortunately it runs and backs up the files but does not replace them with the modded ones.
Rafase282 said:
2-)After boot then you can copy the files or make the symlink. I suggest you dont copy the app to the sdcard on teh scrip since they should be there already. so do that manually once then the script just delete the folders and then crate the symlinmks.
Click to expand...
Click to collapse
Not copying the apps is a good idea, modified the script to not do so.
Rafase282 said:
I have a menu that does that and I have got some experience as why it works one day and not the other.
Click to expand...
Click to collapse
Does Android require that you do a chmod on all shell scripts first?
On Debian I usually just use sudo sh ./ and it runs the script w/o changing anything on the file permissions so I figured Android would be similar if I just ran them as root. Still I see a lot of people requiring a chmod 777 on any guide referring to running shell scripts.
I will try that and report back with my findings. Thanks for replying.
Does Android require that you do a chmod on all shell scripts first? I just have to type m oon anywhere in the androud shell and my scripts run, for that i put it on /system/bin and do a chmod 4755 to the file. it is still needed to type su before you run the script.
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
mkdir /system/sd
cp /sdcard/media/Data/mountd.conf /system/etc/mountd.conf
cp /sdcard/media/Data/init.rc /system/init.rc
Thats my code for copying the modified files to the right place. So maybe you should try that.
Oh for androoid you dont unless you put it on /system/bin then you will have to use sude and sometiems it still wont run due to lack or permisions so is better to do a chmod 4755
Well I made the changes suggested and did a chmod on all the files prior to running but with no luck.
The odd thing is if I use the shell scripts as a guide list it works perfectly but if I try to launch them as a shell script all sorts of strange undesirable things happen to my phone.
The time consumed trying to use the scripts and recover from what happens from what they do out weight the effects of typing everything in.
joshtheitguy said:
Well I made the changes suggested and did a chmod on all the files prior to running but with no luck.
The odd thing is if I use the shell scripts as a guide list it works perfectly but if I try to launch them as a shell script all sorts of strange undesirable things happen to my phone.
The time consumed trying to use the scripts and recover from what happens from what they do out weight the effects of typing everything in.
Click to expand...
Click to collapse
you can only run the script once .. when the "ln -s" has already been done it has to be undone before trying to run the script again .. otherwise you would be copying the files onto themselves .. not sure if you've tried running it more than once
LucidREM said:
you can only run the script once .. when the "ln -s" has already been done it has to be undone before trying to run the script again .. otherwise you would be copying the files onto themselves .. not sure if you've tried running it more than once
Click to expand...
Click to collapse
These scripts were intended for my usage after a system restore from a update.zip file which wipes /system in the process.
My intentions were to:
1. remount the fs rw
2. copy the original init and mountd files to the sd then copy the modified to their respective places in the system folders then reboot
3. reboot then create the sym links appropriately then move my caches too
Well unfortunately the only thing that works is the backing up of the original init and mountd files.
joshtheitguy said:
These scripts were intended for my usage after a system restore from a update.zip file which wipes /system in the process.
My intentions were to:
1. remount the fs rw
2. copy the original init and mountd files to the sd then copy the modified to their respective places in the system folders then reboot
3. reboot then create the sym links appropriately then move my caches too
Well unfortunately the only thing that works is the backing up of the original init and mountd files.
Click to expand...
Click to collapse
yes .. but you can't create the sym links when they already exist .. running the update.zip only wipes the /system .. not /data .. if the links were there before the update.zip they will be there after

using the internal memory as a virtual sdcard

I managed to break my micro sd card in half today and I wasn't able to pickup a class 10 or 6 replacement locally so I thought I could use some of the 6gb of internal memory as a virtual filesystem to get me out of trouble.
So, after quickly looking at the android docs and the supported busybox commands I created a 2gb sdcard.img in /data and mounted to /sdcard. I copied some files to it with astro filemanager and fired up raging thunder 2 and it went ahead and downloaded the game data to /sdcard/ and worked correctly.
But, a few apps won't recognise it as an sdcard (Motorola SD card and phone storage settings applet) as well as things like PlayPro (states I have no sdcard present). I thought perhaps I could modify the /etc/vold.fstab file to auto mount the sdcard.img I created using vi but I'm a bit clueless as to what I should change on the dev_mount /sdcard line to get it automounted at boot and hopefully fool the rest of the apps into thinking it is a physical sdcard.
Can anyone possibly point me in the right direction? Not sure how to invoke cmd mode in vi using the milestone qwerty either but I'll keep digging.
What I did (roughly), maybe I'm going about it wrong but any advice would be appreciated.
1. rooted device
2. installed the free terminal app from the market
3. fired up the terminal shell
4. su
5. dd if/dev/zero of=/data/sdcard.img bs=1024 count=1 seek=2000000
6. busybox mkfs.vfat /data/sdcard.img (didn't seem to support -F 32)
7. busybox mount -o loop /data/sdcard.img /sdcard/
+ 1 for this, it would be great to can use internal storage for user data
Why do you let this nice post die.. so "flibbulator" found anything more out?.. I'd like to know more.. like if you got it to work with Music Players and Video players??
Try to mount /data/sdcard.img to /mnt/sdcard (/sdcard is a link to /mnt/sdcard)
or try "export EXTERNAL_STORAGE /sdcard"
I made in a different way: created a 4GB storage.img in /data and mounted it in /sdcard/storage, so internal storage is finally usable for user data
the problem was to set mount point on boot, I can't find a way to execute a script on boot (you can't permanently modify init.rc)
flibbulator said:
What I did (roughly), maybe I'm going about it wrong but any advice would be appreciated.
1. rooted device
2. installed the free terminal app from the market
3. fired up the terminal shell
4. su
5. dd if/dev/zero of=/data/sdcard.img bs=1024 count=1 seek=2000000
6. busybox mkfs.vfat /data/sdcard.img (didn't seem to support -F 32)
7. busybox mount -o loop /data/sdcard.img /sdcard/
Click to expand...
Click to collapse
I have actually tried this on my Droid2Global, and I get the error "unknown operand if/dev/zero" I feel like I am missing the point or do not fully understanding how to use the "dd" command?
the correct syntax is:
dd if=/dev/zero of=/data/sdcard.img bs=1024 count=4194340
4194340 --> 4GB
patton82 said:
the correct syntax is:
dd if=/dev/zero of=/data/sdcard.img bs=1024 count=4194340
4194340 --> 4GB
Click to expand...
Click to collapse
Thank you bro.
Quick question I keep getting these errors. I do have a folder in "/" named "sdcard-int"
Better Terminal Emulator Pro
/ # busybox mount -o loop /data/sdcard.img /sdcard-int/
mount: can't setup loop device: No such file or directory
/ # busybox mount -o /data/sdcard.img /sdcard-int
mount: can't read /etc/fstab: No such file or directory
/ #
Sent from my DROID2 GLOBAL using Tapatalk
you can't place anything in root folder, /sdcard is a link to /mnt/sdcard and is created by init.rc (you can't edit init.rc, it's provided by boot.img, so need to extract from boot.img and repack)
I made in this way but I have to manually execute a script or a command from terminal after every boot to mount storage.img
mkdir /sdcard/storage
su
dd if=/dev/zero of=/data/storage.img bs=1024 count=4194340
busybox mkfs.vfat /data.storage.img
mount -o loop -t vfat /data/storage.img /sdcard/storage
Will be lost anything after reboot when use this storage?
Sent from my MotoA953 using XDA App
all the stuff in img file will not be lost, as long as you put it in /data/
on the contrary the mount point must be restored after reboot
patton82 said:
you can't place anything in root folder, /sdcard is a link to /mnt/sdcard and is created by init.rc (you can't edit init.rc, it's provided by boot.img, so need to extract from boot.img and repack)
I made in this way but I have to manually execute a script or a command from terminal after every boot to mount storage.img
mkdir /sdcard/storage
su
dd if=/dev/zero of=/data/storage.img bs=1024 count=4194340
busybox mkfs.vfat /data.storage.img
mount -o loop -t vfat /data/storage.img /sdcard/storage
Click to expand...
Click to collapse
Thank you, I will use the Thank you button when I login via PC.
I still get the same error, I know that I'm doing something incorrectly or maybe I don't understand "mount" comment correctly?
/ $ su
/ # mkdir /sdcard/storage
/ # dd if=/dev/zero of=/data/storage.img bs=1024 count=41943404194340+0 recordsn
4194340+0 records out
4295004160 bytes (4.0GB) copied, 339.823883 seconds, 12.1MB/s
/ # busybox mkfs.vfat /data/storage.img
/ # mount -o loop -t vfat /data/storage.img /sdcard/storage
mount: can't setup loop device: No such file or directory
/ #
I am using my sdcard also, I'm not too sure if that makes any difference?
Sent from my DROID2 GLOBAL using Tapatalk
Better terminal pro uses BASH shell, I presume
try to switch to android shell, in preferences
or to use terminal emulator (free) from market
Okay, I tried Android Terminal Emulator, and this is a new error.
export PATH=/data/local/bin:$PATH
$ $ su
# mount -o loop -t vfat /data/storage.img /sdcard/storage
ioctl LOOP_SET_FD failed: Device or resource busy
#
Not too sure where to go now. I thank you again for all your help, and time.
Sent from my DROID2 GLOBAL using Tapatalk
resource busy, you have to reboot the phone
I use Gscript lite, add a script with the string
mount -o loop -t vfat /data/storage.img /sdcard/storage
and create a shortcut to homescreen, so when I reboot, I can mount the img file in one click
Cool mod for my ROM. Could I take it??
sure, they are simple shell commands
the best would be to do what happen with Samsung Galaxy S: internal storage mounted as sdcard and physical sdcard mounted in a folder /sdcard/sd
storage.img is 3-4 times faster than my peak 8GB class 6
There is an application "Autostart" in the market, which can automatially execute a script with root after boot up.
I up because I'm now also interested in making profit of the huge internal storage. I'd like to put my wikipedia data from wikidroyd to the internal storage. Hopefully I'm skilled enough to follow the given steps...I doubt that though
fKngFtd said:
Okay, I tried Android Terminal Emulator, and this is a new error.
export PATH=/data/local/bin:$PATH
$ $ su
# mount -o loop -t vfat /data/storage.img /sdcard/storage
ioctl LOOP_SET_FD failed: Device or resource busy
#
Not too sure where to go now. I thank you again for all your help, and time.
Click to expand...
Click to collapse
Guys, I need your help! I have exactly. The same problem:
Every time I try to mount my storage.img I get
Ioctl LOOP_SET_FD failed: Device or resource busy.
I rebooted several times and also tried to mount smaller images (first I tried 3gb then I tried 1mb).
Any solution?
Edit: I solved it myself. I always forgot to punch in busybox before the command. Now it worked for me!!
I do have a question now. With help of Gscript I made a shortcut to mount the storage.img to my sdcard. But my pc wont recognise the sdcard as long as the image is mounted. What is the command to unmount the partition so I wouldnt have to reboot my phone before connecting it to the pc...?
Any help is much appreciated! Thx
(Something like busybox unmount -o loop -t vfat...?)
Sent from my MotoA953 using XDA App

[Q] Can't mount /system as r/w

Have an HTC hero with CM7 stable. Been trying to modify sysctl.conf to increase the speed a little (if thats possible, CM7 is fast). I've used the command in ./adb shell and terminal emulator:
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
When I type mount it displays /system as a r/w partition but I still can't edit the sysctl.conf file. When I do try to edit, the shell says that the directory doesn't exist (/ect/sysctl.conf).
Even with simpler commands like "adb pull /system/ect/sysctl.conf /" still come back as directory doesn't exist.
What am I doing wrong? Ultimately if I can want to get the sysctl file to my PC to edit and place back on the phone.
Have you tried using something like Root Explorer? While learning & knowing ADB comes in handy, I find most things are easier through Root Explorer. You can just copy the file to your SD card, then to your computer.
EDIT: On second look, you have /system/ect... instead of /system/etc...
I also believe it should be mtdblock4 instead of mtdblock3, but I could be wrong. I'm not good with this kind of stuff.
Type in mount to see what device is currently mounted as /system...I would just double check
Sent from my Droid using XDA App
This command should also work:
Code:
mount -w -o remount /system /system
I typed mount in cmd. Says that /system is in mtdblock3. I will try root explorer and see if it fixes my woes. Thanks.

[Solution]SAMSUNG GIO S5660: adb remount failed

Hi guys,
If any one getting error while remounting system partition in rw mode using adb, please follow these steps :
C:\Android\android-sdk-windows\tools> adb remount
remount failed: No such file or directory
SOLUTION:
Connect to your device usb adb: [FOR ROOTED DEVICES ONLY]
C:\Android\android-sdk-windows\tools> adb shell
$su
#mount -o remount,rw /dev/stl12 /system
(do your desired work like copy some files on system/media folder , then remount the system partition in ro mode again)
# cd /
#mount -o remount,ro /dev/stl12 /system
#exit
$exit
Thats all
FYI if you want to know the dev partitions mounted on your device :
C:\Android\android-sdk-windows\tools> adb shell
$ su
# mount
cheers
Did you map the other partitions by any chance? I'd like to be able to make a full backup to eventually be flashed back with Heimdall or ODIN. I already have a system.rfs (stock + root) that could be made in a tar image.
I've see tutorials for other Samsung phones but these need to be adapted to our exact setup. I haven't found anything generic enough to know how to go about mapping things.
It might also help those who flashed GT-S5660 ROMs on the Bell Canada GT-S5660M, as the screen brightness issues sound very much like kernel issues to me...
I can't quite tell what the difference is between stl and bml either. (I'll probably try dd'ing the different blocks, except stl5, and peek around with a hex editor...)
Goodbye,
Darkshado

[MOD] ro / rw scripts to remount your /system

I did not write these scripts. I claim zero credit for them. I pulled them from somewhere (another ROM or a mod for another phone, I can't remember.) I am simply passing on the information.
Here is a way you can add two scripts to change your /system from read-only to read-write and visa-versa. I am not going to hold your hand through this one. If you don't understand it, then don't do it. This is only for those that want a command line script to set their system filesystem to RW and back to RO in a simple way. This is only for people that are comfortable with the command prompt and adb shell to begin with. I am not responsible if you brick your phone.
I'll say it again. I am not responsible if you brick your phone.
Save a text file called: ro that contains:
Code:
#!/system/bin/sh
fs=`mount | grep system | awk '{print $5}'`
mount -t $fs -o remount,ro /dev/block/stl9 /system
Save a text file called: rw that contains:
Code:
#!/system/bin/sh
fs=`mount | grep system | awk '{print $5}'`
mount -t $fs -o remount,rw /dev/block/stl9 /system
Then open a command prompt and change directory to where you have the ro and rw files located. Notice that the ro and rw files DO NOT have any file extension on them. These should NOT show up as text files with Notepad icons when using Windows Explorer. If they do, then you need to take the .txt off the end of the filename. If you can't see it, then you have to be sure to show the hidden extensions.
The following steps assumes that you either have adb.exe and related files in the same directory as your rw and ro scripts OR you have added adb.exe to the PATH environment variable on your computer system.
When you are ready do this:
Code:
adb push rw /data/local/tmp/rw
adb push ro /data/local/tmp/ro
adb shell chmod 0755 /data/local/tmp/rw
adb shell
/data/local/tmp/rw
cp /data/local/tmp/rw /system/xbin/rw
cp /data/local/tmp/ro /system/xbin/ro
chmod 0755 /system/xbin/ro
chmod 0755 /system/xbin/rw
/system/xbin/ro
reboot
Notice that the last command will reboot your phone. This is only necessary if you want these scripts to be usable immediately. When you have rebooted, you should be able to type the command: rw to set your /system to read-write and ro to set your /system to read-only
Personally, I skip that last "reboot" command and I just run /system/xbin/ro manually until the next time I reboot my phone anyway.
These two scripts should be compatible with what ever file system you have on /system since if you read the script it actually checks the file system type first and then uses that response in the next line.
Use at your own risk, though.
EDIT: On Gingerbread, I had to use /dev/block/stl10 instead of /dev/block/stl9 above.

Categories

Resources