I have create a script file that will flash a recovery from the terminal in the Galaxy Nexus.
I got the command from xda but I could not remember it when I wanted to flash a recovery,
so I wrote a script to do it.
AS WITH ANY FLASHING OR MODDING OF "YOUR" PHONE, I AM NOT RESPONSIBLE FOR ANY DAMAGES YOU MAY CAUSE!
I have tested this on my:
Unlocked Galaxy Nexus 4.1.1 takju (flashed from yakju)
Sprint Galaxy Nexus 4.0.4
Thanks to -viperboy- for help.
Code:
Created by Smurph82 2012_0512 (c) v1.0
flashr [-h] [-r] [-m] [-s s] -- Flash a recovery
to the Galaxy Nexus.
where:
-h show this help text
-r will reboot after flashing is complete.
-m image is in the root of the sdcard
-s source of the recovery image (/sdcard/recovery.img).
To use the script:
Download and Flash the script file from your current recovery
Or download the zip file and move the flashr file in the /system/bin folder to /system/bin with RootExplorer
or other root level file manager.
If you manually add the file you must
Code:
chmod 0755 /system/bin/flashr
or change the permissions from RootExplorer
Then open Terminal and type
Code:
su
first, yes you have to be rooted to do this!
Next type
Code:
flashr
or
Code:
flashr -h
to get the help
If you want to flash a recovery you must have the recovery.img
somewhere on your device that you can remember. Like the root of the sdcard.
To flash a recovery type
Code:
flashr -s /sdcard/recovery.img
or if the recovery is in the root of the sdcard type
Code:
flashr -ms recovery.img
If you want to reboot after the flashing is complete next use
Code:
flashr -mrs recovery.img
In the code examples above I used recovery.img as an example.
This should be "what ever you named the recovery".img it does not have to be recovery.
Reserved
Change Log:
v1 - Initial Release
i know you might think that im trolling, but im really not. what id like to know is what makes that better than just flashing the recovery, via the terminal, the old-fashioned way..
su(press enter)
flash_image recovery /sdcard/recovery.img(press enter)
reboot recovery(press enter, if you want to go to the recovery)
providing ithe file is on the main fs in the sd storage.
flash_image does not work with ics, that I have found. So I wrote my own. If there is a new flash_image that works with the galaxy nexus then I could not find it. Maybe it is because I'm still using the stock rom and kernel. I took the flash_image out of cm9 but it didn't work for me.
Sent from my Galaxy Nexus using XDA Premium HD app
Would you be willing to share the sources for this? It would be interesting to know how this works, since it may be useful also for other purposes than flashing recovery images. Or not?
I will post the source later today. It really is not much.
Sent from my Transformer Prime TF201 using XDA Premium HD app
E:V:A said:
Would you be willing to share the sources for this? It would be interesting to know how this works, since it may be useful also for other purposes than flashing recovery images. Or not?
Click to expand...
Click to collapse
Hope that this is helpful to someone.
Code:
#!/system/bin/sh
usage="Created by Smurph82 2012_0512 (c) v1.0
flashr [-h] [-r] [-m] [-s s] -- Flash a recovery
to the Galaxy Nexus.
where:
-h show this help text
-r will reboot after flashing is complete.
-m image is in the root of the sdcard
-s source of the recovery image (/sdcard/recovery.img)."
# Read in the options turn off verbose and require -s to have input
while getopts :hrms: opt; do
case $opt in
h) echo "$usage"
echo
exit;;
m) sdroot="/sdcard/";;
s) sourcedir=$OPTARG;;
r) reboot="t";;
*) echo
echo
echo "Invalid option: -$OPTARG" >&2
echo "$usage"
echo
exit;;
esac
done
shift $(($OPTIND - 1))
# This was for testing
#echo
#echo "Vars: m $sdroot: s $sourcedir: r $reboot: dir $sdroot$sourcedir"
#echo
# Check to make sure somthing was typed if not show help
if [ "$sourcedir" == "" ]; then
echo "$usage"
echo
exit
else
# Check that something is in that location if not dont flash
if [ -s $sdroot$sourcedir ]; then
echo "Flashing image from: $sdroot$sourcedir"
cat $sdroot$sourcedir > /dev/block/platform/omap/omap_hsmmc.0/by-name/recovery
else
echo "File not found at $sdroot$sourcedir"
exit
fi
fi
# Early in the morning I was getting cute
if [ "$reboot" == "t" ]; then
echo "Rebooting in 5.."
sleep 1
echo "Rebooting in 4.."
sleep 1
echo "Rebooting in 3.."
sleep 1
echo "Rebooting in 2.."
sleep 1
echo "Rebooting in 1.."
sleep 1
reboot recovery
fi
thank u very much for this! so easy now!!
It is just as easily done in a terminal by the following (assuming you downloaded the recovery you want to /sdcard and named it recovery.img):
su
dd if=/sdcard/recovery.img of=dev/block/platform/omap/omap_hsmmc.0/by-name/recovery
efrant said:
It is just as easily done in a terminal by the following (assuming you downloaded the recovery you want to /sdcard and named it recovery.img):
su
dd if=/sdcard/recovery.img of=dev/block/platform/omap/omap_hsmmc.0/by-name/recovery
Click to expand...
Click to collapse
Yes I know that but who wants to type all of that out. I just made it shorter more
or else. If you want to type the whole command then by all means have at it. I just
think that "flashr -mrs twrp.img" is a whole lot easier. Just my thoughts.
Hi
Nice enough script.
Although I feel I should warn people that it looks like this script will write anything you tell it. making no effort to verify that the file is a valid or correct for your phone. so be careful not to specify the wrong file.
fastboot flash recovery $file is much safer.
That is true if you are connected to a computer but this script is run on the phone from the terminal. If someone knows a way to check a file from the terminal running on the phone please tell me and I will update the script. I understand that there is currently no verification of the file that is being written so please make sure that you are writing the right file.
Sent from my Galaxy Nexus using XDA Premium HD app
Related
Took me a few minutes to figure this out, so I thought to share
This is taken from some scripts I use in CF-Root, you might need to change it slightly for other CWM3 kernels (like prefixing busybox to various commands, etc).
updater-script
Assumptions:
- rootfs is mounted as rw, so we can write temporary files anywhere (ram disk)
- you put a "myscript.sh" in the system folder inside the update
All this script does is extract whatever you have in update.zip/system folder to /tmp/update, and run the myscript.sh file.
Code:
ui_print("Extracting files ...");
package_extract_dir("system", "/tmp/update");
set_perm(0, 0, 0755, "/tmp/update/myscript.sh");
run_program("/tmp/update/myscript.sh");
myscript.sh
Assumptions:
- all busybox commands are symlinked in /sbin, this is usually the case for CWM3 kernels
Code:
#!/sbin/busybox sh
# get file descriptor for output
OUTFD=$(ps | grep -v "grep" | grep -o -E "update_binary(.*)" | cut -d " " -f 3);
# same as progress command in updater-script, for example:
#
# progress 0.25 10
#
# will update the next 25% of the progress bar over a period of 10 seconds
progress() {
if [ $OUTFD != "" ]; then
echo "progress ${1} ${2} " 1>&$OUTFD;
fi;
}
# same as set_progress command in updater-script, for example:
#
# set_progress 0.25
#
# sets progress bar to 25%
set_progress() {
if [ $OUTFD != "" ]; then
echo "set_progress ${1} " 1>&$OUTFD;
fi;
}
# same as ui_print command in updater_script, for example:
#
# ui_print "hello world!"
#
# will output "hello world!" to recovery, while
#
# ui_print
#
# outputs an empty line
ui_print() {
if [ $OUTFD != "" ]; then
echo "ui_print ${1} " 1>&$OUTFD;
echo "ui_print " 1>&$OUTFD;
else
echo "${1}";
fi;
}
# --- example usage ---
# empty line after "Extracting ..." from updater-script
ui_print;
# give the user some status
ui_print "doing something (1 of 4)";
# assume this won't take more than 30 seconds
progress 0.25 30;
# you'd do something useful here
sleep 15s;
# update status
ui_print "- done with something (1 of 4)";
# we're done, make sure the progress bar is at 25%
set_progress 0.25;
# empty line
ui_print;
# repeat this a few times ;)
ui_print "doing something (2 of 4)";
progress 0.25 30;
sleep 15s;
ui_print "- done with something (2 of 4)";
set_progress 0.50;
ui_print;
ui_print "doing something (3 of 4)";
progress 0.25 30;
sleep 15s;
ui_print "- done with something (3 of 4)";
set_progress 0.75;
ui_print;
ui_print "doing something (4 of 4)";
progress 0.25 30;
sleep 15s;
ui_print "- done with something (4 of 4)";
set_progress 1.00;
ui_print;
# done !
ui_print "done! rebooting!";
How, what, why ?
While updater-script is fine for a lot of things, like installing a new ROM and whatnot, anything sufficiently complicated still has to be done through shell scripts, because a great many things just cannot be easily done in edify. It's nice to be able to give the user some status when doing these operations. There are modded versions of CWM that make the same thing possible in other ways, like simply writing to STDOUT or STDERR. This requires either a custom update_binary or recovery binary, though.
This works because communication between recovery and update_binary is through a file descriptor (pipe). Recovery runs update_binary with the FD as command line parameter. Because the shell script is run as a child process of update_binary, it can write the same commands to that FD (commands recovery listens for), because child processes inherited FD numbers and access rights.
So, all the script has to do is figure out which FD to write to, and pass it the right commands. Finding the FD isn't difficult, as it is passed on the command line and so is listed in the output of ps. Some grep and cut magic retrieve it. See the OUTFD=$(...) line. The right commands are defined in the functions at the top.
Note: this is all taken from my rfs<=>ext4 conversion script for CF-Root/ext4. Slightly adjusted, hopefully it still works as expected
Enjoy!
Thank you chainfire
Sent from my GT-I9000 using Tapatalk
Thanks for this chainfire.
Precisely what I was looking for! You're my hero today, man!
Hi Chainfire
Thanks for your tricks, I'm using it for an almost bulletproof MTD flash script.
BTW, i'd like to call some set_perm commands. But set_perm isn't a recognized command for update-binary.
IDK if I'm clear.
Do you have some advise on that?
RolluS said:
BTW, i'd like to call some set_perm commands. But set_perm isn't a recognized command for update-binary.
Click to expand...
Click to collapse
I've sort this writing equivalent functions:
Code:
set_perm() { # same as set_perm command in updater-script, for example:
#
# set_perm 0 3003 02750 "/system/bin/netcfg"
#
# sets user:group to 0:3003 and perm to 02750 for the file /system/bin/netcfg
$CHOWN $1:$2 $4
$CHMOD $3 $4
}
set_perm_recursive() { # same as set_perm command in updater-script, for example:
#
# set_perm_recursive 0 2000 0755 0755 "/system/bin"
#
# sets uid:gid to 0:2000 and perm to 0755 for folders and 0755 for files recursively in /system/bin
$CHOWN -R $1:$2 $5
$CHMOD $3 $5
#chmod recursive of folder
$FIND $5/* -type d |while read folder; do
$CHMOD $3 $folder
done
#chmod recursive of files
$FIND $5/* -type f |while read file; do
$CHMOD $4 $file
done
}
There is no error handling (yet), so be carrefull when calling these functions
no FD, no output
Chainfire said:
This works because communication between recovery and update_binary is through a file descriptor (pipe). Recovery runs update_binary with the FD as command line parameter. Because the shell script is run as a child process of update_binary, it can write the same commands to that FD (commands recovery listens for), because child processes inherited FD numbers and access rights.
So, all the script has to do is figure out which FD to write to, and pass it the right commands. Finding the FD isn't difficult, as it is passed on the command line and so is listed in the output of ps. Some grep and cut magic retrieve it. See the OUTFD=$(...) line.
Click to expand...
Click to collapse
finding the FD is difficult on an SGY phone under MT 2.0 kernel, because is is not passed as command line param and therefore not in the ps output.
can anyone give an example of a working FD ?
the expression returns "" on my SGY, and no output is readable from script.
above zip as one file with the (.*) business removed from FD expression in myscript.sh
I don't see that ps gives me a "FD" in its output. whatever that really is. /tmp/recovery.log says that /sbin/recovery has no command line params either on SGY
from recov.log:
I:Set boot command "boot-recovery"
Command: "/sbin/recovery"
there is no FD in the command line ! where is it then ?
I'll test this in a bit. Nice hack b/w.
any news?
Thanks for this trick. What I wanted to do is to redirect stdout (and stderr) of my script to the UI. I know that you can see this in "show logs", but I wanted it to display right during the installation. Here is what I came up with:
Code:
#!/sbin/busybox ash
OUTFD=$(ps | grep -v "grep" | grep -o -E "update_binary(.*)" | cut -d " " -f 3);
/sbin/busybox ash $* 2>&1 |
while read -r line
do
echo "ui_print $line" >&$OUTFD;
echo "ui_print " >&$OUTFD;
done
If you save this as "scripts/stdoutwrapper.sh", you can do something like this:
Code:
package_extract_dir("scripts", "/tmp/update");
set_perm(0, 0, 0755, "/tmp/update/stdoutwrapper.sh");
run_program("/tmp/update/stdoutwrapper.sh", "/tmp/update/myscript.sh", "param1", "param2");
In myscript.sh, use any shell commands. The output will be redirected to the UI. Therefore, you should be able to write scripts that work both on the command line and in recovery without changes.
Please note: As all output will be printed, the tricks with set_progress etc. don't work. It would probably be possible to use a prefix to identify commands that should be executed, not printed, so you could do e.g. "echo '<#>set_progress 0.25'".
what value does OUTFD have? find out like below:
adb shell
ps
then /sbin/recovery might have PID 2166 on SGY phone
su
ls -l --color=never /proc/2166/fd
may give you e.g.
3 -> /dev/tty0
so 3 is your OUTFD !
now grep it accordingly for the script. use MT kernel 2.0 on SGY for above capability
time saver
edify Scripts may be tested by executing update-binary directly:
update-binary version output package
An example would be:
update-binary 2 stdout /sdcard/update.zip
Just noticed Chainfire's ui_print shell script in the latest SuperSU zip, and that lead me here.
Here are some updated versions (for CWM6?); ui_print and set_perm from SuperSU and the other 2 from my tinkering today:
Code:
OUTFD=$2;
ZIP=$3
ui_print() {
echo -ne "ui_print $1\n" > /proc/self/fd/$OUTFD;
echo -ne "ui_print\n" > /proc/self/fd/$OUTFD;
}
set_perm() {
chown $1.$2 $4
chown $1:$2 $4
chmod $3 $4
}
show_progress() { echo "progress $1 $2" > /proc/self/fd/$OUTFD; }
set_progress() { echo "set_progress $1" > /proc/self/fd/$OUTFD; }
ex:
show_progress 1.34 0;
ui_print "Hello world!";
set_progress 0.5;
ui_print " "; #blank line
set_progress 1.34;
ui_print "Done!";
Also worth noting he just uses busybox unzip to extract files from the flashable zip directly and goes from there.
ex:
ui_print "Extracting files!"
cd /tmp
unzip -o "$ZIP"
mai77 said:
what value does OUTFD have?
Click to expand...
Click to collapse
I put ui_print "Test: $OUTFD" in a script and the value of OUTFD appears to increase with every zip flashed.
Not much use knowing it in that case.
Nice work, I used this in my little zip. However, it doesn't work with TWRP. Is there any way to accomplish that?
sorry to put this here but could anyone direct me towards the cwm or TWRP version for "jxjpb" (asia) baseband pls?
klenamenis said:
Nice work, I used this in my little zip. However, it doesn't work with TWRP. Is there any way to accomplish that?
Click to expand...
Click to collapse
TWRP names the extracted update-binary "updater", so you can add something like this (or modify the regex in the existing line):
Code:
[ $OUTFD != "" ] || OUTFD=$(ps | grep -v "grep" | grep -o -E "updater(.*)" | cut -d " " -f 3)
_that said:
TWRP names the extracted update-binary "updater", so you can add something like this (or modify the regex in the existing line):
Code:
[ $OUTFD != "" ] || OUTFD=$(ps | grep -v "grep" | grep -o -E "updater(.*)" | cut -d " " -f 3)
Click to expand...
Click to collapse
Shouldn't be necessary with any reasonably current recovery. That was just a hack Chainfire wrote to get the FD back in the CWM3 days.
All that should be required (and has always worked for me) is to make the update-binary your shell script, then:
Code:
OUTFD=$2;
See my other updated commands above. And some zips I've made which should provide good references for people: Nexus Louder, Xposed Framework Installer, and Nexus BootUnlocker. All available in my Odds and Ends thread, linked in my sig.
osm0sis said:
Shouldn't be necessary with any reasonably current recovery. That was just a hack Chainfire wrote to get the FD back in the CWM3 days.
All that should be required (and has always worked for me) is to make the update-binary your shell script, then:
Code:
OUTFD=$2;
Click to expand...
Click to collapse
Yes, that works if you replace the whole update-binary with a shell script, but this method is for scripts that are called from the updater-script when using a binary updater.
I've recently switched to a shell script as updater too, but I had to write my own zip signing program because busybox unzip was unable to extract files from a zip signed by SignApk.
osm0sis said:
See my other updated commands above. And some zips I've made which should provide good references for people: Nexus Louder, Xposed Framework Installer, and Nexus BootUnlocker. All available in my Odds and Ends thread, linked in my sig.
Click to expand...
Click to collapse
Wow, nice collection! I remember some other posts from you that were very helpful, thanks!
_that said:
Yes, that works if you replace the whole update-binary with a shell script, but this method is for scripts that are called from the updater-script when using a binary updater.
I've recently switched to a shell script as updater too, but I had to write my own zip signing program because busybox unzip was unable to extract files from a zip signed by SignApk.
Wow, nice collection! I remember some other posts from you that were very helpful, thanks!
Click to expand...
Click to collapse
Nice! My misunderstanding then.
And ah yes, the old "1 and 8" issue with unzip. Might be resolved in the latest busybox 1.22.1 but I'm not 100% about that, and it'll be awhile before that makes it into recoveries.
I'd love to get hold of your zip signer if that'd be okay. I have Chainfire's solution, but I was still running into some verification problems (I think) from the MinSignApk whole file resigning.
osm0sis said:
And ah yes, the old "1 and 8" issue with unzip. Might be resolved in the latest busybox 1.22.1 but I'm not 100% about that, and it'll be awhile before it makes it into recoveries.
Click to expand...
Click to collapse
Exactly! I learned a lot about the zip format while researching this.
osm0sis said:
I'd love to get hold of your zip signer if that'd be okay. I have Chainfire's solution, but I was still running into some verification problems (I think) from the MinSignApk whole file resigning.
Click to expand...
Click to collapse
Argh! I saw your original question in that thread but I never found the solution because there were so many pages in between...
I ended up with a hack that appears to resemble Chainfire's minsignapk, but I didn't need to write my own zipadjust. Basically I simply sign the zip normally with signapk, then I unpack and repack the whole archive using 7zip (bonus: slightly better compression), and then I run the whole-zip-signer on the archive.
Here is my SignWholeFile.jar - the source code is just too ugly to publish. View attachment SignWholeFile.jar If you find that it works better than Chainfire's version, I'll clean the source and release it.
This is the script I use for signing:
Code:
#!/bin/sh
KEYDIR=~/android/aosp/build/target/product/security
SIGNAPK=~/android/aosp/prebuilts/sdk/tools/lib/signapk.jar
SIGNWHOLEFILE=~/android/src/signapk/SignWholeFile.jar
java -jar $SIGNAPK -w $KEYDIR/testkey.x509.pem $KEYDIR/testkey.pk8 "$1" "$1.signed.zip"
mv "$1" "$1.unsigned"
signedzip=$(readlink -f "$1.signed.zip")
[ -d /tmp/signapk2 ] && rm -rf /tmp/signapk2
mkdir /tmp/signapk2
pushd /tmp/signapk2
unzip $signedzip
rm $signedzip
7z a -r -mx=9 $signedzip *
#7z a -r $signedzip *
popd
mv "$1.signed.zip" "$1"
java -jar $SIGNWHOLEFILE $KEYDIR/testkey.x509.pem $KEYDIR/testkey.pk8 "$1" "$1"
Having dropped my desire and cracked the screen I would like to perform a factory wipe via ADB before I take it in for repair (I've backed it up).
I have the clockwork recovery which doesn't have the su/format commands and I am unable to find information on the other functions.
Any tips?
Many thanks!
Clockwork recovery offers all wipe and factory reset functions. 2.5.0.7, unless I'm missing something
He has no screen man, so gui is Wortes
Anyway, try this
Code:
adb shell
#wipe data
just a question, can you go from rooted desire with custom rom to stock by just wiping everyting in clockwork recovery?
I thought you needed to run a RUU update to put everything back to stock?
swimon said:
I thought you needed to run a RUU update to put everything back to stock?
Click to expand...
Click to collapse
That's right. But even if wipe all is not back to stock, it's better than leaving a rooted rom if you want to give it for repair i think.
try;
adb shell
wipe all
you need to add ./ to the start of adb if using a mac or linux
./adb shell
wipe all
Thanks for all the help guys!
I tried the *wipe* command, but I didn't have superuser mode set up.
To get into superuser, which was denied repeatedly I read that a popup usually shows on the phone requesting access. I think I managed to click that by tapping the screen on the left where "yes/accept" usually shows.
When I tried with superuser:
Code:
adb shell
su
wipe system
I got an long list of files that it was unable to delete.
At this point, I needed to leave and thought maybe the phone needed charging or something.
Coming back to it now, the phone is not recognised by ADB.
I've done a lot of searching and I think I must have unchecked the "usb debugging" from the notifications menu somehow.
So I have a new problem...
q) Is it possible to enable usb debugging with a cracked screen or otherwise get into the phone?
I connect the phone and just get android disk device/usb disk drive in windows manager.
I can reboot the phone into bootloader (with volume down held) and when I connect the phone I get bootloader interface appearing instead of disk drive but I just don't know where to go from there.
All I want is to clean the phone before I send it in for repair!
If anyone is able to help, I greatly appreciate it, if not thanks for your time.
In recovery you have full adb acces and can do all!
I would say, you try to make a nandroid backup and than flash the ruu
You take out your sd card and send than the device to them.
They wont to a forensic dataanalys, and most of the personal stuff is on the sd ;-)
Ps.: as far as i know you can flash ruus over fastboot(needs s-off)
And when you get your phone back, you root it and restore the last backup!
Pps.: if you haven't done a backup in the closer past you can sync, with htc sync with your pc! So you have atleast your contacts
Edit: when everything fails just keep the sd :-( they should be professional enough to keep your privacy! And i dont think your emails, sms and contacts are that different from all others :-D
Ah thanks, I thought I might be able to do that as I was mulling it over this morning. When I get home I'll give it a try and see if I succeed. I'll let you know how it goes!
Thanks for the tips and the advice on the nandroid backup - I do have a backup already - I did it when I cracked the screen as a pre-emptive, because at first I could see everything and I assumed it was just a crack but overnight the screen blacked out totally.
Ok, it's in recovery mode but doesn't seem to recognise wipe command. I added a directory listing of /sbin
Code:
C:\Program Files\Android\android-sdk\platform-tools>adb devices
List of devices attached
HT0XWPLXXXXX recovery
C:\Program Files\Android\android-sdk\platform-tools>adb shell
~ # wipe data
wipe data
/sbin/sh: wipe: not found
~ # wipe all
wipe all
/sbin/sh: wipe: not found
~ # wipe
wipe
/sbin/sh: wipe: not found
~ # ls
ls
cache etc res sdcard
data init root sys
default.prop init.rc sbin system
dev proc sd-ext tmp
~ # cd sbin
cd sbin
/sbin # ls
ls
[ erase_image mkswap sort
[[ expr mktemp split
adbd false mkyaffs2image stat
amend fdisk modprobe strings
ash fgrep more stty
awk find mount swapoff
basename flash_image mountpoint swapon
bbconfig fold mv sync
bunzip2 free nandroid sysctl
busybox freeramdisk nandroid-md5.sh tac
bzcat fuser nice tail
bzip2 getopt nohup tar
cal grep od tee
cat gunzip patch test
catv gzip pgrep time
chgrp head pidof top
chmod hexdump pkill touch
chown id printenv tr
chroot insmod printf true
cksum install ps tty
clear kill pwd tune2fs
cmp killall rdev umount
cp killall5 readlink uname
cpio killrecovery.sh realpath uniq
cut length reboot unix2dos
date less recovery unlzop
dc ln renice unyaffs
dd losetup reset unzip
depmod ls rm uptime
devmem lsmod rmdir usleep
df lspci rmmod uudecode
diff lsusb run-parts uuencode
dirname lzop sed watch
dmesg lzopcat seq wc
dos2unix md5sum setsid which
du mkdir sh whoami
dump_image mke2fs sha1sum xargs
echo mkfifo sha256sum yes
egrep mkfs.ext2 sha512sum zcat
env mknod sleep
/sbin #
su rm -rf *
Does that work? :/
Yep, that's done the trick. Thanks.
try a straight
adb shell wipe all
all on one line sometimes the shell boots incorrectly
Hello! This is my first walkthrough for one of my first accomplishments on my first android phone, the LG Optimus V. This guide will show you how to put debian squeeze into a chroot environment on your Optimus V. Lets get started!
Just a side note before we start:
I am not responsible for any mistake you made/in the hardware/software, so any problems with your phone is your own fault. I recommend backing up before a ROM install.
1) Root your phone.
I will not cover this, but there are many guides to root an Optimus V on Google. Just search it!
2) Install Custom Recovery Image (optional if your ROM has ext2 support)
Android 2.2 Froyo currently DOES NOT have ext2 support in the kernel, so we need to install an Android build that does. I used aospCMod, which works flawlessly. Download from dl.dropbox.com/u/14791765/preinstall.zip and unzip it. Move the "preinstall" folder over to your SD card on your Optimus. Now run these commands as root (I recommend using "adb shell" and then running "su" as the shell)
Code:
# The following installs "flash_image" to /system/bin, then makes it executable
cd /mnt/sdcard/preinstall
mount -o remount,rw -t yaffs2 /dev/block/mtdblock5 /system
cat flash_image > /system/bin/flash_image
chmod 755 /system/bin/flash_image
# The following flashes recovery-thunderc-v-1.2.0-GNM.img to recovery
flash_image recovery /mnt/sdcard/preinstall/recovery-thunderc-v-1.2.0-GNM.img
reboot recovery
Your phone should reboot into your newly flashed recovery partition
2.5) Install aospCMod (optional if your ROM has ext2 support)
Now, using the volume rocker, the menu button, and the back button, back up your phone, go to "Backup/Restore" -> "Backup Google proprietary system files" and press menu. This will back up your working system.
Now back at the main menu, navigate to "Flash zip menu" -> "Flash zip from Sdcard" -> "preinstall" -> "aospCMod-VM670-20110601-signed.zip". Install the ROM. Now do the same thing, but this time with "gapps-gb-20110325-signed.zip". After that, at the main menu, press "Reboot system now".
3) Create a Debian image file.
You have two options here. One, create your own (recommended) or two, download mine. I would download mine if you don't have linux and don't plan on getting it or don't really have time to set everything up. First and foremost though, you need to download dl.dropbox.com/u/14791765/debian.zip and unzip it to your SD card. My image is located here if you need it: dl.dropbox.com/u/14791765/debian-img.tar.gz Place it in your "debian" folder on your SD card. Afterwards, do these commands
Code:
cd /mnt/sdcard/debian
tar zxf debian-img.tar.gz
rm debian-img.tar.gz
If you do not want to download the whole 84 Mb file (which uncompresses to 1 Gb), create your own by doing this on Ubuntu Linux:
Code:
sudo -s
apt-get install debootstrap
dd if=/dev/zero of=debian.img seek=1024 bs=1M count=1
mke2fs -F debian.img
mkdir debian
mount -o loop debian.img debian/
debootstrap --verbose --arch armel --foreign lenny debian ftp.us.debian.org/debian
umount debian/
If you need the image file to take up less/more room, change "seek=1024" to "seek=[value-in-Mb]".
Now move your newly created "debian.img" to the "debian" folder on your SD card.
4) Install Debian
Almost done!
Back in your root shell, do these commands:
Code:
cd /mnt/sdcard/debian
sh installdebian
sh installdebian2
echo 'deb ftp.us.debian.org/debian squeeze main' > /etc/apt/sources.list
apt-get autoclean && apt-get update
export username="[insertyourfirstnamehere]"
adduser $username (this will ask for some data, put in as much or as little as you'd like)
apt-get install sudo
usermod $username -G sudo
exit
This should blah blah blah about debootstrap and configuring packages. Ignore it. It should finish in about 7-10 minutes. After that is done, the adduser command adds you to the system login files. After you enter "exit", you are all set to run Debian! To start debian, put this in your root shell/terminal emulator:
Code:
bootdebian
Wala! One ready-made LG Optimus V Debian, at your service! From here, you can install pretty much everything for Debian, including XOrg. I may post an update guide for how to install XOrg, VNC, and the like.
EDIT: If "sh installdebian" hangs on "Configuring: sysvinit", just do Control-C, and run it again.
meta1203 said:
Hello! This is my first walkthrough for one of my first accomplishments on my first android phone, the LG Optimus V. This guide will show you how to put debian squeeze into a chroot environment on your Optimus V. Lets get started!
Just a side note before we start:
I am not responsible for any mistake you made/in the hardware/software, so any problems with your phone is your own fault. I recommend backing up before a ROM install.
1) Root your phone.
I will not cover this, but there are many guides to root an Optimus V on Google. Just search it!
2) Install Custom Recovery Image (optional if your ROM has ext2 support)
Android 2.2 Froyo currently DOES NOT have ext2 support in the kernel, so we need to install an Android build that does. I used aospCMod, which works flawlessly. Download from dl.dropbox.com/u/14791765/preinstall.zip and unzip it. Move the "preinstall" folder over to your SD card on your Optimus. Now run these commands as root (I recommend using "adb shell" and then running "su" as the shell)
Code:
# The following installs "flash_image" to /system/bin, then makes it executable
cd /mnt/sdcard/preinstall
mount -o remount,rw -t yaffs2 /dev/block/mtdblock5 /system
cat flash_image > /system/bin/flash_image
chmod 755 /system/bin/flash_image
# The following flashes recovery-thunderc-v-1.2.0-GNM.img to recovery
flash_image recovery /mnt/sdcard/preinstall/recovery-thunderc-v-1.2.0-GNM.img
reboot recovery
Your phone should reboot into your newly flashed recovery partition
2.5) Install aospCMod (optional if your ROM has ext2 support)
Now, using the volume rocker, the menu button, and the back button, back up your phone, go to "Backup/Restore" -> "Backup Google proprietary system files" and press menu. This will back up your working system.
Now back at the main menu, navigate to "Flash zip menu" -> "Flash zip from Sdcard" -> "preinstall" -> "aospCMod-VM670-20110601-signed.zip". Install the ROM. Now do the same thing, but this time with "gapps-gb-20110325-signed.zip". After that, at the main menu, press "Reboot system now".
3) Create a Debian image file.
You have two options here. One, create your own (recommended) or two, download mine. I would download mine if you don't have linux and don't plan on getting it or don't really have time to set everything up. First and foremost though, you need to download dl.dropbox.com/u/14791765/debian.zip and unzip it to your SD card. My image is located here if you need it: dl.dropbox.com/u/14791765/debian-img.tar.gz Place it in your "debian" folder on your SD card. Afterwards, do these commands
Code:
cd /mnt/sdcard/debian
tar zxf debian-img.tar.gz
rm debian-img.tar.gz
If you do not want to download the whole 84 Mb file (which uncompresses to 1 Gb), create your own by doing this on Ubuntu Linux:
Code:
sudo -s
apt-get install debootstrap
dd if=/dev/zero of=debian.img seek=1024 bs=1M count=1
mke2fs -F debian.img
mkdir debian
mount -o loop debian.img debian/
debootstrap --verbose --arch armel --foreign lenny debian ftp.us.debian.org/debian
umount debian/
If you need the image file to take up less/more room, change "seek=1024" to "seek=[value-in-Mb]".
Now move your newly created "debian.img" to the "debian" folder on your SD card.
4) Install Debian
Almost done!
Back in your root shell, do these commands:
Code:
cd /mnt/sdcard/debian
sh installdebian
sh installdebian2
echo 'deb ftp.us.debian.org/debian squeeze main' > /etc/apt/sources.list
apt-get autoclean && apt-get update
export username="[insertyourfirstnamehere]"
adduser $username (this will ask for some data, put in as much or as little as you'd like)
apt-get install sudo
usermod $username -G sudo
exit
This should blah blah blah about debootstrap and configuring packages. Ignore it. It should finish in about 7-10 minutes. After that is done, the adduser command adds you to the system login files. After you enter "exit", you are all set to run Debian! To start debian, put this in your root shell/terminal emulator:
Code:
bootdebian
Wala! One ready-made LG Optimus V Debian, at your service! From here, you can install pretty much everything for Debian, including XOrg. I may post an update guide for how to install XOrg, VNC, and the like.
EDIT: If "sh installdebian" hangs on "Configuring: sysvinit", just do Control-C, and run it again.
Click to expand...
Click to collapse
Cool bro
Hi Guys
I'm knocking my head over the wall since one week. I'm trying to write a sh script that could install apk from a folder located on sdcard.
Writing the script seems simple, but running it doesn't give me the attended result.
Here is my script :
Code:
!/system/bin/sh
if [ -f /data/200notrestored ]
then
if ! cat /proc/mounts | grep /mnt/sdcard
then
mount /dev/block/mmcblk0p1 /mnt/sdcard;
fi;
if ! cat /proc/mounts | grep /data
then
mount /data;
fi;
test=""
while [ "$test" == "" ]
do
sleep 3;
test=`busybox ps | grep systemui | grep -v "$(echo grep systemui)"`
done
for app in /sdcard/.apps/toinstall/*.apk
do
pm install -r $app;
done;
busybox rm -f /data/200notrestored
fi;
this script is located in /system/etc/init.d fodler and is then supposed to run during the boot.
I've seen that it is run, but not fully.
The command line
Code:
pm install -r $app;
seems to be not working at all.
I tried to replace this command by "cp" and then the package is well copied.
Why do I need to use "pm" command... simply because someapk does't support the "cp" command, and need a proper install to be run.
So here is my question :
has someone succeed in writing a script (run during boot) that install an apk ?
If yes , how ?
I know for example that the script works well on a DHD... why not on a Desire ?
Any help appreciate.
thx
Just for information
Running the script thru Termianl emulator works fine.
What can be the issue when the file is run at boot (put in init.d folder) ? What is the difference from runnihbgit at boot and in terminal ?
any idea ?
thx
What is the most reliable recovery currently? I'm using twrp at the moment. It's probably an older version so I'm curious what is recommended before i update it.
Sent from my Kindle Fire using Tapatalk 2
pwned3 said:
What is the most reliable recovery currently? I'm using twrp at the moment. It's probably an older version so I'm curious what is recommended before i update it.
Sent from my Kindle Fire using Tapatalk 2
Click to expand...
Click to collapse
My suggestion would be for you to stay with TWRP. Version 2.1.1 is the latest.
kinfauns said:
My suggestion would be for you to stay with TWRP. Version 2.1.1 is the latest.
Click to expand...
Click to collapse
I agree
Sent from my Galaxy Nexus using XDA
pwned3 said:
What is the most reliable recovery currently? I'm using twrp at the moment. It's probably an older version so I'm curious what is recommended before i update it.
Click to expand...
Click to collapse
You already know that TWRP is intuitive and easy to use. I'm using TWRP 2.1.1 and I have used recovery many times when trying out new ROM builds. Occassionally with 2.1.1 I find that the operation that you want to do just fails with either an error outright or will fail during the recovery process. It even failed on me once while creating a backup. I didn't pay much attention to the backup output log text once and I did want to recover that backup and could not due to an image file being zero bytes in size. I have my own app and data backup script that I wrote that keeps me current so recovery in such a failed case is simply flashing a new ROM and executing my recovery script; couldn't be simpler.
If you pay attention to TWRP's output and not just make an assumption that the backup or recovery succeeded then you can just repeat the operation until it's successful. This is rare but has happened to me more than once but even with that issue, I still like TWRP 2.1.1 (plus my own app backup script).
I'll include my app backup and recovery script here in case others can find it useful (I make no claims that will work to your liking however or that it will even work for you)
rebaseline.sh
Code:
#!/system/xbin/bash
cd /sdcard/BACKUP/
for i in `/system/bin/pm list packages -3 -f`
do
read junk apk pkg <<< =`echo $i | sed -e 's/[=:]/ /g'`
echo "Processing $pkg..."
echo " backing up $apk..."
cp $apk baseline/
touch /sdcard/BACKUP/baseline/`basename $apk`
echo " backing up data..."
busybox tar czf /sdcard/BACKUP/baseline/$pkg.tar.gz --exclude lib --exclude cache /data/data/$pkg 2>/dev/null
done
echo "Processing accounts..."
echo " backing up data..."
busybox tar czf /sdcard/BACKUP/baseline/accounts.tar.gz /data/system/accounts.db 2>/dev/null
Here is my recovery script:
restore-from-baseline.sh
Code:
#!/system/xbin/bash
cd /sdcard/BACKUP
pm set-install-location 1
chmod 777 /data/data
for i in baseline/*apk
do
X=${i/-[0-9].apk}
Y=`basename $i`
Y=${Y/-[0-9].apk}
echo $X
pm install -r $i
# Find out what the new app ID is for the package
OWNER=`/system/bin/ls -l /data/data | grep $Y | awk '{print $3;}'`
echo $OWNER
# Restore data as the app owner ID
chmod 777 /data/data/$Y
su --command "tar xvf /sdcard/BACKUP/$X.tar.gz -C /" $OWNER
echo "tar rc=$?"
chmod 751 /data/data/$Y
echo
done
chmod 771 /data/data
echo "Restoring accounts.db - reboot will be required"
tar xvf /sdcard/BACKUP/baseline/accounts.tar.gz -C /
There is one limitation that I haven't worked into the script yet. Any time there is an app update you will see a duplicate app in the baseline folder differentiated by -1 or -2. Before recovery you can just get rid of the oldest version of the apk file; the data is always current.
I'm sure that there are a lot of apps that this script would not work with but it does work very well with mine and cuts down recovery to a minute or two. I don't use Titanium Backup myself.
I've been sticking with TWRP 2.1.1, simply because I really like how it can compress backups, meaning more space for music and videos. Haven't had any issues with it, but I do prefer the look of CWRecovery, particularly Hashcode's latest release.