Related
**New version in the works. See last page for my post**
**Updated 5:51pm CST**
-Made sweeping changes to the script. Thanks Farmatito for the suggestions. Output from script also goes to adb logcat
-See script for additional changelog
**Updated 11:00am CST**
-Changed a couple "cp" commands to "ln" as this is a smarter way of doing it. Script has been updated and re-uploaded
After having issues with the current a2sd script floating around (under certain environments the script would erase all user & system apps) I decided to update it so that there is proper error checking, logging, and back-out procedures on failure. The log is stored in /data/a2sd.log so if you get stuck at a black screen or it won't boot, now you can check the log and find out where its failing! By the way, if your phone won't boot or you have a black screen obviously the only way you can read the log is by connecting the phone to a pc and using adb shell cat /data/a2sd.log .
Anyways here it is, enjoy.
Procedure
Code:
adb remount
adb shell cp /system/bin/a2sd /system/bin/a2sd.bak
adb shell push a2sd.txt /system/bin/a2sd
adb shell chmod 777 /system/bin/a2sd
adb shell reboot
Everything should work like before. But you can rest at night knowing if your phone won't boot you now have a way to know if it was related to a2sd and what the cause was
**NOTE: If you get stuck at the boot screen it's probably b/c your /system/sd partition is failing the fsck. You should probably fsck it on your own to fix any corruption. If you don't want the fsck then comment it out of the script.
Very cool, lets hope a developer picks this up and uses it.
bubonik said:
Very cool, lets hope a developer picks this up and uses it.
Click to expand...
Click to collapse
I could toss this in my next build if the masses like it (sure they will)
I was going to read through this and give a full opinion but it is too long for me to do it this late. My eyes are crossing trying to read it. But at first glance it looks good (logs are always good right ). And I've never seen shafty not do good work. I'll try to look it over in full tomorrow. Plus you've inspired me to try to think of same way to contribute to this file. So now I have to put that on my todo list.
miketaylor00 said:
I was going to read through this and give a full opinion but it is too long for me to do it this late. My eyes are crossing trying to read it. But at first glance it looks good (logs are always good right ). And I've never seen shafty not do good work. I'll try to look it over in full tomorrow. Plus you've inspired me to try to think of same way to contribute to this file. So now I have to put that on my todo list.
Click to expand...
Click to collapse
O hell yea, mike the masters on it!
miketaylor00 said:
I was going to read through this and give a full opinion but it is too long for me to do it this late. My eyes are crossing trying to read it. But at first glance it looks good (logs are always good right ). And I've never seen shafty not do good work. I'll try to look it over in full tomorrow. Plus you've inspired me to try to think of same way to contribute to this file. So now I have to put that on my todo list.
Click to expand...
Click to collapse
The more the merrier. It's too bad everyone doesn't have bash installed or we'd be able to take advantage of all the features bash includes (functions, advanced iteration loops, arithmetic).
That would be on all the ROM devs to include it though. Oh and I'm a UNIX Admin so writing shell scripts is like 60% of my job. We try and make our lives easier by writing scripts to do the work for us
shafty023 said:
The more the merrier. It's too bad everyone doesn't have bash installed or we'd be able to take advantage of all the features bash includes (functions, advanced iteration loops, arithmetic).
That would be on all the ROM devs to include it though. Oh and I'm a UNIX Admin so writing shell scripts is like 60% of my job. We try and make our lives easier by writing scripts to do the work for us
Click to expand...
Click to collapse
I figured you did something like that. Your scripts are always good. I've learned a lot from reading through stuff that you have posted. I wish I had your experience with it. I always have to fumble through to find the right syntax to do what I want to do.
miketaylor00 said:
I figured you did something like that. Your scripts are always good. I've learned a lot from reading through stuff that you have posted. I wish I had your experience with it. I always have to fumble through to find the right syntax to do what I want to do.
Click to expand...
Click to collapse
Ya I started out fumbling around just as well. Keep at it and if you ever have any questions about how to do something feel free to PM me. Shell scripting, among the other 10 programming languages I code in fluently, come second nature after years of coding in them. Java/C/C++/Sh/Bash/Lisp/Javascript/Html/Php/Jquery.
shafty023 said:
Ya I started out fumbling around just as well. Keep at it and if you ever have any questions about how to do something feel free to PM me. Shell scripting, among the other 10 programming languages I code in fluently, come second nature after years of coding in them. Java/C/C++/Sh/Bash/Lisp/Javascript/Html/Php/Jquery.
Click to expand...
Click to collapse
Sweet, i will probably take you up on that offer sometime. I have a question about running e2fsck. I always run it with the -f option because it seems like it never finds problems unless they are really bad if I don't. Would there be a problem running it in your a2sd with -fy? I've always wondered why no one uses the -f option.
miketaylor00 said:
Sweet, i will probably take you up on that offer sometime. I have a question about running e2fsck. I always run it with the -f option because it seems like it never finds problems unless they are really bad if I don't. Would there be a problem running it in your a2sd with -fy? I've always wondered why no one uses the -f option.
Click to expand...
Click to collapse
Well there's two sides to this. One could argue we should force a fsck at every boot, and then the other side is to let Android mark the partition as dirty so fsck will run only when needed. Normally the filesystem is supposed to be marked dirty if in fact it is dirty.
So if we force a fsck at every boot then that would add to the boot time of the OS but then again would ensure the filesystem isn't corrupted. It's really personal preference. It breaks down to "Speed of boot" vs "filesystem integrity"
I can't even find a2sd in cm4.1.999. Seems to have gone missing. Anyone know if it exists, and if so, where it's at?
overground said:
I can't even find a2sd in cm4.1.999. Seems to have gone missing. Anyone know if it exists, and if so, where it's at?
Click to expand...
Click to collapse
The default location is /system/bin/a2sd . If it's not there not sure where else it could be hidden at
shafty023 said:
The default location is /system/bin/a2sd . If it's not there not sure where else it could be hidden at
Click to expand...
Click to collapse
That's where it should be and used to be. I looked in the original zip and it's not there either. Checked sbin and xbin and other places where it also shouldn't be, and can't find it...weird.
overground said:
That's where it should be and used to be. I looked in the original zip and it's not there either. Checked sbin and xbin and other places where it also shouldn't be, and can't find it...weird.
Click to expand...
Click to collapse
Perhaps it was integrated into the swap file. And I don't mean swap file as in the literal swap file. I mean /system/bin/swap which is a conf file & shell script in one. I would check there to see if it was incorporated in there.
Hi,
just some comments about the "monster" a2sd script. ;-)
Hope they will help you to imprrove it further.
I would suggest to change the logging so that
it could be seen during a adb logcat of the boot process, from:
echo "Beginning a2sd `date`" >$LOG;
to e.g:
echo "Beginning a2sd `date`" | busybox tee -a $LOG;
(LOG must be initialized if it not exists)
Line 40:
e2fsck -y /dev/block/mmcblk0p2;
if [ $? -ne 0 ];
then
echo "Fail" >>$LOG;
exit 1;
fi;
else
echo "Ok" >>$LOG;
fi;
# set property with exit code in case an error occurs
setprop cm.e2fsck.errors $?;
Setprop is not executed in case of errors as we do exit. Is this intended?
Line 144:
# don't allow /data/data on sd because of upgrade issues - move it if possible
if [ -d /system/sd/data ];
then
echo -n "Found /system/sd/data which is a no-no, removing: " >>$LOG;
busybox cp -a /system/sd/data/* /data/data/;
busybox rm -rf /system/sd/data;
echo "Ok" >>$LOG;
fi;
I suggest cp -ap to preserve permissions and ownership of the copied files
I suggest to mv /system/sd/data to /system/sd/data.bak if cp fails
rather than rm all the data
Line 195:
if [ `ls -l /data/$i/ | wc -l` -ne 0 ];
then
echo -n "Moving /data/$i: " >>$LOG;
busybox cp -a /data/$i/* /system/sd/$i/;
if [ $? -ne 0 ];
then
echo "Fail" >>$LOG;
busybox umount /system/sd;
exit 1;
else
echo "Ok" >>$LOG;
fi;
fi;
I suggest to use cp -ap to preserve permissions and ownership
Line 206:
echo -n "Deleting contents in /data/$i: " >>$LOG;
busybox rm -f /data/$i/*;
I suggest rm -fR /data/$i;
Line 329:
if [ -f /system/lib/hw/lights.msm7k.so ] && [ ! -e /system/lib/hw/lights.trout.so ];
then
busybox cp /system/lib/hw/lights.msm7k.so /system/lib/hw/lights.trout.so;
fi;
if [ -f /system/lib/hw/copybit.msm7k.so ] && [ ! -e /system/lib/hw/copybit.trout.so ];
then
busybox cp /system/lib/hw/copybit.msm7k.so /system/lib/hw/copybit.trout.so;
fi;
if [ -f /system/lib/hw/sensors.msm7k.so ] && [ ! -e /system/lib/hw/sensors.trout.so ];
then
busybox ln -s /system/lib/hw/sensors.msm7k.so /system/lib/hw/sensors.trout.so;
fi;
I suggest to use ln for all.
Line 353:
/system/bin/sh /system/bin/swap;
Cannot find /system/bin/swap on my rom, maybe
if [ -e /system/bin/swap ] ; then.
shafty023 said:
The default location is /system/bin/a2sd . If it's not there not sure where else it could be hidden at
Click to expand...
Click to collapse
update-cm-4.1.99-signed/system/etc/init.d/04apps2sd
farmatito said:
update-cm-4.1.99-signed/system/etc/init.d/04apps2sd
Click to expand...
Click to collapse
Thank you...knew it had to be in there. Love your work, BTW.
echo "Beginning a2sd `date`" >$LOG;
to e.g:
echo "Beginning a2sd `date`" | busybox tee -a $LOG;
Click to expand...
Click to collapse
Unfortunately during boot anything thrown to console is not caught by adb logcat, BUT! You gave me a good idea, it will now look like this
Code:
/system/bin/logwrapper echo "Beginning a2sd `date`";
# set property with exit code in case an error occurs
setprop cm.e2fsck.errors $?;
Click to expand...
Click to collapse
Removed
Line 144:
# don't allow /data/data on sd because of upgrade issues - move it if possible
if [ -d /system/sd/data ];
then
echo -n "Found /system/sd/data which is a no-no, removing: " >>$LOG;
busybox cp -a /system/sd/data/* /data/data/;
busybox rm -rf /system/sd/data;
echo "Ok" >>$LOG;
fi;
I suggest cp -ap to preserve permissions and ownership of the copied files
I suggest to mv /system/sd/data to /system/sd/data.bak if cp fails
rather than rm all the data
Click to expand...
Click to collapse
Great catch, this has been changed
Line 195:
if [ `ls -l /data/$i/ | wc -l` -ne 0 ];
then
echo -n "Moving /data/$i: " >>$LOG;
busybox cp -a /data/$i/* /system/sd/$i/;
if [ $? -ne 0 ];
then
echo "Fail" >>$LOG;
busybox umount /system/sd;
exit 1;
else
echo "Ok" >>$LOG;
fi;
fi;
I suggest to use cp -ap to preserve permissions and ownership
Click to expand...
Click to collapse
Changed
Line 206:
echo -n "Deleting contents in /data/$i: " >>$LOG;
busybox rm -f /data/$i/*;
I suggest rm -fR /data/$i;
Click to expand...
Click to collapse
This was already being done in the following FOR loop but after inspecting further I merged the app symlinks FOR loop with this IF statement.
Line 329:
if [ -f /system/lib/hw/lights.msm7k.so ] && [ ! -e /system/lib/hw/lights.trout.so ];
then
busybox cp /system/lib/hw/lights.msm7k.so /system/lib/hw/lights.trout.so;
fi;
if [ -f /system/lib/hw/copybit.msm7k.so ] && [ ! -e /system/lib/hw/copybit.trout.so ];
then
busybox cp /system/lib/hw/copybit.msm7k.so /system/lib/hw/copybit.trout.so;
fi;
if [ -f /system/lib/hw/sensors.msm7k.so ] && [ ! -e /system/lib/hw/sensors.trout.so ];
then
busybox ln -s /system/lib/hw/sensors.msm7k.so /system/lib/hw/sensors.trout.so;
fi;
I suggest to use ln for all.
Click to expand...
Click to collapse
This change has already been made and I uploaded a new script earlier today.
Line 353:
/system/bin/sh /system/bin/swap;
Cannot find /system/bin/swap on my rom, maybe
if [ -e /system/bin/swap ] ; then.
Click to expand...
Click to collapse
Added.
Thanks for all your suggestions, I will re-upload a new version in an hour or so soon as I get a chance to change the echo commands to use logwrapper. Well I'm keeping the existing echo commands which spit output to my log but will also add another which will spit output to logcat.
miketaylor00 said:
Sweet, i will probably take you up on that offer sometime. I have a question about running e2fsck. I always run it with the -f option because it seems like it never finds problems unless they are really bad if I don't. Would there be a problem running it in your a2sd with -fy? I've always wondered why no one uses the -f option.
Click to expand...
Click to collapse
I take it back, after having suffered yet another file system corruption on my /system/sd partition I'm putting that darn "-f" in there. I'll re-upload a new copy with other changes shortly
Posted a new copy of the a2sd script with lots of changes. Check it out everyone. As always suggestions & questions are welcome
I had an Idea for a script that would run at bootup, and if a certain variable had a "value" of NOT 1.
then the script would change the CHMOD of a userinit.sh located in the sd-ext from 050 or 777 to 750 then it would change the variable "value" to 0 were it would stay untill another script that runs at shut down or reboot setts the variable to 1 and changes CHMOD back to 050 or 777 so that the userinit.sh is not run.
That way if a change is made during operating the phone that causes the phone to crash with out shutting down properly the script runs which causes the userinit.sh to run and "resets" userinit.sh values to a "default". Otherwise if shut down properly nothing happens.
This could be expanded on to include repairing the EXT or clearing some special cache or other stuff I am unfamiliar with but that you might want to run after a crash.(like logcat?)
any way what do you think? any promise?
I think, for overclocking purposes anyway, making the userinit.sh unrunnable would make the phone break immediately, as I think it would go to the highest available frequency. However, I like the idea, though I'm not sure how to run scripts on shutdown. I think for overclocking, it would check if the shutdown was clean on startup, and if not change the applicable line to the next lowest number, which it would get either from a seperate file or maybe it could be stuffed in the script itself. (Just my somewhat uneducated thoughts)
TheNewGuy said:
I had an Idea for a script that would run at bootup, and if a certain variable had a "value" of NOT 1.
then the script would change the CHMOD of a userinit.sh located in the sd-ext from 050 or 777 to 750 then it would change the variable "value" to 0 were it would stay untill another script that runs at shut down or reboot setts the variable to 1 and changes CHMOD back to 050 or 777 so that the userinit.sh is not run.
That way if a change is made during operating the phone that causes the phone to crash with out shutting down properly the script runs which causes the userinit.sh to run and "resets" userinit.sh values to a "default". Otherwise if shut down properly nothing happens.
This could be expanded on to include repairing the EXT or clearing some special cache or other stuff I am unfamiliar with but that you might want to run after a crash.(like logcat?)
any way what do you think? any promise?
Click to expand...
Click to collapse
Keep it simple. If a change in userinit.sh breaks your system, reboot to recovery and edit it and reboot again.
TheNewGuy said:
I had an Idea for a script that would run at bootup, and if a certain variable had a "value" of NOT 1.
then the script would change the CHMOD of a userinit.sh located in the sd-ext from 050 or 777 to 750 then it would change the variable "value" to 0 were it would stay untill another script that runs at shut down or reboot setts the variable to 1 and changes CHMOD back to 050 or 777 so that the userinit.sh is not run.
That way if a change is made during operating the phone that causes the phone to crash with out shutting down properly the script runs which causes the userinit.sh to run and "resets" userinit.sh values to a "default". Otherwise if shut down properly nothing happens.
This could be expanded on to include repairing the EXT or clearing some special cache or other stuff I am unfamiliar with but that you might want to run after a crash.(like logcat?)
any way what do you think? any promise?
Click to expand...
Click to collapse
most rom devs/tweakers launch userinit.sh by calling it with a sh
e.g.
/system/bin/sh /system/sd/userinit.sh
so it will still run !! ( as init doesn't care about permissions, it is god )
don't believe me?
Code:
echo "echo I ran" > /data/test.sh
chmod 000 /data/test.sh
sh /data/test.sh
Keep it simple. If a change in userinit.sh breaks your system, reboot to recovery and edit it and reboot again.
Click to expand...
Click to collapse
Yea thats the easy way!...
(Seriously I'm not that good at Linux Command Line code,wording,but i'm getting there.)
I think, for overclocking purposes anyway, making the userinit.sh unrunnable would make the phone break immediately, as I think it would go to the highest available frequency. However, I like the idea, though I'm not sure how to run scripts on shutdown. I think for overclocking, it would check if the shutdown was clean on startup, and if not change the applicable line to the next lowest number, which it would get either from a seperate file or maybe it could be stuffed in the script itself. (Just my somewhat uneducated thoughts)
Reply With Quote
Click to expand...
Click to collapse
And I know that most roms now have a script called something like in /system/etc/init.d/20userinit that runs at startup and checks to see if a userinit.sh is present in sd-ext,if so it runs it.Also I noticed that the script can be there but if it is CHMOD to 777 it wont run. This is the "Reset script" Set to restet to something you like and run other tasks to help Fix/Diagnose probs.
The OC changes would be made from a different script such as 86supersettings
Or a userinit located in system/sd maybe ?
The thing is making sure one is read before the other.
Any way I probably will just learn the language better and do it from recovery console.
Thanks again
TheNewGuy said:
Yea thats the easy way!...
(Seriously I'm not that good at Linux Command Line code,wording,but i'm getting there.)
And I know that most roms now have a script called something like in /system/etc/init.d/20userinit that runs at startup and checks to see if a userinit.sh is present in sd-ext,if so it runs it.Also I noticed that the script can be there but if it is CHMOD to 777 it wont run. This is the "Reset script" Set to restet to something you like and run other tasks to help Fix/Diagnose probs.
The OC changes would be made from a different script such as 86supersettings
Or a userinit located in system/sd maybe ?
The thing is making sure one is read before the other.
Any way I probably will just learn the language better and do it from recovery console.
Thanks again
Click to expand...
Click to collapse
chmod 777 makes it rw and executable by everyone!!!!!!!!
have a look here
http://www.comptechdoc.org/os/linux/usersguide/linux_ugfilesp.html
but as I mentioned above, init ( the initial progam runs as root and doesn't care about permissions, ( it wouldn't be very good at doing initialising the system if it had to seek permission )
Yea your right. Well I said I wasn't that good at this linux stuff! Now I Proved it.
Any way as you can see this is more of a request..... I still think it's a good Idea.
Thanks for your help FireRat.
Keep it simple. If a change in userinit.sh breaks your system, reboot to recovery and edit it and reboot again.
Click to expand...
Click to collapse
I understand how I could manualy Replace the modified script with a default one that was on my sdcard from within recovery after a faild OC change...but..
Are you saying I could actualy modify the original script from recover? Do you have any info on how? A link?
TheNewGuy said:
I understand how I could manualy Replace the modified script with a default one that was on my sdcard from within recovery after a faild OC change...but..
Are you saying I could actualy modify the original script from recover? Do you have any info on how? A link?
Click to expand...
Click to collapse
If you have RA-Recovery, adb works, so you can pull/push the userinit.sh script. You can also enter the terminal and use vi to edit it from recovery. You may have to mount the ext partition first, but that's pretty easy. "mount /system/sd" will do it, if /system/sd doesn't exist, "mkdir /system/sd".
Ok, Thanks that makes sense. I'm still learning adb though. And I tried vi once before with no luck. But now I know what to learn about.
Thanks a lot I appreciate it.
TheNewGuy said:
Ok, Thanks that makes sense. I'm still learning adb though. And I tried vi once before with no luck. But now I know what to learn about.
Thanks a lot I appreciate it.
Click to expand...
Click to collapse
ok, this would do what you want
/system/bin/shutdown
bold is new
Code:
#!/system/bin/sh
stop;
stop dhcpcd;
sleep 1;
[B]echo "1" > /data/cleanshutdown[/B]
for i in `cat /proc/mounts | cut -f 2 -d " "`;
do
busybox mount -o remount,ro $i 2>&1 > /dev/null;
done
sync;
if [ "$1" = "-r" ];
then
toolbox reboot -f;
else
toolbox reboot -fp;
fi
your script
Code:
#!/system/bin/sh
if [ "`cat /data/cleanshutdown`" != "1" ];
then
echo "shutdown was not clean"
[B]your tweaks[/B]
else
echo "shutdown was clean"
[B]your tweaks[/B]
fi
echo "0" > /data/cleanshutdown
I'm not sure you need it,
this is for education value, if you want to play ^^^ is where to start
Thank You!
That is perfect
I need to add all of this to the startup script right?
if [ "`cat /data/cleanshutdown`" != "1" ];
then
echo "shutdown was not clean"
your tweaks
else
echo "shutdown was clean"
your tweaks
fi
echo "0" > /data/cleanshutdown
Click to expand...
Click to collapse
I am going to use the beta boot up script from ZKX called 86Supersettings, but I could use a userinit/user.conf like most do. Correct?
TheNewGuy said:
Thank You!
That is perfect
I need to add all of this to the startup script right?
I am going to use the beta boot up script from ZKX called 86Supersettings, but I could use a userinit/user.conf like most do. Correct?
Click to expand...
Click to collapse
well, a .conf file should be just that
a file with configurations , not an executable script
well, a .conf file should be just that
a file with configurations , not an executable script
Click to expand...
Click to collapse
OK. I guess I meant both together. I would use the user.conf to make tweaks. Then have to modify the userinit.sh with the part you made. Something like.
#!/system/bin/sh--LEAVE THIS OUT. ITS ALL READY AT THE BEGINNING
if [ "`cat /data/cleanshutdown`" != "1" ];
then
echo "shutdown was not clean"
Dont run user.conf
and set cpu or other stuff to "default"
else
echo "shutdown was clean"
Run user.conf for tweaked settings
fi
echo "0" > /data/cleanshutdown
Click to expand...
Click to collapse
If I'm way off then I guess I need to re-read the Userinit thread.
TheNewGuy said:
OK. I guess I meant both together. I would use the user.conf to make tweaks. Then have to modify the userinit.sh with the part you made. Something like.
If I'm way off then I guess I need to re-read the Userinit thread.
Click to expand...
Click to collapse
well, in practise it doesn't matter
the file extension is only for use humans, if I'm looking in a directory and I see .conf I expect it to be a configuration file, I see .sh, its a shell script, .py python, pl perl .......
I see. Well Thanks again for your help. Your script does work. I tried it. crash on purpose.
I still have a lot to learn.
Folks;
1) If you're OC'ing via SetCPU, remember that this doesn't change the recovery kernel, and you can uninstall SetCPU from Recovery. From there, all you need is a "safe" userinit.sh.
3) If you're OC'ing via userinit.sh -- same deal. Your phone crashes on you and you just edit it to a safe config from recovery.
Tweak away.
This is what I ended up with
Thanks to
XxKolohexX
FireRat
Licknuts
Code:
#!/system/bin/sh
#
echo 255 >/sys/class/leds/blue/brightness;
echo "+++ Now entering the speedy madness of Z.X.D.!"
echo "----- let's clear that Cache first."
echo "----- Too much DBs make System go sloow..."
echo "----- Also be shure to check out CacheMate"
echo "----- It's in the Market. (Made by Android AppCritic)."
echo "----- It's way more powerfull than this script!"
echo "----- (Times 10 or 100... Clears everything :P)"
echo "----- And this script already took hours to build..."
echo "----- domenukk - 2010."
find /data/data -name app_admob_cache | while read line; do du -s $line/* | cut -f1; rm -Rf $line/*; done;
find /data/data -name cache | while read line; do du -s $line/* | cut -f1; rm -Rf $line/*; done;
find /data/data -name google_analytics.db | while read line; do du -s $line | cut -f1; rm -Rf $line; done;
find /data/data -name webviewCache.db | while read line; do du -s $line | cut -f1; rm -Rf $line; done;
rm -rf /data/data/com.facebook.katana/files
rm -rf /data/data/com.google.android.apps.genie.geniewidget/app_news_image_cache
rm -rf /data/data/com.code.i.music/app_admob_cache
rm -rf /data/data/fm.last.android/databases/google_analytics.db
echo "--- All the Cache has been cleared."
sleep 10
echo 0 >/sys/class/leds/blue/brightness;
####determin if shutdown was clean####
if [ "`cat /data/cleanshutdown`" != "1" ];
then
####RUN CLEAN SHUTDOWN SCRIPT####
echo 255 >/sys/class/leds/green/brightness;
####Turbo Script by [email protected]####
####Prioritize everyting ####
echo "----- Enabling Turbo."
dirty_writeback_centisecs=500
/system/bin/prior &
#
# Linux-SWAP
#
if [ -e /dev/block/mmcblk0p3 ];
then
if [ -n /dev/block/mmcblk0p3 ];
then
echo "+++ Set Linux Swap"
busybox mkswap /dev/block/mmcblk0p3;
fi;
if [ -e /dev/block/mmcblk0p3 ];
then
echo "+++ Set Swapiness"
echo 100 > /proc/sys/vm/swappiness;
echo "+++ Activate Swap"
busybox swapon /dev/block/mmcblk0p3;
fi;
fi;
####Better CPU Settings...####
echo "----- Speed up the CPU"
echo 633600 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq;
echo 122800 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq;
echo 95 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold;
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice_load;
echo 100000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate;
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias;
echo 0 >/sys/class/leds/green/brightness;
echo 255 >/sys/class/leds/blue/brightness;
else
####RUN DIRTY SHUTDOWN SCRIPT####
echo 255 >/sys/class/leds/red/brightness;
####Turbo Script by [email protected]####
####Prioritize everyting ####
echo "----- Enabling Turbo."
dirty_writeback_centisecs=500
/system/bin/prior &
#
# Linux-SWAP
#
if [ -e /dev/block/mmcblk0p3 ];
then
if [ -n /dev/block/mmcblk0p3 ];
then
echo "+++ Set Linux Swap"
busybox mkswap /dev/block/mmcblk0p3;
fi;
if [ -e /dev/block/mmcblk0p3 ];
then
echo "+++ Set Swapiness"
echo 83 > /proc/sys/vm/swappiness;
echo "+++ Activate Swap"
busybox swapon /dev/block/mmcblk0p3;
fi;
fi;
####Better CPU Settings...####
echo "----- Speed up the CPU"
echo 576000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq;
echo 122800 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq;
echo 45 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold;
echo 0 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice_load;
echo 2000000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate;
echo 200 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias;
fi;
echo "0" > /data/cleanshutdown
echo "+++ continue on lame stock SuperD boot "
##Clearing Davlik-Cache##
for dc in dalvik-cache;
do
umount /cache/$dc;
rm -fr /cache/$dc;
mkdir /cache/$dc;
chown 1000:1000 /cache/$dc;
chmod 771 /cache/$dc;
mount -o bind /data/$dc /cache/$dc;
done;
Named 86supersettings so it runs after userinit.sh if one exists.
I put some Led indicators in so you can tell if it ran right at boot up. (about all I did besides copy and paste) Thinking about adding some other stuff like repair ext, or some kind of log to help me see what happed... any suggestions.
OK, here's another Idea for another safety feature...
I would like to "hard code" a temp fail-safe in to the code. I would like to get rid of SetCPU and when OC-ing it's nice to have a temp failsafe.SHUTDOWN!LOL
Any way I guess I would just add a few lines to some existing script in my phone?.... Any suggestions.
Thanks for your time.
Even though I put this in the Epic forum, this will work on any zImage based android kernel as far as I am aware.. from Eclair to Gingerbread, maybe previous, maybe in the future..
I will post my tweaks here (please give credit), and even my ext4 modules (again please give credit, to both me and Rodderik, as he helped with one of them) for Gingerbread.
First off, you will need either a linux based computer, a remote linux box, or a virtual machine.. I don't think cygwin will be enough. I'm not going to go through the steps of setting that up because it's out of the scope of this How-to, maybe in another post.
Second, you need some scripts to decompile the initramfs from the kernel, or you can do it manually with grep or a hex editor ( I don't recommend ), I'll provide the scripts I use, which I procured from supercurio's project voodoo github then modified to work a little better with zImages that have 2 signatures (happens sometimes) like EH06...
http://chris41g.devphone.org/voodoo.tar.gz
in voodoo/config.sh you will need to set your compiler path.
also read the readme.txt it will pretty much describe how it all works, and remember all the gingebread leaks only work with gzip compression when repacking.
to unpack the initramfs
Code:
./extracter.sh -s "/path/to/original/zImage" -d "/path/where/you/want/initramfs/"
and after a few minutes your initramfs will be wherever you told it to go with -d.
now the initramfs is pretty much the meat and potatoes when repacking a kernel.
adding EXT4
this is a pretty popular request...
to do this you need just a few things, the correct modules, and the correct mount options. both of which i will provide.
the modules for Gingerbread are called ext4.ko and mbcache.ko and need to added to lib/modules in the initramfs - link http://chris41g.devphone.org/gbext4modules.tar.gz
then the following lines need to be added to init.rc lpm.rc and recovery.rc
Code:
insmod /lib/modules/mbcache.ko
insmod /lib/modules/ext4.ko
right around the lines that look like
Code:
insmod /lib/modules/fsr.ko
insmod /lib/modules/fsr_stl.ko
insmod /lib/modules/rfs_glue.ko
insmod /lib/modules/rfs_fat.ko
to the same files look for:
Code:
mount rfs /dev/block/stl9 /system check=no
and under it add
Code:
mount ext4 /dev/block/stl9 /system noatime nodiratime errors=continue
now in init.rc and recovery.rc look for
Code:
mount rfs /dev/block/stl10 /data nosuid nodev crypt check=no
and under it add
Code:
mount ext4 /dev/block/stl10 /data nosuid nodev crypt noatime nodiratime
and look for
Code:
mount rfs /dev/block/stl11 /cache nosuid nodev check=no
and under it add
Code:
mount ext4 /dev/block/stl11 /cache nosuid nodev noatime nodiratime errors=continue nobh data=writeback barrier=0 noauto_da_alloc
now usually there will be some stuff you need to comment out.. which means adding # to the beginning of the line..
i always comment this out because it can mess with my tweaks later on and its useless
Code:
mount rfs /dev/block/stl9 /system ro remount
i also comment out or delete left over stuff for other phones that samsung has a habit of leaving in our init.rc... lazy people..
How to Root a Kernel Re-Pack:
This may seem basic, and to some it is, but I'm going to cover it anyway. Also it has changed in gingerbread, as you can't suid anything in /sbin, and that is the beginning of your PATH.
First we need some files.
su binary Stable - http://forum.xda-developers.com/showthread.php?t=682828 Beta - http://chris41g.devphone.org/su3.tar.gz
Superuser.apk Beta - http://chris41g.devphone.org/Superuser.apk
busybox binary (this one is dependent on whether you have purple cwm built in or not, since we havent got that far ill assume you dont) busybox 1.20.0 compiled by me http://chris41g.devphone.org/busybox
copy those files into /sbin in the initramfs, also do a
Code:
ln -s busybox sh
from the sbin directory in your initramfs on your linux box to make a symlink from sh to busybox
then goto the initramfs root
and do
Code:
ln -s sbin bin
to make a symlink from sbin to bin, it's probably not necessary but i always do it for consistency.
now go into /sbin and make a new sh script called whatever you want.
Code:
#!/system/bin/sh
# Remount filesystems RW
busybox mount -o remount,rw /
busybox mount -o remount,rw /system
#install busybox links
busybox cp /sbin/busybox /system/bin/busybox
/system/bin/busybox rm /sbin/busybox
busybox --install -s /system/bin
busybox --install -s /system/xbin
#establish root
busybox cp -f /sbin/su /system/bin/su
chmod 6755 /system/bin/su
busybox rm /sbin/su
busybox ln -s /system/bin/su /system/xbin/su
#check if Superuser.apk exist if not install but also delete bloat to make room
if [ ! -f "/system/app/Superuser.apk" ] && [ ! -f "/data/app/Superuser.apk" ] && [[ ! -f "/data/app/com.noshufou.android.su"* ]]; then
if [ -f "/system/app/Asphalt5_DEMO_ANMP_Samsung_D700_Sprint_ML.apk" ]; then
busybox rm /system/app/Asphalt5_DEMO_ANMP_Samsung_D700_Sprint_ML.apk
fi
if [ -f "/system/app/Asphalt5_DEMO_SAMSUNG_D700_Sprint_ML_330.apk" ]; then
busybox rm /system/app/Asphalt5_DEMO_SAMSUNG_D700_Sprint_ML_330.apk
fi
if [ -f "/system/app/FreeHDGameDemos.apk" ]; then
busybox rm /system/app/FreeHDGameDemos.apk
fi
busybox cp /sbin/Superuser.apk /system/app/Superuser.apk
fi
sync
# Fix screwy ownerships
for blip in conf default.prop fota.rc init init.goldfish.rc init.rc init.smdkc110.rc lib lpm.rc modules recovery.rc res sbin bin
do
chown root.shell /$blip
chown root.shell /$blip/*
done
chown root.shell /lib/modules/*
chown root.shell /res/images/*
#setup proper passwd and group files for 3rd party root access
# Thanks DevinXtreme
if [ ! -f "/system/etc/passwd" ]; then
echo "root::0:0:root:/data/local:/system/bin/sh" > /system/etc/passwd
chmod 0666 /system/etc/passwd
fi
if [ ! -f "/system/etc/group" ]; then
echo "root::0:" > /system/etc/group
chmod 0666 /system/etc/group
fi
# fix busybox DNS while system is read-write
if [ ! -f "/system/etc/resolv.conf" ]; then
echo "nameserver 8.8.8.8" >> /system/etc/resolv.conf
echo "nameserver 8.8.4.4" >> /system/etc/resolv.conf
fi
sync
# patch to prevent certain malware apps
if [ -f "/system/bin/profile" ]; then
busybox rm /system/bin/profile
fi
touch /system/bin/profile
chmod 644 /system/bin/profile
# remount read only and continue
busybox mount -o remount,ro /
busybox mount -o remount,ro /system
Now you need to make a change in your init.rc file to call this new script..
add this to your init.rc in the services section, around where the factory bootanimation service is loaded.
Code:
# Custom Script Configuration
service userscript /system/bin/sh /sbin/[whateveryounamedyour].sh
user root
group system
critical
oneshot
now you have rooted your own repack...
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Adding init.d support...
this is pretty easy, didn't want to add another post..
Let's open up /sbin/[whateveryounamedyour].sh
right after installing Superuser.apk, lets add this section...
Code:
if [ -d /system/etc/init.d ]
then
logwrapper busybox run-parts /system/etc/init.d
fi
sync
There ya go, thats it, you're done..
-----------------------------------------------------------------------------------------------------------------------------------------------
Ok, since I'm on a roll haha lets go with bootanimations... they are different on Gingerbread..
this is all done in the init.rc so lets open that up in your text editor, I recommend Geany btw..
First off in GB I had to disable stock animations to make it not look like trash, because they won't always start at the same time.. but it's your option.. ymmv
Code:
service samsungani /system/bin/samsungani
user graphics
group graphics
disabled
oneshot
Comment that section if you want to disable the stock animations... you can leave it and custom animations will still work if you want, but fair warning, its weird...
Code:
service bootanim /system/bin/bootanimation
user graphics
group graphics
critical
oneshot
Add that section to enable custom animations..
I never have but just incase you want to, you can comment this section out to disable boot sounds..
Code:
service playsound /system/bin/playsound
user media
group system
disabled
oneshot
one more thing, the new binary works, but it doesn't know when to stop playing....
add this line to the very end of the init.rc
Code:
on property:sys.boot_completed=1
stop bootanim
Thanks to tanimn for help on that one...
Now remember, before gingerbread, custom animations were bootanimation.zip, but now they are sanim.zip you can leave it that way, or for the users sake you can crack open the [whateveryounamedyour].sh and make a workaround.
add this line to [whateveryounamedyour].sh before you remount the partitions at the end.
Code:
busybox ln -s /system/media/bootanimation.zip /system/media/sanim.zip
basically what that does is create a symlink from the users bootanimation.zip to sanim.zip, so when the bootanimation binary looks for sanim.zip its redirected to bootanimation.zip.. so the user can put bootanimation.zip in the directory transparently without having to rename...
More to come, and I'm still taking request for additions to this how to....
awesome! thanks for the post... maybe I can start putting that programming class I had last semester to good use...
Joey
holy crap...I needed this about a month ago. thanks for putting it all in one place!! and jw....why do we need the mbcache.ko? ext4 worked fine without it, in a kernel I did.
sent from my uncyanogen modded epic 4g. with the key skips.
You know I don't even know what a plus kernel does but I use it for the old school android boot animation
Sent from my SPH-D700 using xda premium
ahh nice! cant wait for the others!
I really wanted this thank for the info!
Sent from my SPH-D700 using xda premium
Anyone ... what does the plus kernel do ?
Sent from my SPH-D700 using xda premium
Digglez said:
Anyone ... what does the plus kernel do ?
Sent from my SPH-D700 using xda premium
Click to expand...
Click to collapse
Its basically a stock kernel with mods.
Sent from my SPH-D700 using xda premium
Any mods besides the boot animation
Sent from my SPH-D700 using xda premium
Digglez said:
Any mods besides the boot animation
Sent from my SPH-D700 using xda premium
Click to expand...
Click to collapse
So far, adding ext4 modules is the only mod he's shown how to do. He'll be updating his thread with more mods soon.
Sent from my SPH-D700 using xda premium
Digglez said:
Any mods besides the boot animation
Sent from my SPH-D700 using xda premium
Click to expand...
Click to collapse
You can include boot animation...he just hasn't shown how to do it yet like ceelos said
Like I said in the first post, I will take request, within reason...
chris41g said:
Like I said in the first post, I will take request, within reason...
Click to expand...
Click to collapse
Any way you can show us how to bake mods into the kernel? Like say, superuser, so we make pre-rooted kernels
Sent from my SPH-D700 using xda premium
Ceelos09 said:
Any way you can show us how to bake mods into the kernel? Like say, superuser, so we make pre-rooted kernels
Sent from my SPH-D700 using xda premium
Click to expand...
Click to collapse
Updated just now with rooting, init.d support, and bootanimations..
Could you add how to do a cwm redirector? I've searched everywhere and can't find how.
that will be one of the upcoming topics..
chris41g said:
Updated just now with rooting, init.d support, and bootanimations..
Click to expand...
Click to collapse
Thanks Chris!
Sent from my SPH-D700 using xda premium
Hope your not doing this because you plan on leaving ! D;
But once again thanks for the info ill read it daily to make sure I understand it all!
Sent from my SPH-D700
I don't plan on going anywhere... but I also don't plan on being the only one repacking kernels forever either =]
chris41g said:
that will be one of the upcoming topics..
Click to expand...
Click to collapse
Awesome
chris41g said:
I don't plan on going anywhere... but I also don't plan on being the only one repacking kernels forever either =]
Click to expand...
Click to collapse
Hopefully soon we won't have to repack them, just recompile
Okay, I worked a bit on something to add a little more options to init.d scripts for my ROM's. I came up with the below solution and thought I should share it with whomever would like a bit more options in their own ROM's. This is a first draft so some of things can properly be done in other ways, but it works and it does add a lot more options when building startup scripts while it is compatible with regular init.d scripts as well. But fell free to pitch in with ideas if you like.
Note that this thread is directed to ROM cookers, but can be used by anyone that knows how to edit ramdisk's.
So there are several problems with the regular init.d methods. First of all there are two different ways of executing the scripts and it differs from ROM to ROM which method has been implemented. We have the "exec /system/bin/sysinit" which will execute all of the scripts before continuing with the normal boot and we have the service sysinit which will execute all scripts while the normal boot is running. Both are useful for different things but no ROM has both.
Also init.d will just start executing the scripts before/during the normal boot, depended on the method, but what if we need it to execute something at a specific time during boot. Before folder structures and such are created in /data? Or when the phone has completely booted into the GUI. Or before the phone is turned off and so on.
This method will implement different states where different parts of a script can be executed depended on where in the boot process we are. All it requires is a more extended sysinit file and a couple of extra lines in the init.rc file.
File: /init.rc
Code:
on early-init
##
# Whatever goes here
##
on init
##
# Whatever goes here
##
on fs
##
# Mount /system
##
# Make sure that we have the synlinks we need to use sysinit
symlink /system/bin/sysinit /system/bin/sysinit.onstart
symlink /system/bin/sysinit /system/bin/sysinit.onfs
symlink /system/bin/sysinit /system/bin/sysinit.onpostfs
symlink /system/bin/sysinit /system/bin/sysinit.onpostfsdata
symlink /system/bin/sysinit /system/bin/sysinit.onboot
symlink /system/bin/sysinit /system/bin/sysinit.onsysinit
symlink /system/bin/sysinit /system/bin/sysinit.onfinalize
symlink /system/bin/sysinit /system/bin/sysinit.oncomplete
symlink /system/bin/sysinit /system/bin/sysinit.onshutdown
exec /system/bin/sysinit.onstart
##
# Mount the rest of the partitions and remount /system without write permissions
##
exec /system/bin/sysinit.onfs
on post-fs
##
# Whatever goes here
##
exec /system/bin/sysinit.onpostfs
on post-fs-data
##
# Whatever goes here
##
exec /system/bin/sysinit.onpostfsdata
##
# If you want to include an additional *.rc file, do it here at the end of post-fs-data
##
on boot
##
# Whatever goes here
##
exec /system/bin/sysinit.onboot
start sysinit
##
# Start any other services
##
on property:init.svc.bootanim=stopped
start syscomplete
on property:sys.boot_completed=1
exec /system/bin/sysinit.onfinalize
on property:sys.shutdown.requested=1
exec /system/bin/sysinit.onshutdown
service sysinit /system/bin/sysinit.onsysinit
disabled
oneshot
service syscomplete /system/bin/sysinit.oncomplete
disabled
oneshot
##
# The rest of the file
##
File: /system/bin/sysinit
Code:
#!/system/bin/sh
export PATH=/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
if [ -d /system/etc/init.d ]; then
case $(basename $0) in
"sysinit") INIT_STATE="$1" ;;
*) INIT_STATE="`basename $0 | cut -d '.' -f2`" ;;
esac
while :
do
if [ ! -f /sysinit.stage.prop ]; then
mount -o remount,rw /
touch /sysinit.stages.prop
mount -o remount,ro /
fi
if ( [ "$INIT_STATE" != "onfinalize" ] && [ "$INIT_STATE" != "oncomplete" ] ) || ( [ "$INIT_STATE" = "onfinalize" ] && [ ! -z "`grep onpostsysinit /sysinit.stages.prop`" ] ) || ( [ "$INIT_STATE" = "oncomplete" ] && [ ! -z "`grep onfinalize /sysinit.stages.prop`" ] ); then
if [ "$INIT_STATE" = "onsysinit" ]; then
RUN_STATES="onsysinit onpostsysinit"; sleep 1
elif [ "$INIT_STATE" = "oncomplete" ]; then
RUN_STATES="onservice oncomplete"
else
RUN_STATES="$INIT_STATE"
fi
for x in $RUN_STATES; do
log -p v -t sysinit "Switching to state '$x'..."
case $x in
# Make it compatible with old init scripts
onboot|"") FILES="`find /system/etc/init.d -type f | sort`" ;;
*) FILES="`find /system/etc/init.d -type f -iname '*.rc' | sort`" ;;
esac
for i in $FILES; do
if [ ! -d $i ] && [ -x $i ]; then
log -p v -t sysinit "Executing $i..."
if [ "$x" = "onservice" ]; then
logwrapper $i $x > /dev/null &
else
logwrapper $i $x
fi
else
log -p w -t sysinit "Skipping $i. Not an executable!"
fi
done
mount -o remount,rw /
echo $x >> /sysinit.stages.prop
mount -o remount,ro /
done
break
fi
sleep 1
done
fi
To use this you need to end the names of your init script with .rc like "55<name>.rc" instead of just "55<name>". This is to keep it compatible with regular init.d scripts.
This will allow you to build init.d scripts like this
Code:
#!/system/bin/sh
case $1 in
onstart)
# Do something right after the system partition has been mounted RW (No other partitions at this time)
;;
onfs)
# Do something right after the rest of partitions has been mounted and system has been remounted RO, before any of them are used or changed in any way.
;;
onpostfs)
# This is almost the same as onfs, only minor changes has normally been made here
;;
onpostfsdata)
# Do something after the /data partition has been rebuild with folders, permission, ownership and so on
;;
onboot)
# Do something right before Android starts booting and it's services are triggered
;;
onsysinit)
# Do something while Android is booting. This will NOT stall the boot process but run along side it
;;
onpostsysinit)
# Do something as soon as onsysinit has finished
;;
onfinalize)
# Do something when the system is almost booted, this also includes the sysinit parts above
;;
onservice)
# Do some constant work in the background (Service/Daemon)
;;
oncomplete)
# Do something when the phone is fully booted and the boot animation is gone
;;
onshutdown)
# Do something before the phone is turned off or rebooted
;;
esac
EDIT 1
Added 'onfinalize' which is actually the old oncomplete. The new oncomplete runs as a service like onsysinit and onpostsysinit to ensure that you are able to use things like "sleep" without stalling the system.
Rewrote sysinit, much cleaner now
EDIT 2
Added 'onservice' which can be used to run a constant task in the background after the phone has booted
Great concept and great work
I can see how this would be very handy!
Sent from my PG86100 using Tapatalk 2
looks intresting..Hmmmmm
Genius man. Awesome stuff.
Sent from my SCH-I500 using Tapatalk 2
Awesome great work. The last line say do comething before the phone is turned off or rebooted. is it suppose to say something.
Sent from my HTC Desire CDMA using Tapatalk 2
jayallen1980 said:
Awesome great work. The last line say do comething before the phone is turned off or rebooted. is it suppose to say something.
Sent from my HTC Desire CDMA using Tapatalk 2
Click to expand...
Click to collapse
'something' is correct, have been changed
Some examples would be good
Can you please? (Example of Executing Juwe's RAM script will be nice in all cases)
What if I want to keep init.d folder empty and integrate my scripts inside boot.img? and then execute them inside it?
varun.chitre15 said:
Some examples would be good
Can you please? (Example of Executing Juwe's RAM script will be nice in all cases)
What if I want to keep init.d folder empty and integrate my scripts inside boot.img? and then execute them inside it?
Click to expand...
Click to collapse
Why would you integrate scripts into the boot.img? The point of init.d is to be able to add things to boot without changing the boot.img. If you want to execute things from within the boot.img, then just place your scripts in it (sbin would be a good place) and execute it the same way my example executes /system/bin/sysinit.
And as for examples, it's easy. Just place your code in that section (onboot, onfs etc) where you want the code to be executed. The onboot is the default in process in most ROM's and also where regular init.d scripts is executed in this example.
dk_zero-cool said:
Why would you integrate scripts into the boot.img? The point of init.d is to be able to add things to boot without changing the boot.img. If you want to execute things from within the boot.img, then just place your scripts in it (sbin would be a good place) and execute it the same way my example executes /system/bin/sysinit.
And as for examples, it's easy. Just place your code in that section (onboot, onfs etc) where you want the code to be executed. The onboot is the default in process in most ROM's and also where regular init.d scripts is executed in this example.
Click to expand...
Click to collapse
because the point of this is to start scripts when you want.. there is a few scripts I have that can't be ran until os is loaded, there for making this a great setup for me.
init.d & boot.img runs everything at boot... not after boot.
eugene373 said:
because the point of this is to start scripts when you want.. there is a few scripts I have that can't be ran until os is loaded, there for making this a great setup for me.
init.d & boot.img runs everything at boot... not after boot.
Click to expand...
Click to collapse
The 'oncomplete' runs everything when the system is fully loaded, that's the point of this init.d system, to be able to run scripts in different ways during different stages.
dk_zero-cool said:
The 'oncomplete' runs everything when the system is fully loaded, that's the point of this init.d system, to be able to run scripts in different ways during different stages.
Click to expand...
Click to collapse
yeah I got it..... I've been having one hell of a time starting script until I cam across this...
If it starts like a normal init.d file it hangs the boot process... with this edit I can trigger it to run on bootcomplete with out hanging the service
sorry, I just noticed I quoted you and not the other guy
eugene373 said:
yeah I got it..... I've been having one hell of a time starting script until I cam across this...
If it starts like a normal init.d file it hangs the boot process... with this edit I can trigger it to run on bootcomplete with out hanging the service
sorry, I just noticed I quoted you and not the other guy
Click to expand...
Click to collapse
Yes oncomplete, oninit and onservice will not stall the process, oninit will however stall onfinalize, oncomplete and onservice. onservice will run the script in a seperate process in the background, so that will not even stall the rest of the init.d scripts while executing, making that great for scripts that should keep running, or where you don't know how long they should run.
dk_zero-cool said:
Yes oncomplete, oninit and onservice will not stall the process, oninit will however stall onfinalize, oncomplete and onservice. onservice will run the script in a seperate process in the background, so that will not even stall the rest of the init.d scripts while executing, making that great for scripts that should keep running, or where you don't know how long they should run.
Click to expand...
Click to collapse
Adding this into all my boot.img from now on & I'll be sure to link this thread...
I think this should be the new standard for all Devs, this method is not only a great idea!
But for the End User, there's so much more control over what can / should be done on starting process...
I personally want to thank you for this, as this truely is one of the better methods I've ever seen!!
~Eugene
dk_zero-cool, I'd like to ask you, why you use soft-links and not parameters?
It will remove all
Code:
symlink /system/bin/sysinit /system/bin/sysinit.*
from init.rc and you will not need to use case in sysinit.
Because this whole construction:
Code:
case $(basename $0) in
"sysinit") INIT_STATE="$1" ;;
*) INIT_STATE="`basename $0 | cut -d '.' -f2`" ;;
esac
seems to me like overload.
hashnon said:
dk_zero-cool, I'd like to ask you, why you use soft-links and not parameters?
It will remove all
Code:
symlink /system/bin/sysinit /system/bin/sysinit.*
from init.rc and you will not need to use case in sysinit.
Because this whole construction:
Code:
case $(basename $0) in
"sysinit") INIT_STATE="$1" ;;
*) INIT_STATE="`basename $0 | cut -d '.' -f2`" ;;
esac
seems to me like overload.
Click to expand...
Click to collapse
Because I have had bad experience using arguments along with the exec command, so I try to avoid that. Mostly because I can't remember the issues anymore.
As for overload, this is to small to be noticed, specially when this is only executed a couple of times during startup. If this was to be executed every couple of minute during the phone on state, then sure. But when the phone has booted, sysinit is no longer used.
Pretty neat design. I've found that having to deal with some of the escaping of an exec can be a nightmare too.
In the kernel ramdisk of my Xperia ray, there are two kinds of inits, init.rc and init.semc.rc.
The "on fs" exists in init.semc.rc (where i can see the commands to mount the partitions). In init.rc there's no "on fs" between "on early-fs" and "on post-fs".
So i've put the "on fs"-part in init.semc.rc and the rest of your fabulous work into init.rc. When i look after booting into the /system/bin/ directory i can see all the "sysinit.on........." symlinks. Is that proof that i did everything right so far? Haven't tried any script yet to be honest.
Kaskade said:
In the kernel ramdisk of my Xperia ray, there are two kinds of inits, init.rc and init.semc.rc.
The "on fs" exists in init.semc.rc (where i can see the commands to mount the partitions). In init.rc there's no "on fs" between "on early-fs" and "on post-fs".
So i've put the "on fs"-part in init.semc.rc and the rest of your fabulous work into init.rc. When i look after booting into the /system/bin/ directory i can see all the "sysinit.on........." symlinks. Is that proof that i did everything right so far? Haven't tried any script yet to be honest.
Click to expand...
Click to collapse
Yes some phones have extra init files for onfs. Mostly if they use different file system types. What you did is correct in this case.
You can check the file /sysinit.stages.prop to see if all stages was executed. If one stage is missing from that file, it was not executed.
Deleted.
hi is ths still working in android marshmallow? cant find sysinit file in system/bin/sysinit
Hi,
This is a combination of 3 different methodologies to reduce Android lag due to low entropy.
1. Change wakeup threshold kernel parameters ala KAK.
2. Run rngd ala Seeder but not in intensive feed mode.
3. Remove /dev/random as it's blocking. Link it to non-blocking /dev/urandom. Since /dev/random is blocking and designed to protect us from Quantum alien cryptographers with mathematical certainty and urandom is non blocking pseudo-random device that most apps and OSs are using anyway.
I'm getting some good results on all Android devices I've tried this on.
You can check your results with this tool:
http://play.google.com/store/apps/de...ndentropyavail
You should get consistent values around the maximum 4096 with this mod.
This is the listing of /etc/init.d/00CrossBreeder (Can be run manually too) :
Code:
#!/system/bin/sh
busybox sysctl -w kernel.random.write_wakeup_threshold=4096
busybox sysctl -w kernel.random.read_wakeup_threshold=1333
rm /dev/random && ln /dev/urandom /dev/random
busybox mknod -m 666 /dev/random.fake c 1 8
busybox chown root.root /dev/random.fake
rngd -t 10 -T 1 -s 256 -W 80% -o /dev/random.fake
sleep 2
echo -8 > /proc/$(busybox pgrep rngd)/oom_adj
renice 5 `busybox pidof rngd`
rm /dev/random.fake
Your thoughts and experiences welcome.
Notes:
1. You can put the code in /etc/init.d/00CrossBreeder and make it executable with:
chmod 755 /etc/init.d/00CrossBreeder
This should run on every boot if you have init.d support. You can also run it manually.
2. You'll need to rename the attached rngd.img binary to /system/xbin/rngd and make it executable with:
cp rngd.img /system/xbin/rngd
chmod 755 /system/xbin/rngd
3. You'll need to stop the seeder service and disable auto start ( IMPORTANT as seeder rngd can take high cpu with the link enabled). Though you can run the app to see available entropy.
or flash zip ( update 31/01/13 ) => CrossBreederByMick.zip
CREDITS:
1. Seeder. This rngd binary is from the seeder util. ( http://forum.xda-developers.com/show...php?p=33999592 )
2. KAK ( http://forum.xda-developers.com/show...php?p=12058585 ).
rngd.img.......
http://forum.xda-developers.com/showthread.php?t=2113150
naudmick said:
Hi,
This is a combination of 3 different methodologies to reduce Android lag due to low entropy.
1. Change wakeup threshold kernel parameters ala KAK.
2. Run rngd ala Seeder but not in intensive feed mode.
3. Remove /dev/random as it's blocking. Link it to non-blocking /dev/urandom. Since /dev/random is blocking and designed to protect us from Quantum alien cryptographers with mathematical certainty and urandom is non blocking pseudo-random device that most apps and OSs are using anyway.
I'm getting some good results on all Android devices I've tried this on.
You can check your results with this tool:
http://play.google.com/store/apps/de...ndentropyavail
You should get consistent values around the maximum 4096 with this mod.
This is the listing of /etc/init.d/00CrossBreeder (Can be run manually too) :
Code:
#!/system/bin/sh
busybox sysctl -w kernel.random.write_wakeup_threshold=4096
busybox sysctl -w kernel.random.read_wakeup_threshold=1333
rm /dev/random && ln /dev/urandom /dev/random
busybox mknod -m 666 /dev/random.fake c 1 8
busybox chown root.root /dev/random.fake
rngd -t 30 -T 1 -s 256 -W 80% -o /dev/random.fake
sleep 2
echo -8 > /proc/$(busybox pgrep rngd)/oom_adj
renice 5 `busybox pidof rngd`
rm /dev/random.fake
Your thoughts and experiences welcome.
Notes:
1. You can put the code in /etc/init.d/00CrossBreeder and make it executable with:
chmod 755 /etc/init.d/00CrossBreeder
This should run on every boot if you have init.d support. You can also run it manually.
2. You'll need to rename the attached rngd.img binary to /system/xbin/rngd and make it executable with:
cp rngd.img /system/xbin/rngd
chmod 755 /system/xbin/rngd
3. You'll need to stop the seeder service and disable auto start ( IMPORTANT as seeder rngd can take high cpu with the link enabled). Though you can run the app to see available entropy.
or flash zip ( update 29/01/13 ) => CrossBreederByMick.zip
CREDITS:
1. Seeder. This rngd binary is from the seeder util. ( http://forum.xda-developers.com/show...php?p=33999592 )
2. KAK ( http://forum.xda-developers.com/show...php?p=12058585 ).
Click to expand...
Click to collapse
had this running on flinnys cm10.1 since the morning and so far so good
DuTY09 said:
had this running on flinnys cm10.1 since the morning and so far so good
Click to expand...
Click to collapse
Can you translate it to "human language" ?
Or is it for devs only ?
remusator said:
Can you translate it to "human language" ?
Or is it for devs only ?
Click to expand...
Click to collapse
basically all this does is free up more resources which helps reduce lag well that's what I've gathered anyways I'm probably wrong but I'm not a dev either I just flashed the zip lol
well, just use Seeder. End of story.
btw, are you a leecher or what? kinda same post like the one on this thread by idcrisis .
This yarn is a non-development? If yes what is the Idcrisis with a tweak added!
But said that everyone does not parcour Forum fro!
R: [MOD ICS, GB / 29/01] CrossBreeder (uRandom) for entropy based lag reduction
It feels better and smoother than with seeder only. Running fine on JellyTime 4.2
Inviato dal mio Desire S
What's the difference between this and the version by idcrisis?
What's the difference between this and the version by idcrisis?
Click to expand...
Click to collapse
Script IdCrisis :
init.d => 00CrossBreeder
xbin => haveged
#!/system/bin/sh
busybox sysctl -w kernel.random.write_wakeup_threshold=4096
busybox sysctl -w kernel.random.read_wakeup_threshold=1333
rm /dev/random && ln /dev/urandom /dev/random
if pgrep haveged > /dev/null; then
echo Haveged already running. Not starting another instance.
exit 1
fi
haveged -w 4096
Click to expand...
Click to collapse
Script me :
init.d => 00CrossBreeder + 04ramtweaks + 30sdcardspeedfix + 93zipalign
xbin => rngd
#!/system/bin/sh
busybox sysctl -w kernel.random.write_wakeup_threshold=4096
busybox sysctl -w kernel.random.read_wakeup_threshold=1333
rm /dev/random && ln /dev/urandom /dev/random
busybox mknod -m 666 /dev/random.fake c 1 8
busybox chown root.root /dev/random.fake
rngd -t 10 -T 1 -s 256 -W 80% -o /dev/random.fake
sleep 2
echo -8 > /proc/$(busybox pgrep rngd)/oom_adj
renice 5 `busybox pidof rngd`
rm /dev/random.fake
Click to expand...
Click to collapse
OK... It's not very clear in the OP. What should I do to use this mod? Should I just flash the ZIP? And if yes, how can I find the service and stop it?
Thanks a lot in advance!
So all we need is to flash the crossbreed zip? What about the rngd.img? fastboot flash?
Sorry but, i can't understand @[email protected]
leimrey said:
So all we need is to flash the crossbreed zip? What about the rngd.img? fastboot flash?
Sorry but, i can't understand @[email protected]
Click to expand...
Click to collapse
Yes flash the zip, it's in the OP
Sent from my supercharged :tank:
Just for anyone who hasn't seen it. This was posted by arcee on his G+
https://plus.google.com/115049428938715274412/posts/GWr72W9zmY2
I should've learned by now that sarcasm doesn't translate well on the internet
So to be clear... IMNSHO, the recent entropy pool fad is bull****. The only users of /dev/random are libcrypto (used for cryptographic operations like SSL connections, ssh key generation, and so on), wpa_supplicant/hostapd (to generate WEP/WPA keys while in AP mode), and the libraries that generate random partition IDs when you do an ext2/3/4 format. None of those 3 users are in the path of app execution, so feeding random from urandom does nothing except make random... well... less random
The only conceivable reason some devices may feel faster is because by constantly polling the PRNG, it keeps the device's I/O in constant use (which in turn, depending on device, will make the CPU stick to higher clock frequencies to keep up and/or ramp up the IO scheduler).
Click to expand...
Click to collapse
I'm not hating on the OP or anything, just thought I'd share the info.
dan-fish said:
Just for anyone who hasn't seen it. This was posted by arcee on his G+
https://plus.google.com/115049428938715274412/posts/GWr72W9zmY2
I'm not hating on the OP or anything, just thought I'd share the info.
Click to expand...
Click to collapse
Gosh so happy...
The day my exam ends am gonna post a thread...on all placebo effects and atleast make desire s users smart to not believe in placebo effects...
Entropy bingo just keeps cell at higher frequency thereby making cell feel responsive...
You can achieve same by keeping lower frequency to say 768 or something rather than 245 and upper limit 1200 as always...and voila everythings flying
Gosh entropy, lag reduction, build prop tweaks (setting some values which are not even used post GB still people say set some windows manager event or debug.some value as 1 makes rom feel smoother which ain't even used in code)
I am gonna do that 1st than port some rom...so people are a bit smart rather than live in placebo world
Atleast desire S users for heaven sake are