Shell Programming Error - Droid Incredible Q&A, Help & Troubleshooting

I recently wrote a shell program to turn the front LEDs on and off for a flashlight, without having two scripts (one off, one on, which did work). Although the script seems sound to me, i get an error when I run it:
Stderr [: Not Found
Stderr [: Not Found
The script is as follows:
led_status=$(cat /sys/class/leds/flashlight/brightness);
if [ 1 ]
then
if [ "$led_status" = "0" ]
then
echo 3 > /sys/class/leds/flashlight/brightness
fi
fi
if [ "$led_status" = "3" ]
then
echo 0 > /sys/class/leds/flashlight/brightness
fi

I tried the script stripped down a little:
Code:
led_status=$(cat /sys/class/leds/flashlight/brightness);
if [ "$led_status" = "0" ];
then
echo 3 > /sys/class/leds/flashlight/brightness
else
echo 0 > /sys/class/leds/flashlight/brightness
fi
But I get permission denied trying to run it with better terminal pro from emmc with su. I'm not going to be much help, but I'm interested to know if you get this working, and how to run it, and from where.

GScript is the app I use to run scripts as su. It works fine.
But for some reason, I still get the error:
stderr: [: Not Found
I don't know what it's trying to find tbh, but that bracket seems to be a problem.

Code:
led_status=$(cat /sys/class/leds/flashlight/brightness);
if [ "$led_status" = "0" ];
then
echo 3 > /sys/class/leds/flashlight/brightness
else
echo 0 > /sys/class/leds/flashlight/brightness
fi
I just put that code in to gscript and was able to run it fine. It turned both leds on(Really bright) and then I ran it again and it shut both of them off...
Cool script but y not just use an app like lamppu with widgets to do this? or do you have something else your putting together that this is part of?

Hmm. I wonder why mine isn't working then. And I would, but I'm trying to learn more about android and how it works, and running into an error where a bracket becomes a problem confused me to be honest.

Related

[FIXED] FROYO Calibration Error -> open input device: Inappropriate ioctl for device

[FIXED] FROYO Calibration Error -> open input device: Inappropriate ioctl for device
well, there are several threads about calibration problems ...
but nothing in detail ...
here we go....
basic is froyo 2.2 with haret 1.4 + no "ts-calibrate" file existing on fat32 (sdcard)
in init (startup) the calibration command failed to work ...
as you can see (below) - there in the script the calibration call via:
tssc-calibrate
then i can also see the message for clicking the 5 points, blabla...
(but the "white touch area" like as it is on diamond is not there ... and no time and it is jumping to next procedure in init script. the most users doesn't see that, because it does fast switch/show another lines ....)
then i see an error: (this comes from command "tssc-calibrate")
open input device: Inappropriate ioctl for device
any idea how to fix ?
Code:
for i in /sys/class/input/input* ; do
if [ "`cat $i/name`" = "tssc-manager" ] ; then
touchscreendir=$i
echo "Touchscreen device directory is $i"
fi
done
if [ -f /sdcard/ts-calibration ] ; then
echo "Using Saved Touchscreen Calibration"
echo 128,128,1903,128,128,1907,1903,1907,1024,1024 > $touchscreendir/calibration_screen
cat /sdcard/ts-calibration > $touchscreendir/calibration_points
else
mkdir /dev/graphics
mknod /dev/graphics/fb0 c 29 0
clear
echo; echo; echo; echo; echo; echo; echo; echo "Calibrating Touchscreen:"
echo "Click the Five Targets in order -- Top Left, Top Right, Middle, Bottom Left, Bottom Right"
echo "(Tap lightly. The screen is quite sensitive.)"
tssc-calibrate
echo 0,0,0,0,0,0,0,0,0,0 | cmp -s $touchscreendir/calibration_points # determine if calibration is still null -- means failed calibration
if [ $? -eq 0 ] ; then
echo "Touchscreen Calibration Failed"
else
echo "Touchscreen Calibration Successful; Saving..."
cat $touchscreendir/calibration_points > /sdcard/ts-calibration
fi
fi
EDIT:
FIXED in latest kernel version "htc-msm-linux-20100818_154417-package.tar" and newer ...
for calibration - you must delete the "ts_calibrate" file on your sdcard.
cu camel
hey mate,
any news on this? Wish I could help you but I know nothing about this programming of this sort...as a matter of fact, who is putting this together? I mean, who is putting the versions online, shouldn't they know?
:|
i' now in vacation, but will take care if i'm back ...
this problem is fixed in latest kernel.
if you use kernel "htc-msm-linux-20100818_154417-package.tar" or newer it is fixed.
the touchscreen problem (finger touch does recognize extra touch on left side ..) is not fixed now.
I am new, is it that we have to calibrate before we install?
hktotti said:
I am new, is it that we have to calibrate before we install?
Click to expand...
Click to collapse
On your first boot with the new zimage, it will ask you to calibrate the screen. If you made a mistake (or you did not calibrate at all), delete the ts-calibration file on your sd-card and start android again

[SOLVED] Shell scripting problem: unexpected "fi"

SOLVED: The file had Windows EOL formatting. *nix no likely that.
In the init script there are several instances of if statements like this:
Code:
testvar=1
if [ "$testvar" = "1" ] ; then
echo "Testvar is equal to one"
fi
Yet, when I put if statements exactly like this into a shell script and execute them in an adb shell (or connectbox shell), I get the following error:
line 4: syntax error: unexpected "fi" (expecting "then")
I've also taken if statements directly from init and they throw the same error.
Any busybox gurus here know what's up with this?
toadlife said:
In the init script there are several instances of if statements like this:
Code:
testvar=1
if [ "$testvar" = "1" ] ; then
echo "Testvar is equal to one"
fi
Yet, when I put if statements exactly like this into a shell script and execute them in an adb shell (or connectbox shell), I get the following error:
line 4: syntax error: unexpected "fi" (expecting "then")
I've also taken if statements directly from init and they throw the same error.
Any busybox gurus here know what's up with this?
Click to expand...
Click to collapse
Remove the ; and enter the then
Code:
testvar=1
if [ "$testvar" = "1" ]
then
echo "Testvar is equal to one"
fi
Nope. Still throws the same error.
This is driving me nuts. What I'm doing is editing the /init script. The loops work just fine when executed at bootup in / init, but remounting the filesystem, editing /init and rebooting just the test a change takes forever.
For now I've got my changes to init working, but it would be nice to be able to test before editing /init
I just realized that I forgot to put `#!/bin/sh` at the top of my script. But doing so doesn't seem to help. Instead I get not found error.
Weird!
toadlife said:
Nope. Still throws the same error.
This is driving me nuts. What I'm doing is editing the /init script. The loops work just fine when executed at bootup in / init, but remounting the filesystem, editing /init and rebooting just the test a change takes forever.
For now I've got my changes to init working, but it would be nice to be able to test before editing /init
Click to expand...
Click to collapse
Code:
testvar=1
if [ $testvar = `1` ] (`=~ key)
then
echo "Testvar is equal to one"
fi
[/QUOTE]
It gives the echo, but also 1: not found.
Here is the actual code I put into my init:
(this works)
Code:
#Super cool battery thingy
RUNSCBS=`/bin/grep -o "run.scbs=.*" /proc/cmdline | /bin/sed -e "s/.*run.scbs=//g" -e "s/ .*//g"`
if [ "$RUNSCBS" = "1" ] ; then
dev=$(cat /sys/class/scbs/0/dev | sed -e "s/:/ /g")
mknod /dev/scbs0 c $dev
scbs -d -co /sdcard/scbs.conf
fi
# Debug logs
TAKELOGS=`/bin/grep -o "take.logs=.*" /proc/cmdline | /bin/sed -e "s/.*take.logs=//g" -e "s/ .*//g"`
if [ "$TAKELOGS" = "1" ] ; then
logfiledate=`expr substr \`date -Iseconds|tr -d :|tr -d \+|tr -d \-|tr -d T\` 1 14`
tar -cz -f "$card"/debuglogs_"$logfiledate".tar.gz "$card"/debuglogs_*.txt
cat /proc/kmsg>"$card"/debuglogs_kmsg_"$logfiledate".txt &
logcat -v time >"$card"/debuglogs_logcat_time_"$logfiledate".txt &
logcat -v time -b radio>"$card"/debuglogs_logcat_time_radio_"$logfiledate".txt &
fi
Ooooo I really like the idea of having logging running from init. Does that work well? Do the logs ever 'loop' and you end up missing things, or do they just keep on churnin?
arrrghhh said:
Ooooo I really like the idea of having logging running from init. Does that work well? Do the logs ever 'loop' and you end up missing things, or do they just keep on churnin?
Click to expand...
Click to collapse
AFAIK, they go forever. I started doing it last night by just putting the static command in the /init and the logging was still going when I got up this morning.
This morning wanted to see if I could make logging and scbs triggerable by an option in the command line.
Both are working for me now.
Know if where talking about scripts, i have a question too.
This is my RIL logs script:
Code:
#! /system/bin/sh
i="0"
while [ $i -lt 2 ]
do
date=`date +%Y%m%d%H%M`
if [ -d /sdcard/logs/ril/$date/ ]
then
echo "/sdcard/logs/ril/$date/ exists!"
else
mkdir /sdcard/logs/ril/$date/
echo " Made direction /sdcard/logs/ril/$date!"
fi
logcat -v time > /sdcard/logs/ril/$date/logcat-time.txt &
logcat -v time -b radio > /sdcard/logs/ril/$date/logcat-time.txt &
sleep 18000 && kill -0 $! && kill $!
cd /sdcard/logs/ril/
tar -czf ril$date.tar.gz $date
rm -r $date
cd /
done
The thing, i believe, is that only the logcat -v time -b radio is killed and when it's sleeping it's not doing that in the background.
Sleeping for 18000 seconds (5h), because if it's running for a day the logcat log will be more than 10 mb or so.
lol.
Your date string...
Code:
date +%Y%m%d%H%M
...is a bit simpler than mine...
Code:
expr substr `date -Iseconds|tr -d :|tr -d \+|tr -d \-|tr -d T` 1 14
(I couldn't figure out the `date` syntax)
Christiaan91 said:
Know if where talking about scripts, i have a question too.
This is my RIL logs script:
Code:
#! /system/bin/sh
i="0"
while [ $i -lt 2 ]
do
date=`date +%Y%m%d%H%M`
if [ -d /sdcard/logs/ril/$date/ ]
then
echo "/sdcard/logs/ril/$date/ exists!"
else
mkdir /sdcard/logs/ril/$date/
echo " Made direction /sdcard/logs/ril/$date!"
fi
logcat -v time > /sdcard/logs/ril/$date/logcat-time.txt &
logcat -v time -b radio > /sdcard/logs/ril/$date/logcat-time.txt &
sleep 18000 && kill -0 $! && kill $!
cd /sdcard/logs/ril/
tar -czf ril$date.tar.gz $date
rm -r $date
cd /
done
The thing, i believe, is that only the logcat -v time -b radio is killed and when it's sleeping it's not doing that in the background.
Sleeping for 18000 seconds (5h), because if it's running for a day the logcat log will be more than 10 mb or so.
Click to expand...
Click to collapse
Hmm. I haven't set up gscript myself yet, but you might need to nohup the logcats to get them to stay once gscript shuts down.
arrrghhh said:
Ooooo I really like the idea of having logging running from init. Does that work well? Do the logs ever 'loop' and you end up missing things, or do they just keep on churnin?
Click to expand...
Click to collapse
I have found one issue. It's seems that whenever scbs runs, locat fails to open the log devices. I just disabled scbs and logcat worked. I'm going to try swapping the code around so scbs runs after the logging starts.
It seems scbs blows up logcat, even when it is triggered after logging starts. Ughhh.
Entropy512 said:
Hmm. I haven't set up gscript myself yet, but you might need to nohup the logcats to get them to stay once gscript shuts down.
Click to expand...
Click to collapse
logcat will be going, even when you close the terminal, but when you deleted the files they stop. So that's not a problem, cuz i won't delete.
BTW: is it possible to silently run scripts? Like this one?
./pathtoscript1 & ./pathtoscript2 & ./pathtoscript3
Christiaan91 said:
logcat will be going, even when you close the terminal, but when you deleted the files they stop. So that's not a problem, cuz i won't delete.
BTW: is it possible to silently run scripts? Like this one?
./pathtoscript1 & ./pathtoscript2 & ./pathtoscript3
Click to expand...
Click to collapse
What do you mean "silently run" - do you mean disable any printing to stdout?
./pathtoscript1 &>/dev/null & ; ./pathtoscript2 &>/dev/null &
should do the trick The &>/dev/null routes all output to /dev/null
Man, you guys go way overboard on this stuff. This is my gscript logging script.
Code:
cd /sdcard
mv logg.txt logg.0.txt
mv logr.txt logr.0.txt
nohup logcat -v time > logg.txt &
nohup logcat -v time -b radio > logr.txt &
nohup klogd > klog.txt
highlandsun said:
Man, you guys go way overboard on this stuff. This is my gscript logging script.
Code:
cd /sdcard
mv logg.txt logg.0.txt
mv logr.txt logr.0.txt
nohup logcat -v time > logg.txt &
nohup logcat -v time -b radio > logr.txt &
nohup klogd > klog.txt
Click to expand...
Click to collapse
Yeah, well we don't all have kung-fu coding ablities like you, so we go overboard with what we can overboard with.
Besides, I think it might be beneficial to put something like the code I wrote into the official init, so noobs can more easily provide debug logs.
One thing to keep in mind, busybox = /bin/sh, statically compiled sh is /system/bin/sh. I got tired of not having arrow key support whenever I su'ed (since /bin/su spawns a root /system/bin/sh regardless of what's in /etc/passwd) so I bind mounted /bin/sh (which is a symlink to busybox) over the one in /system in my user.conf. I haven't come across any ill effect, but if you feel that the shell difference may be causing issues, you could try that route, since it's very easy to undo.
-- Starfox
Starfox said:
One thing to keep in mind, busybox = /bin/sh, statically compiled sh is /system/bin/sh. I got tired of not having arrow key support whenever I su'ed (since /bin/su spawns a root /system/bin/sh regardless of what's in /etc/passwd) so I bind mounted /bin/sh (which is a symlink to busybox) over the one in /system in my user.conf. I haven't come across any ill effect, but if you feel that the shell difference may be causing issues, you could try that route, since it's very easy to undo.
-- Starfox
Click to expand...
Click to collapse
Thanks for the tip. I'll give that a shot.
LOL. I'm an idiot
Figured out what the problem was. The file had Windows EOL formatting.
That's what I get for using Windows to edit shell scripts.

[HOW TO] Extract rom.zip from RUU.exe

Hi,
I'm trying to port One V rom to the Desire (my first rom cooking experience).
So I made a small bash script to extract rom.zip file from RUU.exe.
Code:
#!/bin/bash
DEST_DIR=./
WINE_DIR=~/.wine/drive_c/users/*/Temp
ROM=""
PID=0
function usage {
echo "Extract RUU 0.2 of 25 June 2012, by Luc Chante"
echo ""
echo "Usage: extract-ruu [OPTION]... RUU"
echo "Options: "
echo " -d DIR|FILE where to extract the file rom.zip"
echo " ./ by default"
echo " -w DIR directory for wine temporary files"
echo " ~/.wine/drive_c/users/*/Temp by default"
exit 1
}
[ $# -gt 0 ] || usage
while [ $# -gt 1 ]; do
if [ $1 = "-d" ]; then
[ $# -gt 0 ] || usage
shift
DEST_DIR=$1
elif [ $1 = "-w" ]; then
[ $# -gt 0 ] || usage
shift
WINE_DIR=$1
fi
shift
done
[ $# -gt 0 ] || usage
if [ ! -d $WINE_DIR ]; then ls -d $WINE_DIR; exit 1; fi
wine $1 &
PID=$!
TMP=`mktemp`
while [ ${#ROM} -eq 0 ]; do
ROM=`find $WINE_DIR -type f -cnewer $TMP -name rom.zip`
done
kill -9 $PID
if [ -f $ROM ]; then
cp -i $ROM $DEST_DIR
echo "Rom extracted"
else
echo "Rom not found"
fi
Put these lines into a file named extract-ruu, make it executable and juste do :
./extract-ruu RUU_XXXXXXXXXXXXXXX.exe
Wait for a while ... and it's over
don't ever execute with super-user rights !!! (because of kill -9 $PID)
[edit]: version 0.2
- correction of a bug (DEST & DEST_DIR)
- test with a recent file to force 'find' to find the most recent rom.zip file
!!!
I couldn't get the old OpenRUU script to extract my RUU, but this did its job perfectly! props.
Dude you can do it easy with no script, just run the RUU.exe, when the screen pops up with the picture of the device go to the start menu (Windows 7) and type in search *temp* and press enter. When the folder opens search it for ROM.zip and there you go.
CdTDroiD said:
Dude you can do it easy with no script, just run the RUU.exe, when the screen pops up with the picture of the device go to the start menu (Windows 7) and type in search *temp* and press enter. When the folder opens search it for ROM.zip and there you go.
Click to expand...
Click to collapse
The RUU I was using wasn't starting in Vista (I've had too many phone flashing troubles with 7), so I figured I'd just extract it out in Ubuntu. So when I tried that without any script, it decided to crash (which it was going to do anyway since it was missing DLLs) before I could grab the rom.zip out of temp files.
I was tired of it so I just used this so I could just fastboot it and be done.
CdTDroiD said:
Dude you can do it easy with no script, just run the RUU.exe, when the screen pops up with the picture of the device go to the start menu (Windows 7) and type in search *temp* and press enter. When the folder opens search it for ROM.zip and there you go.
Click to expand...
Click to collapse
What about XP?
GrandMstrBud said:
What about XP?
Click to expand...
Click to collapse
Same procedure but you need to go to temp folder in windows XP. Then search for ROM.zip
Sent from my HTC Desire using xda premium
Why you don't port from desire v?
Sent from my HTC Desire using xda premium
rommanager said:
Why you don't port from desire v?
Sent from my HTC Desire using xda premium
Click to expand...
Click to collapse
because its desire v
Sent from my HTC Desire
rommanager said:
Why you don't port from desire v?
Sent from my HTC Desire using xda premium
Click to expand...
Click to collapse
I abandoned the job ...
Desire V seems to be unportable onto the Desire.
And by the way, I'm a linux user, so I don't have Windows 7 "start menu". I made this script under linux.
Maybe the Desire VT328w...
Hey! I was excited to find this thread, because the RUU I'm trying to use will not run or give me the zip in Windows 7, but I am having problems with your script in ubuntu as well. After running ./extract_ruu, I get this:
wine: cannot find L"C:\\windows\\system32\\RUU_PRIMO_C_ICS_40A_Sprint_WWE_VM_1.08.652.6_Radio_1.00.00.0521_2_NV_VM_3.46_0503_PRL61008_release_262414_signed.exe"
dankstahz said:
Hey! I was excited to find this thread, because the RUU I'm trying to use will not run or give me the zip in Windows 7, but I am having problems with your script in ubuntu as well. After running ./extract_ruu, I get this:
wine: cannot find L"C:\\windows\\system32\\RUU_PRIMO_C_ICS_40A_Sprint_WWE_VM_1.08.652.6_Radio_1.00.00.0521_2_NV_VM_3.46_0503_PRL61008_release_262414_signed.exe"
Click to expand...
Click to collapse
Just run it like I said before
Sent from my Galaxy Nexus using Tapatalk 2
The way you said isn't working for me, It be nice if a script was available to extract the rom.zip.
CdTDroiD said:
Just run it like I said before
Sent from my Galaxy Nexus using Tapatalk 2
Click to expand...
Click to collapse
dankstahz said:
Hey! I was excited to find this thread, because the RUU I'm trying to use will not run or give me the zip in Windows 7, but I am having problems with your script in ubuntu as well. After running ./extract_ruu, I get this:
wine: cannot find L"C:\\windows\\system32\\RUU_PRIMO_C_ICS_40A_Sprint_WWE_VM_1.08.652.6_Radio_1.00.00.0521_2_NV_VM_3.46_0503_PRL61008_release_262414_signed.exe"
Click to expand...
Click to collapse
Hi, sorry to answer so late.
Have you a fully functional wine install ?
Because it works just fine for me :
$ extract-ruu RUU_PRIMO_U_ICS_40A_HTC_Europe_1.56.401.2_Radio_20.66.30.0831U_3831.15.00.19_M_release_254696_signed.exe
fixme:storage:create_storagefile Storage share mode not implemented.
/home/luc/.local/bin/extract-ruu : ligne 53 : 5971 Processus arrêté wine $1
Rom extracted
idem with
$ extract-ruu -d test RUU_PRIMO_U_ICS_40A_HTC_Europe_1.56.401.2_Radio_20.66.30.0831U_3831.15.00.19_M_release_254696_signed.exe
Just in case, I'm using archlinux.
[edit]: I also tried with RUU_PRIMO_U_ICS_40A_HTC_Europe_2.22.401.1_Radio_20.76.30.0835U_3831.19.00.120_release_273801_signed.exe succesfully.
How hard is it for someone to use VirtualBox on Linux?
Sent from my Nexus One using Tapatalk 2
eLukas said:
Hi,
Put these lines into a file named extract-ruu, make it executable and juste do :
./extract-ruu RUU_XXXXXXXXXXXXXXX.exe
Wait for a while ... and it's over
don't ever execute with super-user rights !!! (because of kill -9 $PID)
[edit]: version 0.2
- correction of a bug (DEST & DEST_DIR)
- test with a recent file to force 'find' to find the most recent rom.zip file
Click to expand...
Click to collapse
DUDE, you ROCK, your script so saved me and my One X..... Thanks
Thanks, your script saved my one V. Now giving it for repairs. Thank you very much.
anybody any more didn't meet
It says that I can't run this on my 64 bit windows.. is there anything I can do?
eLukas said:
Hi,
I'm trying to port One V rom to the Desire (my first rom cooking experience).
So I made a small bash script to extract rom.zip file from RUU.exe.
Code:
#!/bin/bash
DEST_DIR=./
WINE_DIR=~/.wine/drive_c/users/*/Temp
ROM=""
PID=0
function usage {
echo "Extract RUU 0.2 of 25 June 2012, by Luc Chante"
echo ""
echo "Usage: extract-ruu [OPTION]... RUU"
echo "Options: "
echo " -d DIR|FILE where to extract the file rom.zip"
echo " ./ by default"
echo " -w DIR directory for wine temporary files"
echo " ~/.wine/drive_c/users/*/Temp by default"
exit 1
}
[ $# -gt 0 ] || usage
while [ $# -gt 1 ]; do
if [ $1 = "-d" ]; then
[ $# -gt 0 ] || usage
shift
DEST_DIR=$1
elif [ $1 = "-w" ]; then
[ $# -gt 0 ] || usage
shift
WINE_DIR=$1
fi
shift
done
[ $# -gt 0 ] || usage
if [ ! -d $WINE_DIR ]; then ls -d $WINE_DIR; exit 1; fi
wine $1 &
PID=$!
TMP=`mktemp`
while [ ${#ROM} -eq 0 ]; do
ROM=`find $WINE_DIR -type f -cnewer $TMP -name rom.zip`
done
kill -9 $PID
if [ -f $ROM ]; then
cp -i $ROM $DEST_DIR
echo "Rom extracted"
else
echo "Rom not found"
fi
Put these lines into a file named extract-ruu, make it executable and juste do :
./extract-ruu RUU_XXXXXXXXXXXXXXX.exe
Wait for a while ... and it's over
don't ever execute with super-user rights !!! (because of kill -9 $PID)
[edit]: version 0.2
- correction of a bug (DEST & DEST_DIR)
- test with a recent file to force 'find' to find the most recent rom.zip file
Click to expand...
Click to collapse
This is what i've done: (WIN8x64)
Created a file. Download from the attachments
Place them in C:/cygwin (yes, you need cygwin)
open cygwin, type cd C:/cygwin
Then, ./ruuextract *RUUNAME*
Worked
CdTDroiD said:
Dude you can do it easy with no script, just run the RUU.exe, when the screen pops up with the picture of the device go to the start menu (Windows 7) and type in search *temp* and press enter. When the folder opens search it for ROM.zip and there you go.
Click to expand...
Click to collapse
I tried that with Wildfire S and when I flash it in CWM it says E:Can't open /sdcard/rom.zip (Bad) at the begging.

[TIP][TRICK][SCRIPT] ISD for Link2SD #2P, ESD as ISD, 300MB ESD, VM#, NTP.

Thank you, for taking the time to put this together for the E4GT community. Nice work
Great. I always wanted to know how to do it.
I decided to write a script to do this automatically.
[size=+1]As before, I provide this with no warranties or guarantees. Use at your own risk. Make a NAND backup of at least System and Data before attempting.[/size]
The script assumes you have busybox and root access.
The script does not check for supported hardware. It has only been tested on the SPH-D710.
The script will check for /mnt/sdcard/external_sd, /mnt/emmc, and /mnt/sd-ext and that at least one is mounted. It bails otherwise. If your external SD card is mounted elsewhere, you can add it to line 9 of the script file (`mountpoint <real path to external SD (no symlinks)>`).
This script must be executed from a live boot (ie, not from recovery) using either Root Explorer, Scripter, a terminal emulator, ADB, or anything else that will run scripts as root.
The file must be on an EXT# partition (just put it in /data and you'll be fine) with 777 permissions unless you're using Scripter.
The script backs up your vold.fstab file to /data/vold.fstab.bak. If the backup file exists, the script will restore it, delete the Link2SD file, and delete the backup file.
Executing the script from Recovery is not advisable.
Executing the script after it has already been executed and the backup file no longer exists is also not advisable.
Your phone will reboot immediately after the script has executed.
Method 1 (terminal emulator or ADB shell):
Put the file from the zip into the /data directory.
Use the following commands from the shell:
Code:
su
chmod 777 /data/eg.link2sd.sh
sh /data/eg.link2sd.sh
Method 2 (Root Explorer | Root Browser):
Put the file from the zip into the /data directory.
Long tap the file, click "Permissions", check every box (the bottom row (there are only two boxes in that row) can be unchecked), and tap Ok.
Tap the file and tap "Execute".
Method 3 (Scripter):
Put the file from the zip wherever, but remember where.
Open Scripter, tap the "+", tap "Import", find the file, and tap it.
Tap the file in the list, tap "Run script", make sure "Execute script as root" is checked, and tap "Execute".
The full script:
Code:
#!/system/bin/sh
LOG=/data/testlog.log
VTEMP=/data/eg.vold.fstab
LTEMP=/data/eg.11link2sd
TEMPFILE=/data/eg.temp
BVOLD=/data/vold.fstab.bak
EXTMOUNTED=""
for N in `mountpoint /mnt/emmc` `mountpoint /mnt/sdcard/external_sd` `mountpoint /mnt/sd-ext`
do
if [ $N ]; then
echo "Found external card. ($N)";
EXTMOUNTED="Yes";
break;
fi
done
if [ ! $EXTMOUNTED ]; then
echo "Can't find external SD card. Make sure it's inserted and mounted and try again.";
exit;
fi
mount -o remount,rw /system
# System files
MOUNTPOINTS=/proc/mounts
VOLD=/system/etc/vold.fstab
LINK2SD=/system/etc/init.d/11link2sd
EXTPATH="";
EXTDEV="";
INTPATH="";
INTDEV="";
LINK2SDPATH="";
LINK2SDDEV="";
x=0;
while [ $x -lt $(cat $MOUNTPOINTS | wc -l) ]
do
let x=x+1;
LINE=`head -n $x $MOUNTPOINTS | tail -n 1`;
DEVICE=`echo "$LINE" | cut -d' ' -f1`;
POINT=`echo "$LINE" | cut -d' ' -f2`;
if [ $POINT = "/mnt/sdcard/external_sd" ] || [ $POINT = "/mnt/emmc" ] || [ $POINT = "/mnt/sd-ext" ]; then # It's the external SD
EXTPATH=$POINT;
EXTDEV=$DEVICE;
elif [ $POINT = "/mnt/sdcard" ]; then
INTPATH=$POINT;
INTDEV=$DEVICE;
elif [ $POINT = "/data/sdext2" ]; then
LINK2SDPATH=$POINT;
LINK2SDDEV=$DEVICE;
fi
done
if [ -f $BVOLD ]; then
echo "Restoring backup. ($BVOLD > $VOLD, '' > $LINK2SD)";
cp $BVOLD $VOLD;
rm $LINK2SD;
rm $BVOLD;
exit;
else
echo "Making backup. ($VOLD > $BVOLD)";
cp $VOLD $BVOLD;
fi
if [ $EXTPATH ] && [ $EXTDEV ]; then
echo "External SD ==";
echo "$EXTPATH: $EXTDEV";
fi
if [ $INTPATH ] && [ $INTDEV ]; then
echo "Internal SD ==";
echo "$INTPATH: $INTDEV";
fi
if [ $LINK2SDPATH ] && [ $LINK2SDDEV ]; then
echo "Link2SD ==";
echo "$LINK2SDPATH: $LINK2SDDEV";
fi
echo "" > $VTEMP;
echo "" > $LTEMP;
echo "" > $TEMPFILE;
echo "#!/system/bin/sh" > $LTEMP;
echo "#added by link2sd" >> $LTEMP;
echo "LOG=/data/link2sd-11link2sd.log" >> $LTEMP;
echo "echo \"\$(date) mounting...\" > \$LOG" >> $LTEMP;
echo "" >> $LTEMP;
VEXT="";
VINT="";
x=0;
while [ $x -lt $(cat $VOLD | wc -l) ]
do
let x=x+1;
LINE=`head -n $x $VOLD | tail -n 1`;
ACTION=`echo "$LINE" | cut -d' ' -f1`;
DEVID=`echo "$LINE" | cut -d' ' -f2`;
POINT=`echo "$LINE" | cut -d' ' -f3`;
PART=`echo "$LINE" | cut -d' ' -f4`;
DEVICE=`echo "$LINE" | cut -d' ' -f5`;
if [ "$POINT" = "$EXTPATH" ]; then # It's the external SD
echo "#$LINE" >> $TEMPFILE;
echo "INT 1" >> $TEMPFILE;
VEXT="$ACTION $DEVID $INTPATH $PART $DEVICE";
elif [ "$POINT" = "$INTPATH" ]; then
echo "#$LINE" >> $TEMPFILE;
echo "EXT 1" >> $TEMPFILE;
VINT="$ACTION $DEVID $EXTPATH 12 $DEVICE";
echo "mount -t vfat -o rw /dev/block/mmcblk0p$PART /data/sdext2 1>>\$LOG 2>>\$LOG" >> $LTEMP;
else
echo "$LINE" >> $TEMPFILE;
fi
done
x=0;
while [ $x -lt $(cat $TEMPFILE | wc -l) ]
do
let x=x+1;
LINE=`head -n $x $TEMPFILE | tail -n 1`;
ACTION=`echo "$LINE" | cut -d' ' -f1`;
if [ "$ACTION" = "EXT" ] && [ "$VEXT" ]; then
echo "$VEXT" >> $VTEMP;
elif [ "$ACTION" = "INT" ] && [ "$VINT" ]; then
echo "$VINT" >> $VTEMP;
else
echo "$LINE" >> $VTEMP;
fi
done
echo "" >> $LTEMP;
echo "mount >> $LOG" >> $LTEMP;
echo "\"\$(date) mount finished\" >> \$LOG" >> $LTEMP;
cp $LTEMP $LINK2SD;
cp $VTEMP $VOLD;
rm $LTEMP;
rm $VTEMP;
rm $TEMPFILE;
chmod 777 $LINK2SD;
mount -o remount,ro /system
reboot;
I can't seem to get this to work without errors and system app crashes on Stock rooted JB 4.1.2.
Nice write up. Thanks for the time spent to put this together
E4GT Rom-a-holic!!!
egingell said:
I can't seem to get this to work without errors and system app crashes on Stock rooted JB 4.1.2.
Click to expand...
Click to collapse
Someone smarter than me can validate or disprove my answer here, but I believe JB has different file system mount points than ICS. (he said he did this on BK)
CyberpodS2 said:
Someone smarter than me can validate or disprove my answer here, but I believe JB has different file system mount points than ICS. (he said he did this on BK)
Click to expand...
Click to collapse
You are correct. JB has a different pre load set up. I think you are rite...this was created on the ICS Kuban.
E4GT Rom-a-holic!!!
CyberpodS2 said:
Someone smarter than me can validate or disprove my answer here, but I believe JB has different file system mount points than ICS. (he said he did this on BK)
Click to expand...
Click to collapse
robrooter said:
You are correct. JB has a different pre load set up. I think you are rite...this was created on the ICS Kuban.
E4GT Rom-a-holic!!!
Click to expand...
Click to collapse
That's just it, it works fine, but System, Settings, and some other system apps crash consistently while the internal sdcard is mounted to Link2SD's directory and the external sdcard mounted in its place. I even made sure to edit my scripts to change where the external and internal would be remounted to (it's /storage/sdcard0 and /storage/extSdCard respectively).
P.S.: It's 4.2 that changes how mounts are seen by or accessible to apps.
Edit: To clarify, the directories get successfully changed around as intended.
Edit 2: Oh, and the phone reboots itself after a few minutes. I had to fix it via Recovery with ADB because the phone wouldn't stay up long enough to do it the normal* way. * Transferring files to the SD card via USB and moving them to their proper destinations via Root Explorer.
I figured out why I was having a problem. I was mounting /dev/block/mmcblk0p12 to /storage/extSdCard. The problem is that Android 4.1.2 stock uses /dev/block/mmcblk0p12 as "overflow" for system apps.
I am currently unwilling to test this on my phone at this time. My setup would require /dev/block/mmcblk0p11 to be an EXT4 file system which, judging by what I see in init.rc, is going to get reformatted as exFAT on boot. Besides, Link2SD has since been fixed to find the second partition on the external SD card for the SGS2.
I have successfully mounted my internal SD card to /data/sdext2, mounted my external SD card to /storage/sdcard0, and bound /storage/sdcard0 to /storage/extSdCard (for backward compatibility) using the following scripts.
[size=+1]I provide this information with no warranties or guarantees and I only tested it on the Sprint Epic 4G Touch with stock rooted Jelly Bean 4.1.2. Use it at your own risk.[/size]
Requires:
root
busybox
basic knowledge of shell scripts and Linux (not necessarily required, but it doesn't hurt)
Notes:
Make sure /system/etc/init.d/12binds, /system/bin/debuggerd, and /system/bin/debuggerd.bin are executable. Just to be safe, you can execute this from a terminal emulator (the asterisk will make it get multiple files at the same time).
Code:
mount -o remount,rw /system
chmod 755 /system/bin/debuggerd*
chmod 755 /system/etc/init.d/12binds
mount -o remount,ro /system
The reason I converted my SD card to EXT4 is so I can move&bind internal app data (the stuff in /data/data/app.package.name) to /data/sdext2/data/app.package.name and preserve file permissions. exFAT does not support this.
Terminal emulator - Executing this command will wipe the SD card and convert it to EXT4. This is optional:
Code:
mkfs.ext2 /dev/block/mmcblk0p11
/system/etc/vold.fstab
Code:
[color=green]## Vold 2.0 Generic fstab
## - San Mehat ([email protected])
##
#######################
## Regular device mount
##
## Format: dev_mount <label> <mount_point> <part> <sysfs_path1...>
## label - Label for the volume
## mount_point - Where the volume will be mounted
## part - Partition # (1 based), or 'auto' for first usable partition.
## <sysfs_path> - List of sysfs paths to source devices
## storage_struct - ex) series, "/mnt/sdcard/extStorages" / parallel
######################
# internal sdcard[/color]
{
ums_sys_path = /sys/class/android_usb/f_mass_storage/lun0/file
secure_format = enable
discard = enable
}
[color=green]#dev_mount sdcard /storage/sdcard0 11 /devices/platform/dw_mmc/mmc_host/mmc0/mmc0 encryptable_nonremovable[/color]
dev_mount sdcard /storage/sdcard0 1 /devices/virtual/block/cyasblkdevblk0
[color=green]# external sdcard[/color]
{
ums_sys_path = /sys/class/android_usb/f_mass_storage/lun1/file
android_secure_containers = enable
}
[color=green]# This partition is 300MB (the smallest I could make it using MiniTool Partition
# Widard) and is [b]not[/b] set to active. It does not mount, which is how I want it. I know
# I'm wasting 300MB of disk space, but that's ok by me.
# This line is here to prevent "damaged SD card" errors.[/color]
dev_mount sdcard1 /storage/extSdCard 2 /devices/virtual/block/cyasblkdevblk0
/system/bin/debuggerd - Make sure you rename the original to /system/bin/debuggerd.bin if you haven't already done so.
Code:
[color=green]#!/system/bin/sh[/color]
LOG=/data/link2sd-debuggerd.log
echo "$(date) mounting..." > $LOG
[color=green]# Delete or comment out this line if you want to make your external SD card into
# an internal and external SD card (both partitions set to active).
# I have not tried setting both partitions on my external SD card to active, so
# I don't know if they will both mount.
# This line binds the internal SD card's directory to the external SD card's
# directory. In other words both internal and external SD cards will be
# the same physical media. You will have duplicates in Music and Gallery.
# If you are not concerned with backward compatibility, you
# can delete or comment out this line.[/color]
mount -o bind /storage/sdcard0 /storage/extSdCard 1>>$LOG 2>>$LOG
[color=green]# Change "ext4" to "vfat" if you did not convert your internal SD card to EXT4.[/color]
mount -t ext4 -o rw,noatime,barrier=0,nobh,errors=continue /dev/block/mmcblk0p11 /data/sdext2 1>>$LOG 2>>$LOG
echo "" >> $LOG
echo "init.d" >> $LOG
[color=green]# Leave this line in if you want init.d support.[/color]
busybox run-parts /system/etc/init.d 1>>$LOG 2>>$LOG
echo "" >> $LOG
mount >> $LOG
echo "$(date) mount finished" >> $LOG
echo debuggerd.bin launched >> $LOG
exec /system/bin/debuggerd.bin
/system/etc/init.d/12binds - This is optional and requires more work than you might think and requires your internal card be EXT4, exFAT will not work. It also requires the "run-parts" line in /system/bin/debuggerd.
Code:
[color=green]#!/system/bin/sh[/color]
LOG=/data/symlink.log;
echo "Symlink" > $LOG
busybox mount -o rw,remount /system
busybox mount -o rw,remount /
cd /data/sdext2/data/
for APP in *; do
cd /data/sdext2/data/$APP;
for DIR in *; do
if [ $DIR != "lib" ]; then # don't bind the lib folder, Link2SD does stuff with it.
echo "" 1>>$LOG 2>>$LOG;
echo "Binding /data/sdext2/data/$APP/$DIR => /data/data/$APP/$DIR" 1>>$LOG 2>>$LOG;
mount -o bind "/data/sdext2/data/$APP/$DIR" "/data/data/$APP/$DIR" 1>>$LOG 2>>$LOG;
fi
done
done
busybox mount -o ro,remount /system
busybox mount -o ro,remount /
Make sure it is executable (chmod 755 /system/etc/init.d/12binds)
To make the above work:
If this is too much for you, don't do it.
Copy /data/data/app.package.name to /data/sdext2/data or if the folder already exists in /data/sdext2/data, copy the contents of /data/data/app.package.name to /data/sdext2/data/app.package.name. Use Root Explorer or any other root file explorer that will preserve the owner of the files and their permissions. Do not use the "move" option or you will be making new folders and trying to figure out what the owner and group should be!
Open each folder except lib in /data/data/app.package.name and delete everything in them.
Execute /system/etc/init.d/12binds or reboot.
I bought an SGS4 and promptly broke the SD card I got for it, so I took the one from my S2 and put it in the S4. I then changed the vold.fstab file back to stock. Unfortunately since the internal SD card is EXT formatted, it won't mount as an SD card. This means that any app that relies on the SD card may not work. Apps that use the path work if I mount the SD card via shell script, but there's a caveat: the files that get put there (e.g. $sdcard/Android/data/<app name>/cache/<stuff>) have their owner/group set to that of the app and no other app can use it without changing the files' owner, group, and permissions first. Camera and Gallery apps won't work at all regardless of whether or not I mount the SD card, at least not the ones I've tried (stock camera and gallery, Camera ICS, Gallery ICS, and Social Gallery). Otherwise the phone works fine without error.
Edit: If I mount a temporary file system (mount -t tmpfs /dev/null /storage/sdcard0), I can get the Camera to work, but the Gallery still complains and any pictures get deleted after reboot. This gave me an idea, though: mount the tmpfs and then bind /data/sdext2 to /storage/sdcard0. This worked, for the most part. Gallery apps still don't like it, but the Camera works. I still have to change the owner, group, and permissions to be able to do anything with pics.
For the record, this seems to work the best:
Code:
chown media_rw:media_rw /data/sdext2
chown media_rw:media_rw /data/sdext2/DCIM
chown media_rw:media_rw /data/sdext2/DCIM/*
chown media_rw:media_rw /data/sdext2/DCIM/Camera/*
chmod -r 775 /data/sdext2
/system/bin/debuggerd
Code:
#!/system/bin/sh
LOG=/data/debuggerd.log
echo "$(date) mounting..." > $LOG
mount -t ext4 -o rw,noatime,barrier=0,nobh,errors=continue /dev/block/mmcblk0p11 /data/sdext2 1>>$LOG 2>>$LOG
mount -t tmpfs /dev/null /storage/sdcard0 1>>$LOG 2>>$LOG
mount -o bind /data/sdext2 /storage/sdcard0 1>>$LOG 2>>$LOG
echo "" >> $LOG
echo "init.d" >> $LOG
/system/xbin/busybox run-parts /data/local/init.d 1>>$LOG 2>>$LOG
echo "" >> $LOG
mount >> $LOG
echo "$(date) mount finished" >> $LOG
echo debuggerd.bin launched >> $LOG
exec /system/bin/debuggerd.bin
I could change it back to exFAT, but I don't wanna.
egingell said:
I decided to write a script to do this automatically.
[size=+1]As before, I provide this with no warranties or guarantees. Use at your own risk. Make a NAND backup of at least System and Data before attempting.[/size]
The script assumes you have busybox and root access.
The script does not check for supported hardware. It has only been tested on the SPH-D710.
The script will check for /mnt/sdcard/external_sd, /mnt/emmc, and /mnt/sd-ext and that at least one is mounted. It bails otherwise. If your external SD card is mounted elsewhere, you can add it to line 9 of the script file (`mountpoint <real path to external SD (no symlinks)>`).
This script must be executed from a live boot (ie, not from recovery) using either Root Explorer, Scripter, a terminal emulator, ADB, or anything else that will run scripts as root.
The file must be on an EXT# partition (just put it in /data and you'll be fine) with 777 permissions unless you're using Scripter.
The script backs up your vold.fstab file to /data/vold.fstab.bak. If the backup file exists, the script will restore it, delete the Link2SD file, and delete the backup file.
Executing the script from Recovery is not advisable.
Executing the script after it has already been executed and the backup file no longer exists is also not advisable.
Your phone will reboot immediately after the script has executed.
Method 1 (terminal emulator or ADB shell):
Put the file from the zip into the /data directory.
Use the following commands from the shell:
Code:
su
chmod 777 /data/eg.link2sd.sh
sh /data/eg.link2sd.sh
Method 2 (Root Explorer | Root Browser):
Put the file from the zip into the /data directory.
Long tap the file, click "Permissions", check every box (the bottom row (there are only two boxes in that row) can be unchecked), and tap Ok.
Tap the file and tap "Execute".
Method 3 (Scripter):
Put the file from the zip wherever, but remember where.
Open Scripter, tap the "+", tap "Import", find the file, and tap it.
Tap the file in the list, tap "Run script", make sure "Execute script as root" is checked, and tap "Execute".
The full script:
Code:
#!/system/bin/sh
LOG=/data/testlog.log
VTEMP=/data/eg.vold.fstab
LTEMP=/data/eg.11link2sd
TEMPFILE=/data/eg.temp
BVOLD=/data/vold.fstab.bak
EXTMOUNTED=""
for N in `mountpoint /mnt/emmc` `mountpoint /mnt/sdcard/external_sd` `mountpoint /mnt/sd-ext`
do
if [ $N ]; then
echo "Found external card. ($N)";
EXTMOUNTED="Yes";
break;
fi
done
if [ ! $EXTMOUNTED ]; then
echo "Can't find external SD card. Make sure it's inserted and mounted and try again.";
exit;
fi
mount -o remount,rw /system
# System files
MOUNTPOINTS=/proc/mounts
VOLD=/system/etc/vold.fstab
LINK2SD=/system/etc/init.d/11link2sd
EXTPATH="";
EXTDEV="";
INTPATH="";
INTDEV="";
LINK2SDPATH="";
LINK2SDDEV="";
x=0;
while [ $x -lt $(cat $MOUNTPOINTS | wc -l) ]
do
let x=x+1;
LINE=`head -n $x $MOUNTPOINTS | tail -n 1`;
DEVICE=`echo "$LINE" | cut -d' ' -f1`;
POINT=`echo "$LINE" | cut -d' ' -f2`;
if [ $POINT = "/mnt/sdcard/external_sd" ] || [ $POINT = "/mnt/emmc" ] || [ $POINT = "/mnt/sd-ext" ]; then # It's the external SD
EXTPATH=$POINT;
EXTDEV=$DEVICE;
elif [ $POINT = "/mnt/sdcard" ]; then
INTPATH=$POINT;
INTDEV=$DEVICE;
elif [ $POINT = "/data/sdext2" ]; then
LINK2SDPATH=$POINT;
LINK2SDDEV=$DEVICE;
fi
done
if [ -f $BVOLD ]; then
echo "Restoring backup. ($BVOLD > $VOLD, '' > $LINK2SD)";
cp $BVOLD $VOLD;
rm $LINK2SD;
rm $BVOLD;
exit;
else
echo "Making backup. ($VOLD > $BVOLD)";
cp $VOLD $BVOLD;
fi
if [ $EXTPATH ] && [ $EXTDEV ]; then
echo "External SD ==";
echo "$EXTPATH: $EXTDEV";
fi
if [ $INTPATH ] && [ $INTDEV ]; then
echo "Internal SD ==";
echo "$INTPATH: $INTDEV";
fi
if [ $LINK2SDPATH ] && [ $LINK2SDDEV ]; then
echo "Link2SD ==";
echo "$LINK2SDPATH: $LINK2SDDEV";
fi
echo "" > $VTEMP;
echo "" > $LTEMP;
echo "" > $TEMPFILE;
echo "#!/system/bin/sh" > $LTEMP;
echo "#added by link2sd" >> $LTEMP;
echo "LOG=/data/link2sd-11link2sd.log" >> $LTEMP;
echo "echo \"\$(date) mounting...\" > \$LOG" >> $LTEMP;
echo "" >> $LTEMP;
VEXT="";
VINT="";
x=0;
while [ $x -lt $(cat $VOLD | wc -l) ]
do
let x=x+1;
LINE=`head -n $x $VOLD | tail -n 1`;
ACTION=`echo "$LINE" | cut -d' ' -f1`;
DEVID=`echo "$LINE" | cut -d' ' -f2`;
POINT=`echo "$LINE" | cut -d' ' -f3`;
PART=`echo "$LINE" | cut -d' ' -f4`;
DEVICE=`echo "$LINE" | cut -d' ' -f5`;
if [ "$POINT" = "$EXTPATH" ]; then # It's the external SD
echo "#$LINE" >> $TEMPFILE;
echo "INT 1" >> $TEMPFILE;
VEXT="$ACTION $DEVID $INTPATH $PART $DEVICE";
elif [ "$POINT" = "$INTPATH" ]; then
echo "#$LINE" >> $TEMPFILE;
echo "EXT 1" >> $TEMPFILE;
VINT="$ACTION $DEVID $EXTPATH 12 $DEVICE";
echo "mount -t vfat -o rw /dev/block/mmcblk0p$PART /data/sdext2 1>>\$LOG 2>>\$LOG" >> $LTEMP;
else
echo "$LINE" >> $TEMPFILE;
fi
done
x=0;
while [ $x -lt $(cat $TEMPFILE | wc -l) ]
do
let x=x+1;
LINE=`head -n $x $TEMPFILE | tail -n 1`;
ACTION=`echo "$LINE" | cut -d' ' -f1`;
if [ "$ACTION" = "EXT" ] && [ "$VEXT" ]; then
echo "$VEXT" >> $VTEMP;
elif [ "$ACTION" = "INT" ] && [ "$VINT" ]; then
echo "$VINT" >> $VTEMP;
else
echo "$LINE" >> $VTEMP;
fi
done
echo "" >> $LTEMP;
echo "mount >> $LOG" >> $LTEMP;
echo "\"\$(date) mount finished\" >> \$LOG" >> $LTEMP;
cp $LTEMP $LINK2SD;
cp $VTEMP $VOLD;
rm $LTEMP;
rm $VTEMP;
rm $TEMPFILE;
chmod 777 $LINK2SD;
mount -o remount,ro /system
reboot;
Click to expand...
Click to collapse
[email protected]_a51dtul:/ # sh /data/eg.link2sd.sh
sh /data/eg.link2sd.sh
/data/eg.link2sd.sh[16]: mountpoint: not found
/data/eg.link2sd.sh[16]: mountpoint: not found
/data/eg.link2sd.sh[16]: mountpoint: not found
Can't find external SD card. Make sure it's inserted and mounted and try again.
[email protected]_a51dtul:/ #
plz help.........my sd card second partion ext4
He... Plz help link2sd not work for htc 820 dual sim lolypop 5.0.2 full rooted or busybox.
Link2sd problem-any apps link success all linked but big problem just manually restart my phone show link2sd error mount open link 2sd and tap quckreboot, but not apps linked show my desktop alwas error view and mount script alwas error.
Plz help....how to work link2sd apps linked and mount script for lolypop 5.0.2 htc 820 dual
That script was written for the Galaxy S2 with ICS. You'll have to modify it to work in whatever device and OS you have and I don't have either of them, so you're on your own.
Sent from: SGS2 - JB 4.1.2 GB27 / SGS4 - JB 4.2.2 MF9
egingell said:
That script was written for the Galaxy S2 with ICS. You'll have to modify it to work in whatever device and OS you have and I don't have either of them, so you're on your own.
Sent from: SGS2 - JB 4.1.2 GB27 / SGS4 - JB 4.2.2 MF9
Click to expand...
Click to collapse
Mods like this eventually burn out extsdcards, when that happens the device won't boot, they also don't work without the modified sdcard inserted. If it ever burns out it is nearly impossible to get the device working again. Just a heads up.
Change Default VM Number in Lollipop
XDA Thread
Sent from: SGS5 - LP 5.1.1 / SGS4 - LP 5.0.1
Google seems to have closed outbound connections to the NTP port (123). Lucky, one can easily reopen it with the following script. Execute it as root post-boot with ROM Toolbox or similar.
Code:
#!/system/bin/sh
iptables -A OUTPUT -p udp --dport 123 -j ACCEPT
Edit: So it turns out that init.d is too soon. It must be executed post-boot using a script executer like ROM Toolbox, Tasker, Script Manager, etc.
Sent from: SGS5 - LP 5.1.1 / SGS4 - LP 5.0.1

[TIP] Running random scripts at boot

HTC One M8.
I have done HTCdev with http://htc-one.wonderhowto.com/how-to/unlock-bootloader-root-your-htc-one-m8-0154444/
then rooted
Then did S-OFF with http://firewater-soff.com/instructions/
Then, to be able to write to /system, you need more steps. From recovery, it works easily. From live running system, the default stock ROM has a write protection. This WP can be removed easily by loading a kernel module:
http://forum.xda-developers.com/showthread.php?t=2701816
then:
Code:
insmod /mnt/sdcard/Download/wp_mod_m8.ko
mount -o remount,rw /system
Now, I want to run random scripts.
First, check if the stock ROM has the same issue as my previous phone:
Code:
[email protected]_m8:/ # echo $PATH
/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin:/vendor/bin
[email protected]_m8:/ # ls -l /system/sbin
/system/sbin: No such file or directory
1|[email protected]_m8:/ #
That's exactly what we need: a folder that is in PATH, that does not exist, and should exist somewhere we can create it. So:
Code:
insmod /mnt/sdcard/Download/wp_mod_m8.ko
mount -o remount,rw /system
mkdir /data/local/bin
ln -s /data/local/bin/ /system/sbin
Then, create two small scripts in there: do vi /system/sbin/vibrate , then i to enter insert mode, paste this code, esc, :x ... or use any other editor if you want:
Code:
#!/system/xbin/ash
#
i="$1"
[ "$i" = "" ] && i=400
# default value for voltage_level at boot is 3100 mV.
v=3100
vmin=1200
[ $i -gt 0 ] 2>/dev/null || {
echo "Invalid argument '$i'; should be a number below 9999 ms."
exit 1
}
[ $i -gt 9999 ] && {
echo "Invalid argument '$i'; should be below 9999 ms."
exit 1
}
[ "$2" != "" ] && {
[ $2 -ge $vmin ] 2>/dev/null || {
echo "Invalid argument '$2'; should be a number between $vmin and ${v} mV."
exit 1
}
[ $2 -gt $v ] && {
echo "Invalid argument '$2'; should be below ${v} mV."
exit 1
}
}
[ "$i" = "" ] && { echo "Provide argument: time in ms." ; exit 1 ; }
[ "$2" = "" ] && {
echo "Voltage not provided. Using default $v mV."
} || {
v=$2
echo "Using voltage argument $v mV."
}
echo $v > /sys/devices/virtual/timed_output/vibrator/voltage_level
echo "$i" > /sys/devices/virtual/timed_output/vibrator/enable
It was an old code for HTC Sensation; voltage does not work anymore, but duration does.
A shorter script for flash, and create the init script:
Code:
echo "echo 255 > /sys/class/leds/flashlight/brightness" > /system/sbin/flashlight
echo "#!/system/bin/sh
# /system/etc/init.qcom.bt.sh
/data/local/bin/vibrate
/system/sbin/flashlight" > /data/local/bin/rc.init
chmod 755 /system/sbin/flashlight
chmod 755 /system/sbin/vibrate
chmod 755 /data/local/bin/rc.init
Now, the tricky part: make the init script run at boot. Edit /system/etc/init.qcom.bt.sh , and below the comment, insert this line:
Code:
/data/local/bin/rc.init &
Reboot, enjoy Your phone flashes and vibrates at boot. As is, this is almost useless. But, now you can create system scripts, and run them at boot ... you can do pretty much anything you do on a classic Linux machine.
Because scripts are put in a folder which is in the default system $PATH, all apps or widgets can run those scripts. This vibrate script can be called for example from a Tasker or ScriptManager widget.
I love vibrate, because it's a small noise; I tail it to any command that is likely to take more than 1mn to run. Having a ScriptManager widget running it also helps me check the system load. If phone seems slow, and vibration does not happen at once, then the phone has big load, and I shall wait for things to settle.
/system/etc/init.qcom.bt.sh was not a random choice. To understand why: open /init.target.rc , and now, search a script that is run ... at boot ... with user root ... and that lays in /system. Many scripts are run as user, or stored outside /system.
Now, it's up to you to create scripts that are usefull to you.
Hey thanks for the directions but I tried running the command mnt/sdcard/download/wp_mod.ko and I got a "failed exec format error"....
rgolnazarian said:
Hey thanks for the directions but I tried running the command mnt/sdcard/download/wp_mod.ko and I got a "failed exec format error"....
Click to expand...
Click to collapse
This is completely unrelated and offtopic. Either your file does not have exec bit, or wrong interpreter, or stored on partition that has noexec.
Hmmm ... why is the quoted message different from the one I received by email ???
Any way, even if you are in /, "mnt/sdcard/download/wp_mod.ko" is an invalid command. A module can not be executed, it must be inserted; see tutos about it.

Categories

Resources