[KERNEL][3.4.5][4.1.x-4.2.x] andiroxu's Kernel [GOVs][IO SCHEDs][SWAP] - Micromax A110

Hi to all!
Check for new kernel for Micromax A110 device.
Not a long description here.
Major features:
1. abyssplug, dancedance, smartassv2, intellidemand, hyper, ondemandx, lulzactiveq, minmax, pegasuq, wheatley, sakuractive, hotplug, nightmare, dyninteractive, intercative, conservative, hybrid, ondemand, userspace, powersave, lionheart, zzmove, performance CPU governors added.
2. noop, deadline, cfq, sio, bfq, fifo, fiops, row, vr, zen I/O scheduler added.
3. Changed LMK values for internal task manager means more free memory.
4. Changed to smartass2 and sio as default CPU governor and I/O scheduler (4.2.x).
5. Changed to zzmove and sio as default CPU governor and I/O scheduler (4.1.x).
6. NTFS OTG support added.
7. init.d support added.
8. Battery saver and performance MODs added.
9. Compressed with lmza means less size means more performance and less time to boot and more battery juice.
10. Compiled with linaro's latest toolchain.
11. lzo compression enabled.
12. Network/WiFi speed and connectivity improved.
13. Readahead set to 1024 KB.
14. All cores working on loaded with heavy process (hotplugging).
15. vfs reduced to 10 means more battery saving.
16. Camera capture quality improved.
17. Improved Multitasking.
18. Dynamic cache included (Thanks to @faux123).
Credits:
@tri_zet for all help and support.
Bruno Martins for repacker scripts.
@faux123 for dynamic cache.
aquila-dev and Acer for sources here and @khan_frd2002 for making aware of it..
To all my testers.
For More on CPU Governors and I/O schedulers and their performance, visit following thread:
http://forum.xda-developers.com/showthread.php?t=1507204
ROMs (Released) that are using my kernels:
Dark™ NeXuS 4.2.2 http://forum.xda-developers.com/showthread.php?t=2439632
LegoIce™ Project ROM 4.2.2 [LegoIce™ Galaxy S4] http://forum.xda-developers.com/showthread.php?t=2458879
LegoIce™Canvas 4 4.2.1 http://forum.xda-developers.com/showthread.php?t=2463118
Micromax Mega™ ROM 4.2.2 [Aroma] http://forum.xda-developers.com/showthread.php?t=2463987
Rayne™ Rom http://forum.xda-developers.com/showthread.php?t=2463118
BLACK PEARL ROM 4.1.1 http://forum.xda-developers.com/showthread.php?t=2447212
If anyone else want to include in one's ROM, kindly PM me. If anyone found using my kernel in one's ROM will be treated as per xda rules.
Disclaimer:
I or xda is not responsible for any kind of mess you do with your device after flashing this kernel and don't complain any, if done.
My Kernel sources:
https://github.com/ajaybhatia/canvas2-4.2.2
Mod Edit: Downloads removed as this is under investigation. Thanks for your patience.

How to change CPU governors and I/O schedulers
Guys. I created a cputuner script for all devices and not just for MMX. The code is given below. Just copy it in the file and name it cputuner. Run the script using SM. The settings will stick in every reboot.
Code:
#!/system/bin/sh
# CPU Tuner
# by andiroxu [user=934623]@xda 2[/user]013
# Copyright (C) andiroxu
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this program.
# If not, see
busybox clear
busybox mount -o rw,remount rootfs /
busybox mount -o rw,remount /system
if [ ! -d "/sqlite_stmt_journals" ]; then
mkdir /sqlite_stmt_journals
chown 0.0 /sqlite_stmt_journals
chmod 777 /sqlite_stmt_journals
fi
busybox rm -f /system/etc/init.d/01cputuner
busybox touch /system/etc/init.d/01cputuner
busybox chmod -f 777 /system/etc/init.d/01cputuner
busybox chown -f 0.0 /system/etc/init.d/01cputuner
busybox echo ""
busybox echo "============================"
busybox echo "= Please select a governor ="
busybox echo "============================"
busybox echo ""
busybox sleep 1
SERIAL_NO=1
AVAIL_GOVS=(`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors`)
for GOVS in ${AVAIL_GOVS[@]}; do
busybox echo "$SERIAL_NO) $GOVS"
SERIAL_NO=$(($SERIAL_NO+1))
done
SERIAL_NO=$(($SERIAL_NO-1))
busybox echo ""
busybox echo -n "Select which governor you would like to use: [ 1 - $SERIAL_NO ]: "
read CHOICE
INDEX=$(($CHOICE-1))
SELECTED_GOV=${AVAIL_GOVS[${INDEX}]}
busybox echo ""
busybox echo "You selected '$SELECTED_GOV' governor..."
busybox sleep 1
for c in `ls -d /sys/devices/system/cpu/cpu?`; do
if [ -e ${c}/cpufreq/scaling_governor ]; then
busybox chmod -f 644 ${c}/cpufreq/*
busybox echo "${SELECTED_GOV}" >> ${c}/cpufreq/scaling_governor 2>/dev/null
fi 2>/dev/null
done 2>/dev/null
# Making all cores active
for c in `ls -d /sys/devices/system/cpu/cpu?`; do
if [ -e ${c}/online ]; then
busybox chmod -f 644 ${c}/online 2>/dev/null
fi 2>/dev/null
if [ -e ${c}/online ]; then
busybox echo "1" >> ${c}/online 2>/dev/null
fi 2>/dev/null
done 2>/dev/null
busybox echo ""
busybox echo "============================="
busybox echo "= Please select a scheduler ="
busybox echo "============================="
busybox echo ""
busybox sleep 1
SERIAL_NO=1
COUNT=`cat /sys/block/mmcblk0/queue/scheduler | wc -w`
busybox chmod -f 644 /sys/block/mmcblk0/queue/*
while [ $SERIAL_NO -le $COUNT ]; do
busybox echo "$SERIAL_NO) `cat /sys/block/mmcblk0/queue/scheduler | awk '{print $'$SERIAL_NO'}' | cut -d '[' -f 2 | cut -d ']' -f 1 `"
SERIAL_NO=$(($SERIAL_NO+1))
done
busybox echo ""
SERIAL_NO=$(($SERIAL_NO-1))
busybox echo -n "Select which scheduler you would like to use: [ 1 - $SERIAL_NO ]: "
read CHOICE
INDEX=$(($CHOICE))
SELECTED_SCHEDULER=`cat /sys/block/mmcblk0/queue/scheduler | awk '{print $'$INDEX'}' | cut -d '[' -f 2 | cut -d ']' -f 1 `
busybox echo ""
busybox echo "You selected '$SELECTED_SCHEDULER' scheduler..."
busybox sleep 1
m=/sys/block/dm-*
emmc=/sys/block/mmc*
loop=/sys/block/loop*
ram=/sys/block/ram*
zram=/sys/block/zram*
stl=/sys/block/stl*
bml=/sys/block/bml*
mtd=/sys/block/mtd*
for a in $dm $stl $bml $mtd $emmc $loop $ram $zram; do
if [ -e ${a}/queue ]; then
busybox chmod -f 644 ${a}/queue/*
busybox echo "${SELECTED_SCHEDULER}" >> ${a}/queue/scheduler
fi
done
busybox echo ""
busybox echo "============================="
busybox echo "= Please select a max freq ="
busybox echo "============================="
busybox echo ""
busybox sleep 1
SERIAL_NO=1
TRANS_RANGE=(`cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state | awk '{print $1}'`)
for AVAIL_FREQ in ${TRANS_RANGE[@]}; do
busybox echo "$SERIAL_NO) $AVAIL_FREQ KHz"
SERIAL_NO=$(($SERIAL_NO+1))
done
SERIAL_NO=$(($SERIAL_NO-1))
busybox echo ""
busybox echo -n "Select which max freq you would like to use: [ 1 - $SERIAL_NO ]: "
read CHOICE
INDEX=$(($CHOICE-1))
SELECTED_MAX_FREQ=${TRANS_RANGE[${INDEX}]}
busybox echo ""
busybox echo "You selected '$SELECTED_MAX_FREQ' max freq..."
busybox sleep 1
# Setting max frequency on active cores
for c in `ls -d /sys/devices/system/cpu/cpu?`; do
if [ -e ${c}/cpufreq ]; then
busybox chmod -f 644 ${c}/cpufreq/scaling_max_freq
fi
if [ -e ${c}/cpufreq ]; then
busybox echo "${SELECTED_MAX_FREQ}" >> ${c}/cpufreq/scaling_max_freq
fi
done
busybox echo ""
busybox echo "============================="
busybox echo "= Please select a min freq ="
busybox echo "============================="
busybox echo ""
busybox sleep 1
SERIAL_NO=1
TRANS_RANGE=(`cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state | awk '{print $1}'`)
for AVAIL_FREQ in ${TRANS_RANGE[@]}; do
busybox echo "$SERIAL_NO) $AVAIL_FREQ KHz"
SERIAL_NO=$(($SERIAL_NO+1))
done
SERIAL_NO=$(($SERIAL_NO-1))
busybox echo ""
busybox echo -n "Select which min freq you would like to use: [ 1 - $SERIAL_NO ]: "
read CHOICE
INDEX=$(($CHOICE-1))
SELECTED_MIN_FREQ=${TRANS_RANGE[${INDEX}]}
busybox echo ""
busybox echo "You selected '$SELECTED_MIN_FREQ' min freq..."
busybox sleep 1
# Setting min frequency on active cores
for c in `ls -d /sys/devices/system/cpu/cpu?`; do
if [ -e ${c}/cpufreq ]; then
busybox chmod -f 644 ${c}/cpufreq/scaling_min_freq
fi
if [ -e ${c}/cpufreq ]; then
busybox echo "${SELECTED_MIN_FREQ}" >> ${c}/cpufreq/scaling_min_freq
fi
done
busybox sleep 1
busybox echo ""
busybox echo "CPU Tuning has been done!!!"
busybox echo "These values will be stick on boot."
busybox echo ""
busybox echo "THANK YOU!!!"
busybox echo ""
busybox sleep 1
cat >> /system/etc/init.d/01cputuner \${c}/cpufreq/scaling_governor
fi
done
# Making all cores online
for c in \`ls -d /sys/devices/system/cpu/cpu?\`; do
if [ -e \${c}/online ]; then
busybox chmod -f 644 \${c}/online 2>/dev/null
fi 2>/dev/null
if [ -e \${c}/online ]; then
busybox echo "1" >> \${c}/online 2>/dev/null
fi 2>/dev/null
done 2>/dev/null
# Changing to the selected I/O Scheduler
m=/sys/block/dm-*
emmc=/sys/block/mmc*
loop=/sys/block/loop*
ram=/sys/block/ram*
zram=/sys/block/zram*
stl=/sys/block/stl*
bml=/sys/block/bml*
mtd=/sys/block/mtd*
for a in \$dm \$stl \$bml \$mtd \$emmc \$loop \$ram \$zram; do
if [ -e \${a}/queue ]; then
busybox chmod -f 644 \${a}/queue/*
busybox echo "${SELECTED_SCHEDULER}" >> \${a}/queue/scheduler
fi
done
# Changing max frequecy on all cores
for c in \`ls -d /sys/devices/system/cpu/cpu?\`; do
if [ -e \${c}/cpufreq ]; then
busybox chmod -f 644 \${c}/cpufreq/scaling_max_freq
fi
if [ -e \${c}/cpufreq ]; then
busybox echo "${SELECTED_MAX_FREQ}" >> \${c}/cpufreq/scaling_max_freq
fi
done
# Changing min frequecy on all cores
for c in \`ls -d /sys/devices/system/cpu/cpu?\`; do
if [ -e \${c}/cpufreq ]; then
busybox chmod -f 644 \${c}/cpufreq/scaling_min_freq
fi
if [ -e \${c}/cpufreq ]; then
busybox echo "${SELECTED_MIN_FREQ}" >> \${c}/cpufreq/scaling_min_freq
fi
done
EOF
rm -r /sqlite_stmt_journals 2>/dev/null
busybox chown 0.0 /system/etc/init.d/01cputuner
busybox chmod 777 /system/etc/init.d/01cputuner
exit 0
Note: This is 100% genuine work and don't try to reproduce it any way or no one is allowed to use it their ROM with prior permission.
After all I'm a coder and real developer and love coding and this is known to many of you

Now feeling good with mmx a110 coz of talented devs engaged with it :good::good::good:

Reserved 1
Reserved 1

proseray said:
Now feeling good with mmx a110 coz of talented devs engaged with it :good::good::good:
Click to expand...
Click to collapse
Ah you are so quick. I was just making the thread ready and was reserving some post for future use. But never mind I will manage somehow.
Thanks

andiroxu said:
Ah you are so quick. I was just making the thread ready and was reserving some post for future use. But never mind I will manage somehow.
Thanks
Click to expand...
Click to collapse
My Bad Extremely Sry for that

andiroxu said:
Hi to all!
Check for new kernel for Micromax A110 device. No Bugs at all.
Not a long description here.
Major features:
1. Swap support added.
2. init.d support added.
3. interactive and conservative CPU governors added.
4. ondemand and noop as default CPU governor and I/O scheduler.
5. Battery saver and performer.
P.S. No OC added due to fast draining of battery but you will enjoy equal performance as if it would OC.
Working on other governors and schedulers like zzmoove, smartassv2, interactiveX, ondemandX, lulzactive, hotplug, sio, zen, bfq etc.
Credits:
@tri_zet for all help and support.
Bruno Martin for repacker scripts.
Wiko King for sources.
Download as an attachment
Click to expand...
Click to collapse
Kindly add Over clocking feature bro so that we can enable or disable when we need.
Thx in advance.
Sent from my A110 using xda app-developers app

showstopper1 said:
Kindly add Over clocking feature bro so that we can enable or disable when we need.
Thx in advance.
Sent from my A110 using xda app-developers app
Click to expand...
Click to collapse
Alright. Soon. But it will eat your battery.

andiroxu said:
Alright. Soon. But it will eat your battery.
Click to expand...
Click to collapse
and please provide oc till 1.4ghz....and i don't mind if it eats battery....its just the feature every one will use accordingly what they
Sent from my MICROMAX A110 using xda app-developers app

andiroxu said:
Alright. Soon. But it will eat your battery.
Click to expand...
Click to collapse
bro @andiroxu
please try to add overclocking! many of us use that a lot! it really is a ver useful feature after all!
and with battery.. we'll manage..
thanks a lot again for this kernel!

Good work!
Have you added cifs?

Also add native NTFS support for USB OTG for connecting HDD
Hit Thanks If U Like.....
Sent from MMX A110 By XDA App

LFC-YNWA said:
Have you added cifs?
Click to expand...
Click to collapse
No cifs yet.
venu007 said:
Also add native NTFS support for USB OTG for connecting HDD
Hit Thanks If U Like.....
Sent from MMX A110 By XDA App
Click to expand...
Click to collapse
Will try.
Sent from my GT-I9500 using xda app-developers app

Can you give all features that varun chitre gives in her thunderzap kernal
Sent from my Micromax A110 using Tapatalk 4

akashvfx said:
Can you give all features that varun chitre gives in her thunderzap kernal
Sent from my Micromax A110 using Tapatalk 4
Click to expand...
Click to collapse
Why you are comparing each others works? BTW I'm on adding new features and will release new updated kernel soon with OC, NTFS support for OTG, etc.

andiroxu said:
Why you are comparing each others works? BTW I'm on adding new features and will release new updated kernel soon with OC, NTFS support for OTG, etc.
Click to expand...
Click to collapse
Dont forget to add Cifs

Kernel Source?

nolinuxnoparty said:
Kernel Source?
Click to expand...
Click to collapse
Check OP.
Sent from my GT-I9500 using xda app-developers app

LFC-YNWA said:
Dont forget to add Cifs
Click to expand...
Click to collapse
I'm ready with cifs enabled kernel. More features NTFS support for OTG, now interactive as default CPU governor.
More coming soon: other CPU govs and I/O schedulers, OCing.
Sent from my GT-I9500 using xda app-developers app

Edit : deleted
Sent from my A110 using xda app-developers app
---------- Post added at 06:41 PM ---------- Previous post was at 06:32 PM ----------
andiroxu said:
I'm ready with cifs enabled kernel. More features NTFS support for OTG, now interactive as default CPU governor.
More coming soon: other CPU govs and I/O schedulers, OCing.
Sent from my GT-I9500 using xda app-developers app
Click to expand...
Click to collapse
Bro can you upload your sources to guthub and is it possible to build cyanogenmod from your kernel build.
You ve done something very great dont think im asking again n again juz upload your siurces to github which is your modified sourcr used to build this kernel it will be very useful for most of the mt6577 who are missing something in the sources...
Sent from my A110 using xda app-developers app

Related

[BASH SCRIPT][UPDATED] Governor Switch Scripts from the Command Line

UPDATE: Govswitch.sh has received an upgrade and it can now automagically generate an init.local.rc.new which can be used to set a governor on start up. It will also generate the chosen governor specific script and place it in the /system/bin folder. Thank you Duffkitty for the idea!
Original Post:
In the spirit of Open Source, I've written a couple of scripts that I wanted to share with the community. These are meant for advanced users familiar with the *nix command line. I didn't want to buy SetCPU (yes, I'm cheap ) so I decided to automate the process through the Bash shell language. For those interested, I've written a couple of Bash scripts that allow you to switch CPU governors via the command line. One script generates single instance scripts (one per governor) that can be used in conjunction with GScript for single click governor shortcuts. These single instance scripts are also ideal for changing the governor at boot. The other is command line only and prompts the user to choose from the available governors on the system.
I got tired of having to type it all out so I scripted the process. I just wanted to share with everyone else. I'm also planning to write a watch script that changes to the powersave governor automagically if the battery gets low.
I hope someone finds these scripts useful. Please let me know if anyone finds any errors in the scripts.
These scripts are offered under the terms of the GPLv2. Please see:
http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
You must have root to run these. Usage is detailed in the scripts.
Disclaimer:
You use this script at your own risk. There are no warranties or guarantees of functionality or safety implied or stated whatsoever.
If you do not know what this does, please do not use it.
Despite my harsh warning above, I've designed these scripts to be as failsafe as possible so that nothing is written if the user does not want changes or the governor being selected is already in use. I use these scripts all the time and I have tried to make them as user friendly as command line scripts can be.
Unzip the attached zip to your SD Card. It contains:
gpl-2.0.txt
Description: License file.
govscriptgen.sh
Description: This script generates a set of scripts, one per governor to '/sdcard/governors/'. If a governor is not available in the kernel, no script is generated for it. IE: You can't have ondemand on a kernel that only has interactive built in as the only governor. If you do happen to run a governor script for a governor that is not available, it will simply exit with an error message and no changes made.
Example:
Run:
Code:
bash /sdcard/govscriptgen.sh
Then:
Code:
bash /sdcard/governors/ondemand.sh
Code:
## This script is offered free for use and distribution under the terms and conditions
# in accordance with the GPLv2. For more inforation please visit:
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
## Written by Alex Zaballa (8/23/2010) for use on Android OS.
#
## Description: This script is designed to facilitate CPU Governor switching from
# the Bash command line that comes with custom Android ROMs. It reads the governors
# available on the system generates a script per governor.
# This allows user selection and future automation through Bash.
# Running this script with preexisting scripts in the gen_path
# will automatically overwrite the preexisting scripts.
# If you are a Bash editor, rename/backup anything you want to keep.
#
## Usage:
# bash /yourpath/govscriptgen.sh
#
## For root users only.
#
## Disclaimer:
# You use this script at your *own risk*. There are no warranties or guarantees
# of functionality or safety implied or stated whatsoever.
# If you do not know what this does, please do not use it.
##
# User Editable: Change this variable to change the generation path.
# Please use quotes and end slash.
gen_path="/sdcard/governors/"
# What governors are available to us?
gov_list="$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)"
# Create governor script folder if it does not exist.
if [ ! -e "${gen_path}" ]; then
mkdir ${gen_path}
fi
# Main loop
# Loop through the available governors.
for gov in ${gov_list}; do
# Concatenate path + filename.
script_name="${gen_path}${gov}.sh"
# Echo it all to script_name, rinse, repeat.
echo "Generating ${script_name} ..."
echo '## This script is offered free for use and distribution under the terms and conditions' > ${script_name}
echo '# in accordance with the GPLv2. For more inforation please visit:' >> ${script_name}
echo '## http://www.gnu.org/licenses/old-licenses/gpl-2.0.html' >> ${script_name}
echo '#' >> ${script_name}
echo '## Written by Alex Zaballa (8/23/2010) for use on Android OS.' >> ${script_name}
echo '#' >> ${script_name}
echo '## Description: This script is designed to facilitate CPU Governor' >> ${script_name}
echo '# switching from the Bash command line that comes with custom'>> ${script_name}
echo '# Android ROMs. The script name is generated from the available' >> ${script_name}
echo '# governors and when run, updates to the governor for which the script' >> ${script_name}
echo '# is named. If a governor is not available, it will exit safely with an error.' >> ${script_name}
echo '# These scripts can be used with GScript to create governor shortcuts.' >> ${script_name}
echo '#'
echo '## Usage:' >> ${script_name}
echo "# bash ${script_name}" >> ${script_name}
echo '#' >> ${script_name}
echo '## For root users only.' >> ${script_name}
echo '#' >> ${script_name}
echo '## Disclaimer:' >> ${script_name}
echo '# You use this script at your *own risk*. There are no warranties or guarantees' >> ${script_name}
echo '# of functionality or safety implied or stated whatsoever.' >> ${script_name}
echo '# If you do not know what this does, please do not use it.' >> ${script_name}
echo '##' >> ${script_name}
echo "" >> ${script_name}
echo "" >> ${script_name}
echo '# Set governor that the script controls. This was given at generation.' >> ${script_name}
echo -e 'gov='"\042"${gov}"\042" >> ${script_name}
echo '# What is the current system governor?' >> ${script_name}
echo -e current_gov="\042"'$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)'"\042" >> ${script_name}
echo '# What governors are available to us?' >> ${script_name}
echo -e gov_list="\042"'$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)'"\042" >> ${script_name}
echo "" >> ${script_name}
echo '# Failsafe: If the governor we are trying to set to is not available, exit safely.' >> ${script_name}
echo 'if [ "$(echo "${gov_list}" | grep -c "${gov}" )" != "0" ]; then' >> ${script_name}
echo '# Failsafe: If the governor we are trying to set to is already set, write nothing.' >> ${script_name}
echo ' if [ "${gov}" != "${current_gov}" ]; then' >> ${script_name}
echo ' echo "${gov}" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor' >> ${script_name}
echo ' current_gov="$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)"' >> ${script_name}
echo ' echo "Governor changed to:[${current_gov}]"' >> ${script_name}
echo ' else' >> ${script_name}
echo ' echo "Governor already set to:[${current_gov}]"' >> ${script_name}
echo ' echo "No changes made."' >> ${script_name}
echo ' fi' >> ${script_name}
echo 'else' >> ${script_name}
echo ' echo "Error: [${gov}] governor is not available on this kernel. No changes made."' >> ${script_name}
echo 'fi' >> ${script_name}
done
govswitch.sh
Description:
This script is meant for interactive terminal use (IE: use if you are staring at a command line prompt). It prompts the user for governor selection.
Example:
Run:
Code:
bash /sdcard/govswitch.sh
Code:
## This script is offered free for use and distribution under the terms and conditions
# in accordance with the GPLv2. For more inforation please visit:
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
##
## Written by Alex Zaballa (8/23/2010) for use on Android OS.
##
# Description: This script is designed to facilitate CPU Governor switching from
# the Bash command line that comes with custom Android ROMs. It reads the governors
# available on the system and asks the user which they would like to use.
#
## Usage:
# bash /yourpath/govswitch.sh
#
## For root users only.
#
## Disclaimer:
# You use this script at your *own risk*. There are no warranties or guarantees
# of functionality or safety implied or stated whatsoever.
# If you do not know what this does, please do not use it.
##
# No root, no go.
if [ "$(whoami)" != "root" ]; then
echo "ERROR: You do not have sufficient privileges to run this script."
echo "Please re-run with root privileges."
exit 1
fi
# Default paths. Most of these should not change unless AOS does.
gov_path="/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
available_path="/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors"
init_rc_path="/system/etc/init.local.rc"
bash_path="/system/xbin/bash"
# Recursive function to nag user for a sane and expected answer: (Y)(y) or (N)(n).
function yesno {
read -s -n 1 ans
case $ans in
# If the user has made a choice, update system variable and exit function and for loop.
Y|y) if [ "$2" == '/system/etc/init.local.rc' ]; then
# Do no harm. User has final say to replace 'init.local.rc'.
clear
echo "Setting system to rw permissions."
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
# Backup the original init.local.rc file if one does not exist.
if [ ! -e "${init_rc_path}.bak" ]; then
echo "Generating $2.bak"
cat "${init_rc_path}" > "${init_rc_path}.bak"
fi
echo "Generating $2.new"
cat "$2" > "$2.new"
echo "$1" >> "$2.new"
else
echo "$1" > "$2"
echo "[$1] written to:"
echo "$2"
fi
break 2> /dev/null ;;
# If the user wants something else, skip current item listed.
N|n) echo "Not writing [$1]..."
if [ "$2" == '/system/etc/init.local.rc' ]; then
echo "Done."
exit 0
fi ;;
# Garbage answer in; sanity nag out. Recurse.
* ) echo "Please enter:[y/n]"
yesno "$1" "$2";;
esac
}
# What governors are available to us?
gov_list="$(cat "${available_path}")"
# Main Loop
clear
echo "Available governors:[${gov_list}]"
# Failsafe: If all answers are no, we don't change anything.
echo "Answer (n)o to every question to keep current governor."
# Loop through available options.
for gov in ${gov_list}; do
# What is our current governor?
current_gov="$(cat "${gov_path}")"
# Skip question if the current governor and our option is the same.
if [ "${gov}" != "${current_gov}" ]; then
echo "The current governor is:[${current_gov}]"
echo ""
echo "Change to:[${gov}][y/n]?"
yesno "${gov}" "${gov_path}"
fi
done
# Confirm what we've done.
current_gov="$(cat "${gov_path}")"
echo -e "\nThe current governor is:[${current_gov}]"
echo "Do you want to use this governor on startup?"
startup_script="$(echo -e '/system/bin/'"${current_gov}"'.sh')"
init_string="$(echo -e 'service gov_'"${current_gov} ${bash_path} ${startup_script}\n\t\t"'oneshot'"\n\n\n")"
yesno "${init_string}" "${init_rc_path}"
if [ ! -e "${startup_script}" ]; then
# Echo it all to startup_script.
echo "Generating ${startup_script} ..."
echo '## This script is offered free for use and distribution under the terms and conditions' > ${startup_script}
echo '# in accordance with the GPLv2. For more inforation please visit:' >> ${startup_script}
echo '## http://www.gnu.org/licenses/old-licenses/gpl-2.0.html' >> ${startup_script}
echo '#' >> ${startup_script}
echo '## Written by Alex Zaballa (8/23/2010) for use on Android OS.' >> ${startup_script}
echo '#' >> ${startup_script}
echo '## Description: This script is designed to facilitate CPU Governor' >> ${startup_script}
echo '# switching from the Bash command line that comes with custom'>> ${startup_script}
echo '# Android ROMs. The script name is generated from the available' >> ${startup_script}
echo '# governors and when run, updates to the governor for which the script' >> ${startup_script}
echo '# is named. If a governor is not available, it will exit safely with an error.' >> ${startup_script}
echo '# These scripts can be used with GScript to create governor shortcuts.' >> ${startup_script}
echo '#' >> ${startup_script}
echo '## Usage:' >> ${startup_script}
echo "# bash ${startup_script}" >> ${startup_script}
echo '#' >> ${startup_script}
echo '## For root users only.' >> ${startup_script}
echo '#' >> ${startup_script}
echo '## Disclaimer:' >> ${startup_script}
echo '# You use this script at your *own risk*. There are no warranties or guarantees' >> ${startup_script}
echo '# of functionality or safety implied or stated whatsoever.' >> ${startup_script}
echo '# If you do not know what this does, please do not use it.' >> ${startup_script}
echo '##' >> ${startup_script}
echo "" >> ${startup_script}
echo "" >> ${startup_script}
echo '# Set governor that the script controls. This was given at generation.' >> ${startup_script}
echo -e 'gov='"\042"${current_gov}"\042" >> ${startup_script}
echo '# What is the current system governor?' >> ${startup_script}
echo -e 'current_gov='"\042"'$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)'"\042" >> ${startup_script}
echo '# What governors are available to us?' >> ${startup_script}
echo -e 'gov_list='"\042"'$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)'"\042" >> ${startup_script}
echo "" >> ${startup_script}
echo '# Failsafe: If the governor we are trying to set to is not available, exit safely.' >> ${startup_script}
echo 'if [ "$(echo "${gov_list}" | grep -c "${gov}" )" != "0" ]; then' >> ${startup_script}
echo '# Failsafe: If the governor we are trying to set to is already set, write nothing.' >> ${startup_script}
echo ' if [ "${gov}" != "${current_gov}" ]; then' >> ${startup_script}
echo ' echo "${gov}" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor' >> ${startup_script}
echo ' current_gov="$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)"' >> ${startup_script}
echo ' echo "Governor changed to:[${current_gov}]"' >> ${startup_script}
echo ' else' >> ${startup_script}
echo ' echo "Governor already set to:[${current_gov}]"' >> ${startup_script}
echo ' echo "No changes made."' >> ${startup_script}
echo ' fi' >> ${startup_script}
echo 'else' >> ${startup_script}
echo ' echo "Error: [${gov}] governor is not available on this kernel. No changes made."' >> ${startup_script}
echo 'fi' >> ${startup_script}
fi
echo ""
echo "***"
echo "WARNING:"
echo "CHECK init.local.rc.new for correctness"
echo "BEFORE overwriting the original."
echo "***"
echo "If you need a backup of the original,"
echo "init.local.rc.bak was created at runtime."
echo "Run the following or similar command"
echo "to overwrite init.local.rc in /system/etc/:"
echo ""
echo "cat init.local.rc.bak > init.local.rc"
Thanks downloading now.
duffkitty said:
Thanks downloading now.
Click to expand...
Click to collapse
Please let me know if you have any questions.
At first I got a yesno error but ran it with sh and not bash.
Working but I can't figure out gscript it sends out stderr's. I have the lite so dunno.
I'm guessing to start at boot I would need to edit a bit =P
Sent from my CM 6 Blackmodded Heroc using the XDA app. Now with uncapped kernel and battery tweaks.
duffkitty said:
At first I got a yesno error but ran it with sh and not bash.
Working but I can't figure out gscript it sends out stderr's. I have the lite so dunno.
I'm guessing to start at boot I would need to edit a bit =P
Sent from my CM 6 Blackmodded Heroc using the XDA app. Now with uncapped kernel and battery tweaks.
Click to expand...
Click to collapse
I found this for running scripts at boot. It's a good place to start.
http://forum.xda-developers.com/showthread.php?t=690564&page=2
govscriptgen.sh
This script generates a set of scripts, one per governor. It's those scripts you would want to use at boot or in gscript. If you didn't change the location, and assuming that you could write to your SD Card, they should be located in '/sdcard/governors'. There will be one per available governor (this is dictated by the kernel configuration).
In GScript do the following:
1. Open GScript Lite.
2. Menu > Add Script
3. Name the script. Let's say Ondemand.
4. Check 'Needs SU?'
5. In the text box type (without quotes), 'bash /sdcard/governors/ondemand.sh'
6. Create a shortcut to that script and it will set the governor it is named for.
govswitch.sh
This one is for use in a terminal and prompts the user for the desired governor.
I think I figured out and was gonna post it but you already did thanks. I appreciate it.
Sent from my CM 6 Blackmodded Heroc using the XDA app. Now with uncapped kernel and battery tweaks.
Added interactive.sh to /system/bin and fixed the permissions but I added
service gov_interactive /system/bin/interactive.sh
oneshot
To init.local.rc and it doesn't start... I can run it in terminal emulator with just interactive.sh though....
Sent from my CM 6 Blackmodded Heroc using the XDA app. Now with uncapped kernel and battery tweaks.
duffkitty said:
Added interactive.sh to /system/bin and fixed the permissions but I added
service gov_interactive /system/bin/interactive.sh
oneshot
To init.local.rc and it doesn't start... I can run it in terminal emulator with just interactive.sh though....
Sent from my CM 6 Blackmodded Heroc using the XDA app. Now with uncapped kernel and battery tweaks.
Click to expand...
Click to collapse
I think it needs the interpreter in front of it. Could you try the following?
Code:
service gov_interactive /system/xbin/bash /system/bin/interactive.sh
zansatsu said:
I think it needs the interpreter in front of it. Could you try the following?
Code:
service gov_interactive /system/xbin/bash /system/bin/interactive.sh
Click to expand...
Click to collapse
That does it. I guess it doesn't automagically know it's bash =P
Sent from my CM 6 Blackmodded Heroc using the XDA app. Now with uncapped kernel and battery tweaks.
duffkitty said:
That does it. I guess it doesn't automagically know it's bash =P
Click to expand...
Click to collapse
I'm glad it worked. Yeah, Android's command line fought me most of the way until I learned to just call bash before running any scripts. I suspect it's probably because the command line on Android initializes in a relatively 'bare' state as compared to all of Linux's bells and whistles that I'm used to.
Let me know if you have any more questions.
zansatsu said:
I'm glad it worked. Yeah, Android's command line fought me most of the way until I learned to just call bash before running any scripts. I suspect it's probably because the command line on Android initializes in a relatively 'bare' state as compared to all of Linux's bells and whistles that I'm used to.
Let me know if you have any more questions.
Click to expand...
Click to collapse
Thanks for helping =) I wonder if its possible to add bsd style init scripts. I guess you don't actually need to change many services but an rc.conf file would be cool =P
Sent from my CM 6 Blackmodded Heroc using the XDA app. Now with uncapped kernel and battery tweaks.
duffkitty said:
Thanks for helping =) I wonder if its possible to add bsd style init scripts. I guess you don't actually need to change many services but an rc.conf file would be cool =P
Sent from my CM 6 Blackmodded Heroc using the XDA app. Now with uncapped kernel and battery tweaks.
Click to expand...
Click to collapse
I started on Slackware and a '/etc/rc.d/rc.local' file would be really awesome. Slackware being one of the oldest distros (if not the oldest) is very similar to BSD. I've had to configure Slack many times, but once you did it was rock-solid.
Android feels more like Ubuntu in some ways and Red Hat in others, but a very slim version of either. I can't really explain it.
Anywho. Glad I could help.
Code:
## This script is offered free for use and distribution under the terms and conditions
# in accordance with the GPLv2. For more inforation please visit:
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
## Written by Alex Zaballa (9/23/2010) for use on Android OS.
#
Click to expand...
Click to collapse
How did you write this script one month in the future?
Seriously....would this script be able to change kernel voltage from command line? Say changing from undervolted to regular voltage for certain tasks (like GPS nav for example), then switch back to undervolt for other usage? Is something like that even possible? I've seen a few others ask about something like that in other threads.
chromiumleaf said:
How did you write this script one month in the future?
Click to expand...
Click to collapse
I'm just that ahead of my time! ROFL
DOH!
I corrected and reposted the zip file.
chromiumleaf said:
Seriously....would this script be able to change kernel voltage from command line? Say changing from undervolted to regular voltage for certain tasks (like GPS nav for example), then switch back to undervolt for other usage? Is something like that even possible? I've seen a few others ask about something like that in other threads.
Click to expand...
Click to collapse
If there is a command line associated with it, I can write a script that can easily handle it. I haven't looked into the specifics on changing voltages...
TBH: That thought scares the bejeezuz out of me.
zansatsu said:
If there is a command line associated with it, I can write a script that can easily handle it. I haven't looked into the specifics on changing voltages...
TBH: That thought scares the bejeezuz out of me.
Click to expand...
Click to collapse
Check out this thread for some of the initial dev conversations on undervolting: http://forum.xda-developers.com/showthread.php?t=697286 Ironically, I think some of it started from the guy who dev'd setcpu. Might have some info in it that could help you figure some things out. I'd try to sum it up for you but that stuff is just a bit over my head
Decad3nce said:
Code:
/* MSM7201A Levels 3-6 all correspond to 1.2V, level 7 corresponds to 1.325V. */
enum {
VDD_0 = 0,
VDD_1 = 1,
VDD_2 = 2,
VDD_3 = 3,
VDD_4 = 4,
VDD_5 = 5,
VDD_6 = 6,
VDD_7 = 7,
VDD_END
};
Thanks to kleranc for idea.
Click to expand...
Click to collapse
These are kernel level calls that have to be compiled into the kernel. Unless they make this available as a system variable, like the governors are, I don't think changing the voltage from the command line is possible... or even safe. The governors are routines written to control different CPU modes of operation and are designed to be fairly safe to use in instances of power management. Adjusting the voltages from the command line would prove to be too close to suicidal because Bash can't operate at the speeds necessary to monitor voltage fluctations.
Example: We hit a voltage spike, which needs to be corrected in nanoseconds (billionth of a second), Bash would brick the phone by not responding until at least 50 milliseconds (thousandth of a second) later, if ever.
Now if they had modules written that the kernel had different voltage 'modes' and built-in safeties, then I wouldn't have a problem manipulating them from the command line. As it stands, I'll leave it to people who think in ARM Assembler, C, and C++. lol
However, I am taking script ideas, so feel free to suggest anything else you might think is useful.
No Hero gets left behind!
Sent from my FROYO HERO.
Govswitch.sh has received an upgrade and it can now automagically generate an init.local.rc.new which can be used to set a governor on start up. It will also generate the chosen governor specific script and place it in the /system/bin folder. Thank you Duffkitty for the idea!
zansatsu said:
Govswitch.sh has received an upgrade and it can now automagically generate an init.local.rc.new which can be used to set a governor on start up. It will also generate the chosen governor specific script and place it in the /system/bin folder. Thank you Duffkitty for the idea!
Click to expand...
Click to collapse
Awesome I'm not longer using CM for a daily and switched to Zen-ROM but may go back when a release happens. Niche audience for the script but its very helpful
Sent from my HTC Hero using XDA App

My init.d Script for CFQ scheduler.

Hi guys,
I used system tuner to create a script on set CFQ as default scheduler (as recommend for sense 4)
It does work however, looking at the file it looks over complicated and seems to repeat commands.
Can you guys have a look and see if it can be tidied up?
Feel fee to use this if it's something you need
#!/system/bin/sh
chmod 777 /sys/block/mmcblk0/queue/scheduler
echo "cfq" > /sys/block/mmcblk0/queue/scheduler
chmod 777 /sys/block/mmcblk1/queue/scheduler
echo "cfq" > /sys/block/mmcblk1/queue/scheduler
chmod 777 /sys/block/mmcblk1/queue/scheduler
echo "cfq" > /sys/block/mmcblk1/queue/scheduler
if [ ! -e /sys/block/mmcblk0/queue/scheduler]
then
sleep 60
fi
chmod 777 /sys/block/mmcblk0/queue/scheduler
echo "cfq" > /sys/block/mmcblk0/queue/scheduler
chmod 777 /sys/block/mmcblk1/queue/scheduler
echo "cfq" > /sys/block/mmcblk1/queue/scheduler
chmod 777 /sys/block/mmcblk1/queue/scheduler
echo "cfq" > /sys/block/mmcblk1/queue/scheduler
Sent from my SuperSensation.
ViperS ROM 1.0.1.
SebastianFM Overclocked Kernel v1.5
D-SHEL Undervoltage mod.
Turns out you only need first echo line.
Sent from my SuperSensation.
ViperS ROM 1.0.1.
SebastianFM Overclocked Kernel v1.5
D-SHEL Undervoltage mod.

[TWEAK] Faux123 Kernel Tweaks

Hi,
For those of you who aren't using Faux123 Application for tweaking the kernel, I have made a init.d file for them. Just flash the zip and you will have the same tweaks (battery saver only).
Following are included:
CPU Control
Min clock - 162 MHz
Max clock - 1.7 GHz
CPU Governor - Intellidemand
mpdecision - Off
Eco Mode - On
Intellidemand gov control
Up Threshold - 75
Boost Frequency - 0
Two Phase Freq - 1350000
Sampling Rate - 50000
Optimal Freq - 1566000
Synchro Freq - 702000
GPU Control
GPU Governor - ondemand
GPU Clock - 320Mhz
GPU Vsync - On
I/O Scheduler Control
I/O Scheduler (eMMC) - FIOPS
Readhead Size (eMMC) - 1024
**************** Use Faux123 Application if you want to use the true power of this mighty kernel.
************************All credits goes to Faux123 and his mighty kernel*****************************
theintelligent said:
Hi,
For those of you who aren't using Faux123 Application for tweaking the kernel, I have made a init.d file for them. Just flash the zip and you will have the same tweaks (battery saver only).
Following are included:
CPU Control
Min clock - 162 MHz
Max clock - 1.7 GHz
CPU Governor - Intellidemand
mpdecision - Off
Eco Mode - On
Intellidemand gov control
Up Threshold - 75
Boost Frequency - 0
Two Phase Freq - 1350000
Sampling Rate - 50000
Optimal Freq - 1566000
Synchro Freq - 702000
GPU Control
GPU Governor - ondemand
GPU Clock - 320Mhz
GPU Vsync - On
I/O Scheduler Control
I/O Scheduler (eMMC) - FIOPS
Readhead Size (eMMC) - 1024
**************** Use Faux123 Application if you want to use the true power of this mighty kernel.
************************All credits goes to Faux123 and his mighty kernel*****************************
Click to expand...
Click to collapse
thanks! this is great. Can you also add snake charmer=on?
As per my findings, snake charmer is Faux's application thingy. But I will definitely take a look.
Has established, but my options which were before application Faux123 Kernel Tweaks have not changed.
Glad to see you here!!
Thanks
The app costs $4.99, which is kind of pricy.
Sent from my HTC One using xda app-developers app
dont think his going to be very happy when he sees this lol
Heh $4.99 is nothing for what our devs do for us
Sent from my HTC One using xda premium
i personally bought all of his apps even though i don't use them all, devs need support, threads like are kind of inappropriate and unfair.
chiho0516 said:
The app costs $4.99, which is kind of pricy.
Sent from my HTC One using xda app-developers app
Click to expand...
Click to collapse
riiiiiiiight
kennynguyen20 said:
i personally bought all of his apps even though i don't use them all, devs need support, threads like are kind of inappropriate and unfair.
Click to expand...
Click to collapse
Excuse me? In what way? Have you even looked at the file? There's absolutely nothing in there that anyone fooling around with their own init.d file couldn't have done. There is no custom code written in there by faux that someone else couldn't independently have written. Should he be credited for it? Absolutely. Is he owed any compensation for this? I really don't think so. Those who want to contribute (and make no mistake, his kernel is pretty great) can do so by purchasing his app or donating to him.
Take a look for yourself before jumping to conclusions:
Code:
#!/system/bin/sh
#
#
IO_SCH="fiops"
READ_AHEAD_KB="1024"
CURRENT_GOVERNOR="intellidemand"
MIN_FREQ="162000"
MAX_FREQ="1728000"
echo "Setting and Tweaking $IO_SCH I/O Scheduler"
STL=`ls -d /sys/block/stl*`
BML=`ls -d /sys/block/bml*`
MMC=`ls -d /sys/block/mmc*`
for i in $STL $BML $MMC $TFSR; do
echo $IO_SCH > $i/queue/scheduler
echo 0 > $i/queue/rotational
echo 1 > $i/queue/iosched/low_latency
echo 1 > $i/queue/iosched/back_seek_penalty
echo 1000000000 > $i/queue/iosched/back_seek_max
echo 1 > $i/queue/iosched/slice_idle
echo 8 > $i/queue/iosched/quantum
echo 1024 > $i/queue/nr_requests
echo 0 > $i/queue/iostats
echo 4 > $i/queue/iosched/fifo_batch
echo 2 > $i/queue/iosched/writes_starved
echo 1 > $i/queue/iosched/rev_penalty
echo 1 > $i/queue/rq_affinity;
done
echo "Optimizing Read Ahead"
VD=`ls -d /sys/devices/virtual/bdi/*`
for i in $VD; do
echo $READ_AHEAD_KB > $i/read_ahead_kb;
echo "Read ahead kb SET to $READ_AHEAD_KB";
done
echo "Stopping MPDECISION"
stop mpdecision
sleep 1
if [ -e /sys/module/intelli_plug/parameters/intelli_plug_active ]; then
echo "Activating IntelliPlug"
echo "1" /sys/module/intelli_plug/parameters/intelli_plug_active;
fi;
sleep 1
if [ -e /sys/module/intelli_plug/parameters/eco_mode_active ]; then
echo "Enabling ECO mode"
echo "1" > /sys/module/intelli_plug/parameters/eco_mode_active;
fi;
sleep 3
echo "Setting governor as $CURRENT_GOVERNOR"
chmod 0777 /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo $CURRENT_GOVERNOR > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo $CURRENT_GOVERNOR > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
echo $CURRENT_GOVERNOR > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
echo $CURRENT_GOVERNOR > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor
chmod 0644 /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
sleep 2
echo "Setting minfreq=$MIN_FREQ and maxfreq=$MAX_FREQ"
chmod 0777 /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo $MIN_FREQ > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
chmod 0644 /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
chmod 0777 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo $MAX_FREQ > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
chmod 0644 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
sleep 2
if [ $CURRENT_GOVERNOR == "intellidemand" ]; then
echo "Optimizing $CURRENT_GOVERNOR governor"
chmod 0777 /sys/devices/system/cpu/cpufreq/intellidemand/up_threshold
echo "75" > /sys/devices/system/cpu/cpufreq/intellidemand/up_threshold
chmod 0644 /sys/devices/system/cpu/cpufreq/intellidemand/up_threshold
chmod 0777 /sys/devices/system/cpu/cpufreq/intellidemand/boostfreq
echo "0" > /sys/devices/system/cpu/cpufreq/intellidemand/boostfreq
chmod 0644 /sys/devices/system/cpu/cpufreq/intellidemand/boostfreq
chmod 0777 /sys/devices/system/cpu/cpufreq/intellidemand/two_phase_freq
echo "1350000" > /sys/devices/system/cpu/cpufreq/intellidemand/two_phase_freq
chmod 0644 /sys/devices/system/cpu/cpufreq/intellidemand/two_phase_freq
chmod 0777 /sys/devices/system/cpu/cpufreq/intellidemand/sampling_rate
echo "50000" > /sys/devices/system/cpu/cpufreq/intellidemand/sampling_rate
chmod 0644 /sys/devices/system/cpu/cpufreq/intellidemand/sampling_rate
chmod 0777 /sys/devices/system/cpu/cpufreq/intellidemand/optimal_freq
echo "1566000" > /sys/devices/system/cpu/cpufreq/intellidemand/optimal_freq
chmod 0644 /sys/devices/system/cpu/cpufreq/intellidemand/optimal_freq
chmod 0777 /sys/devices/system/cpu/cpufreq/intellidemand/sync_freq
echo "702000" > /sys/devices/system/cpu/cpufreq/intellidemand/sync_freq
chmod 0644 /sys/devices/system/cpu/cpufreq/intellidemand/sync_freq
fi;
sleep 2
echo "Optimizing GPU"
MIN_GPU_CLK="320000000"
GPU_GOV="ondemand"
if [ -e /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0 ]; then
echo "Setting GPU Governor=$GPU_GOV @ $MIN_GPU_CLK"
chmod 0777 /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/gpuclk
echo $MIN_GPU_CLK > /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/gpuclk
chmod 0644 /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/gpuclk
chmod 0777 /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/pwrscale/trustzone/governor
echo $GPU_GOV > /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/pwrscale/trustzone/governor
chmod 0644 /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/pwrscale/trustzone/governor
fi;
sleep 1
if [ -e /d/clk/mdp_vsync_clk/ ]; then
echo "Enabling GPU VSync"
chmod 0777 /d/clk/mdp_vsync_clk/enable
echo "1" > /d/clk/mdp_vsync_clk/enable
chmod 0644 /d/clk/mdp_vsync_clk/enable
fi;
LiquidSolstice said:
Excuse me? In what way? Have you even looked at the file? There's absolutely nothing in there that anyone fooling around with their own init.d file couldn't have done. There is no custom code written in there by faux that someone else couldn't independently have written. Should he be credited for it? Absolutely. Is he owed any compensation for this? I really don't think so. Those who want to contribute (and make no mistake, his kernel is pretty great) can do so by purchasing his app or donating to him.
Take a look for yourself before jumping to conclusions:
Code:
#!/system/bin/sh
#
#
IO_SCH="fiops"
READ_AHEAD_KB="1024"
CURRENT_GOVERNOR="intellidemand"
MIN_FREQ="162000"
MAX_FREQ="1728000"
echo "Setting and Tweaking $IO_SCH I/O Scheduler"
STL=`ls -d /sys/block/stl*`
BML=`ls -d /sys/block/bml*`
MMC=`ls -d /sys/block/mmc*`
for i in $STL $BML $MMC $TFSR; do
echo $IO_SCH > $i/queue/scheduler
echo 0 > $i/queue/rotational
echo 1 > $i/queue/iosched/low_latency
echo 1 > $i/queue/iosched/back_seek_penalty
echo 1000000000 > $i/queue/iosched/back_seek_max
echo 1 > $i/queue/iosched/slice_idle
echo 8 > $i/queue/iosched/quantum
echo 1024 > $i/queue/nr_requests
echo 0 > $i/queue/iostats
echo 4 > $i/queue/iosched/fifo_batch
echo 2 > $i/queue/iosched/writes_starved
echo 1 > $i/queue/iosched/rev_penalty
echo 1 > $i/queue/rq_affinity;
done
echo "Optimizing Read Ahead"
VD=`ls -d /sys/devices/virtual/bdi/*`
for i in $VD; do
echo $READ_AHEAD_KB > $i/read_ahead_kb;
echo "Read ahead kb SET to $READ_AHEAD_KB";
done
echo "Stopping MPDECISION"
stop mpdecision
sleep 1
if [ -e /sys/module/intelli_plug/parameters/intelli_plug_active ]; then
echo "Activating IntelliPlug"
echo "1" /sys/module/intelli_plug/parameters/intelli_plug_active;
fi;
sleep 1
if [ -e /sys/module/intelli_plug/parameters/eco_mode_active ]; then
echo "Enabling ECO mode"
echo "1" > /sys/module/intelli_plug/parameters/eco_mode_active;
fi;
sleep 3
echo "Setting governor as $CURRENT_GOVERNOR"
chmod 0777 /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo $CURRENT_GOVERNOR > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo $CURRENT_GOVERNOR > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
echo $CURRENT_GOVERNOR > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
echo $CURRENT_GOVERNOR > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor
chmod 0644 /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
sleep 2
echo "Setting minfreq=$MIN_FREQ and maxfreq=$MAX_FREQ"
chmod 0777 /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo $MIN_FREQ > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
chmod 0644 /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
chmod 0777 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo $MAX_FREQ > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
chmod 0644 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
sleep 2
if [ $CURRENT_GOVERNOR == "intellidemand" ]; then
echo "Optimizing $CURRENT_GOVERNOR governor"
chmod 0777 /sys/devices/system/cpu/cpufreq/intellidemand/up_threshold
echo "75" > /sys/devices/system/cpu/cpufreq/intellidemand/up_threshold
chmod 0644 /sys/devices/system/cpu/cpufreq/intellidemand/up_threshold
chmod 0777 /sys/devices/system/cpu/cpufreq/intellidemand/boostfreq
echo "0" > /sys/devices/system/cpu/cpufreq/intellidemand/boostfreq
chmod 0644 /sys/devices/system/cpu/cpufreq/intellidemand/boostfreq
chmod 0777 /sys/devices/system/cpu/cpufreq/intellidemand/two_phase_freq
echo "1350000" > /sys/devices/system/cpu/cpufreq/intellidemand/two_phase_freq
chmod 0644 /sys/devices/system/cpu/cpufreq/intellidemand/two_phase_freq
chmod 0777 /sys/devices/system/cpu/cpufreq/intellidemand/sampling_rate
echo "50000" > /sys/devices/system/cpu/cpufreq/intellidemand/sampling_rate
chmod 0644 /sys/devices/system/cpu/cpufreq/intellidemand/sampling_rate
chmod 0777 /sys/devices/system/cpu/cpufreq/intellidemand/optimal_freq
echo "1566000" > /sys/devices/system/cpu/cpufreq/intellidemand/optimal_freq
chmod 0644 /sys/devices/system/cpu/cpufreq/intellidemand/optimal_freq
chmod 0777 /sys/devices/system/cpu/cpufreq/intellidemand/sync_freq
echo "702000" > /sys/devices/system/cpu/cpufreq/intellidemand/sync_freq
chmod 0644 /sys/devices/system/cpu/cpufreq/intellidemand/sync_freq
fi;
sleep 2
echo "Optimizing GPU"
MIN_GPU_CLK="320000000"
GPU_GOV="ondemand"
if [ -e /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0 ]; then
echo "Setting GPU Governor=$GPU_GOV @ $MIN_GPU_CLK"
chmod 0777 /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/gpuclk
echo $MIN_GPU_CLK > /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/gpuclk
chmod 0644 /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/gpuclk
chmod 0777 /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/pwrscale/trustzone/governor
echo $GPU_GOV > /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/pwrscale/trustzone/governor
chmod 0644 /sys/devices/platform/kgsl-3d0.0/kgsl/kgsl-3d0/pwrscale/trustzone/governor
fi;
sleep 1
if [ -e /d/clk/mdp_vsync_clk/ ]; then
echo "Enabling GPU VSync"
chmod 0777 /d/clk/mdp_vsync_clk/enable
echo "1" > /d/clk/mdp_vsync_clk/enable
chmod 0644 /d/clk/mdp_vsync_clk/enable
fi;
Click to expand...
Click to collapse
Friends these tweaks are all over the XDA forums including the Faux's kernel threads. I have only consolidated them. Btw I myself own Faux applications and they are great, of course.
This is not a place to fight rather it's a place to share knowledge. So calm down.
kennynguyen20 said:
i personally bought all of his apps even though i don't use them all, devs need support, threads like are kind of inappropriate and unfair.
Click to expand...
Click to collapse
come on dude !!! he has just gathered his settings into a zip file and just made it easier for users to simply flash it n apply the settings he is using...there is no harm to the dev's hard work behind his kernel n app !!!
dhingra_vinay_in said:
come on dude !!! he has just gathered his settings into a zip file and just made it easier for users to simply flash it n apply the settings he is using...there is no harm to the dev's hard work behind his kernel n app !!!
Click to expand...
Click to collapse
i just thought it might be better if he post the setting as a reply in faux's kernel thread instead of making a new one. Well, just my opinion
kennynguyen20 said:
i personally bought all of his apps even though i don't use them all, devs need support, threads like are kind of inappropriate and unfair.
Click to expand...
Click to collapse
kennynguyen20 said:
i just thought it might be better if he post the setting as a reply in faux's kernel thread instead of making a new one. Well, just my opinion
Click to expand...
Click to collapse
respect ur opinion but there are many noobs who just dont know how to edit the init.d script...
dhingra_vinay_in said:
respect ur opinion but there are many noobs who just dont know how to edit the init.d script...
Click to expand...
Click to collapse
i personally dont know how to edit init.d script as well so i bought his app, there are so much you can do.
kennynguyen20 said:
i just thought it might be better if he post the setting as a reply in faux's kernel thread instead of making a new one. Well, just my opinion
Click to expand...
Click to collapse
Well friend, you are right I thought of posting my init.d to that thread but I am not sure why I posted a new thread (there was a some reason, I forgot). Anyways I will post a link referring to this thread.
EDIT:
Posted
http://forum.xda-developers.com/showpost.php?p=42010742&postcount=1379

[SCRIPT][UPDATED 03.26.14] Fix Lag, Defrag/Free Memory with |=>TrimDropOff<=|

Updated 03.26.14 - Released v2.1 - bug fixes and code cleaned
Introduction:
I am by no means a developer. I am just an android enthusiast who has learned a bit of bash. The reason I made this script was that settings>>wifi>>advanced was not promptly turning wifi off when my device would sleep; sometimes it would not turn off at all. So I figured since I am making a script to resolve this issue I might as well add a couple of other functions as well. To this end I noticed some people saying THIS APP was helpful and I missed the Flush-O-Matic script from V6 SuperCharger so I added fstrim and drop_caches=3 to the script.
Click to expand...
Click to collapse
What will this do?
The script will allow you to sync wifi, fstrim, and/or drop_caches=3 with sleep and/or it will allow you to schedule fstrim and/or drop_caches=3 using crond. The scheduling option can work on either a hourly (you can choose to run desired programs every hour on the hour, every two hours on the hour, every 3 hours on the hour, etc) or daily basis (you can choose to run desired programs at a given time on the hour).
Both the sync and schedule options will load themselves in to memory each boot and each time your device goes to sleep and/or when scheduled the scripts will depending on your options: (1) sync your data so as to ensure no data is lost; (2) TRIM your /system, /data, and /cache partitions; (3) DROP CACHES = 3; and (4) turn off wifi.
In addition, there is also an on-the-fly script to manually trim partitions and drop caches when desired.
Click to expand...
Click to collapse
Benefits:
Reduce lag/improve i/o efficiency (see THIS and THIS).
Although android automatically invokes fstrim when certain conditions are met, these criteria could seldom if ever be met depending upon your usage style. The init.d script should ensure fstrim is invoked more frequently for most users.
Should use less ram than apps that perform similar functions (I say should because I have never used such apps, but I imagine they consume more that .2-.5 mb of ram).
Click to expand...
Click to collapse
Requirements:
root
init.d
busybox
fstrim (should be in all nexus 4.3+ roms)
Click to expand...
Click to collapse
Warning/Disclaimer:
Although these scripts function as intended on my device – Nexus 7 (2013), SlimKat (weekly), ElementalX...Use at your own risk. Neither I nor XDA are responsible for any possible deleterious effects.
Click to expand...
Click to collapse
Known Issues/Bugs:
If you use the sync option, scripts with a lower priority than Z99 will not execute.
The log files don't always display as intended...dunno why...any help/suggestions would be appreciated.
Let me know if you find any others .
Click to expand...
Click to collapse
Install, Usage/Verification, & Uninstall:
Install -
Note: If you use crond for other tasks, both the install and uninstall routine account for this potential contigency and should leave your other crond tasks uneffects.
make a nandroid backup
download the zip (<<NOT flashable) attached to this post
extract the zip’s contents
if you were/are using the first version of this script manually delete: /etc/init.d/07TrimDropOff, /data/TrimDropOff_Awake.log, and /data/TrimDropOff_Sleep.log
run TrimDropOffInstaller with superuser permission via terminal or script manager.
follow the scripts prompts
reboot
enjoy
Usage/Verification -
Assuming you have followed the install procedure, next, put your device to sleep and then wake it if you are using the sync option.
Now check the various logs in /data/TrimDropOff. The logs will show the time, the script’s PIDs, the path of the PIDs (just to double-check the PIDs are correct), the ram used by the PIDs, action(s) preformed (amount trimmed from each partition and/or if drop_cahes was run), or errors.
If you want verify manually via terminal do [pgrep -f TrimDrop] for the sync option or [pgrep crond] for the scheduling option to get the PIDs, do [cat /proc/PID/cmdline] for each PID to verify it truly belongs to Z99TrimDropOff or crond, and do [dumpsys meminfo | grep PID] for each PID to verify ram usage (this command will yield duplicates, which can be disregarded and may output undesired additional results, which can be filtered by looking through the results for the relevant PID).
To use the on-the-fly script to trim and/or drop as desired, in terminal do [su -c trimdrop].
Should you want to reconfigure your setup, uninstall before reinstalling to avoid potential issues.
Uninstall -
Note: If you use crond for other tasks, both the install and uninstall routine account for this potential contigency and should leave your other crond tasks uneffects.
Rerun TrimDropOffInstaller with superuser permission and use uninstall option at the beginning of the script.
Reboot and all will be back to as it was before.
Click to expand...
Click to collapse
To-Do List:
Make in to an AROMA package.
I don't know, you tell me .
Click to expand...
Click to collapse
Code:
#!/system/bin/sh
# This script was authored by Defiant07 @ xda. Feel free to use it as you see fit, but please give proper credits.
# Big thanks to zeppelinrox, dk_zero-cool, & gu5t3r @ xda for their contributions to portions of this script (see the code of my other script SwapItOn @ xda for detailed citations).
# Read Karl Marx.
input_error(){
echo "That is not a valid input...try again...bye ."
exit 69
}
mount_rw(){
mount -o remount,rw / 2>/dev/null
mount -o remount,rw rootfs 2>/dev/null
busybox mount -o remount,rw / 2>/dev/null
busybox mount -o remount,rw rootfs 2>/dev/null
mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw /system 2>/dev/null
busybox mount -o remount,rw $(busybox mount | awk '/system /{print $1,$3}') 2>/dev/null
}
mount_ro(){
mount -o remount,ro / 2>/dev/null
mount -o remount,ro rootfs 2>/dev/null
busybox mount -o remount,ro / 2>/dev/null
busybox mount -o remount,ro rootfs 2>/dev/null
mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro /system 2>/dev/null
busybox mount -o remount,ro $(busybox mount | awk '/system /{print $1,$3}') 2>/dev/null
}
clear
if [ ! "`busybox`" ]; then
echo "Missing busybox...try again...bye ."
exit 69
fi
id=$(id); id=${id#*=}; id=${id%%[\( ]*}
if [ "$id" = "0" ] || [ "$id" = "root" ]; then
echo "" 1>/dev/null
else
echo "Not running as root...try again...bye ."
exit 69
fi
if [ ! -d /etc/init.d ]; then
echo "Missing /etc/init.d...try again...bye ."
exit 69
fi
if [ ! "`grep -r fstrim /system/bin`" ] && [ ! "`grep -r fstrim /system/xbin`" ]; then
echo "Missing fstrim...try again...bye ."
exit 69
fi
echo "Do you want to install or uninstall TrimDropOff?"
echo "Note: If you are rerunning this script to"
echo "reconfigure your setup, uninstall first."
echo -n "Input (i)nstall or (u)ninstall: "
read install_uninstall
echo
case $install_uninstall in
i|I)mount_rw
if [ ! -d "/sqlite_stmt_journals" ]; then
mkdir /sqlite_stmt_journals
fi
if [ ! -d "/data/TrimDropOff" ]; then
mkdir /data/TrimDropOff
chmod 755 /data/TrimDropOff
fi;;
u|U)mount_rw
rm /system/etc/init.d/Z99TrimDropOff_Sync 2>/dev/null
rm /system/etc/init.d/07TrimDropOff_Cron 2>/dev/null
rm /system/xbin/trimdrop 2>/dev/null
rm -rf /data/TrimDropOff 2>/dev/null
echo "Are you using cron.d for any other services?"
echo -n "Input es or o: "
read crond_use
echo
case $crond_use in
y|Y)sed '/TrimDropOff/d' -i /system/etc/cron.d/crontabs/root 2>/dev/null;;
n|N)rm -rf /system/etc/cron.d 2>/dev/null;;
*)input_error;;
esac
mount_ro
echo "All done. You can close your app now."
echo "Reboot your device to stop all processes."
exit 0;;
*)input_error;;
esac
wifi_only(){
cat > /system/etc/init.d/Z99TrimDropOff_Sync << EOF
#!/system/bin/sh
tdo_time(){
while [ ! "\`ps | grep -m 1 [a]ndroid\`" ]; do sleep 10; done
while [ 1 ]; do
AWAKE=\`cat /sys/power/wait_for_fb_wake\`
if [ "\$AWAKE" = "awake" ]; then
exec 1>/data/TrimDropOff/Awake.log
svc wifi enable
echo "\$(date +"%r %Y.%m.%d"): Waiting for screen to sleep. Confirming script in memory..."
echo "PIDs:"
pgrep -f TrimDrop
pidls=\`pgrep -f TrimDrop\`
echo "Verify Correct PIDs:"
for i in \$pidls; do
cat /proc/\$i/cmdline
done
echo ""
echo "RAM Usage:"
for i in \$pidls; do
dumpsys meminfo | grep \$i | grep sh | grep -m 1 pid
done
fi
SLEEPING=\`cat /sys/power/wait_for_fb_sleep\`
if [ "\$SLEEPING" = "sleeping" ]; then
exec 1>/data/TrimDropOff/Sleep.log
echo "\$(date +"%r %Y.%m.%d"): Offing."
svc wifi disable
fi
done
}
if [ "\`ps | grep -m 1 [a]ndroid\`" ]; then tdo_time
else exec > /data/TrimDropOff/Sync_BootErrors.log 2>&1
tdo_time &
fi
exit 0
EOF
}
fstrim_only(){
cat > /system/etc/init.d/Z99TrimDropOff_Sync << EOF
#!/system/bin/sh
tdo_time(){
while [ ! "\`ps | grep -m 1 [a]ndroid\`" ]; do sleep 10; done
while [ 1 ]; do
AWAKE=\`cat /sys/power/wait_for_fb_wake\`
if [ "\$AWAKE" = "awake" ]; then
exec 1>/data/TrimDropOff/Awake.log
echo "\$(date +"%r %Y.%m.%d"): Waiting for screen to sleep. Confirming script in memory..."
echo "PIDs:"
pgrep -f TrimDrop
pidls=\`pgrep -f TrimDrop\`
echo "Verify Correct PIDs:"
for i in \$pidls; do
cat /proc/\$i/cmdline
done
echo ""
echo "RAM Usage:"
for i in \$pidls; do
dumpsys meminfo | grep \$i | grep sh | grep -m 1 pid
done
fi
SLEEPING=\`cat /sys/power/wait_for_fb_sleep\`
if [ "\$SLEEPING" = "sleeping" ]; then
exec 1>/data/TrimDropOff/Sleep.log
echo "\$(date +"%r %Y.%m.%d"): Trimming."
echo "/system:"
busybox sync
fstrim -v /system
echo "/data:"
busybox sync
fstrim -v /data
echo "/cache:"
busybox sync
fstrim -v /cache
fi
done
}
if [ "\`ps | grep -m 1 [a]ndroid\`" ]; then tdo_time
else exec > /data/TrimDropOff/Sync_BootErrors.log 2>&1
tdo_time &
fi
exit 0
EOF
}
drop_only(){
cat > /system/etc/init.d/Z99TrimDropOff_Sync << EOF
#!/system/bin/sh
tdo_time(){
while [ ! "\`ps | grep -m 1 [a]ndroid\`" ]; do sleep 10; done
while [ 1 ]; do
AWAKE=\`cat /sys/power/wait_for_fb_wake\`
if [ "\$AWAKE" = "awake" ]; then
exec 1>/data/TrimDropOff/Awake.log
echo "\$(date +"%r %Y.%m.%d"): Waiting for screen to sleep. Confirming script in memory..."
echo "PIDs:"
pgrep -f TrimDrop
pidls=\`pgrep -f TrimDrop\`
echo "Verify Correct PIDs:"
for i in \$pidls; do
cat /proc/\$i/cmdline
done
echo ""
echo "RAM Usage:"
for i in \$pidls; do
dumpsys meminfo | grep \$i | grep sh | grep -m 1 pid
done
fi
SLEEPING=\`cat /sys/power/wait_for_fb_sleep\`
if [ "\$SLEEPING" = "sleeping" ]; then
exec 1>/data/TrimDropOff/Sleep.log
echo "\$(date +"%r %Y.%m.%d"): Dropping."
echo "drop caches:"
busybox sync
busybox sysctl -w vm.drop_caches=3
fi
done
}
if [ "\`ps | grep -m 1 [a]ndroid\`" ]; then tdo_time
else exec > /data/TrimDropOff/Sync_BootErrors.log 2>&1
tdo_time &
fi
exit 0
EOF
}
wifi_fstrim(){
cat > /system/etc/init.d/Z99TrimDropOff_Sync << EOF
#!/system/bin/sh
tdo_time(){
while [ ! "\`ps | grep -m 1 [a]ndroid\`" ]; do sleep 10; done
while [ 1 ]; do
AWAKE=\`cat /sys/power/wait_for_fb_wake\`
if [ "\$AWAKE" = "awake" ]; then
exec 1>/data/TrimDropOff/Awake.log
svc wifi enable
echo "\$(date +"%r %Y.%m.%d"): Waiting for screen to sleep. Confirming script in memory..."
echo "PIDs:"
pgrep -f TrimDrop
pidls=\`pgrep -f TrimDrop\`
echo "Verify Correct PIDs:"
for i in \$pidls; do
cat /proc/\$i/cmdline
done
echo ""
echo "RAM Usage:"
for i in \$pidls; do
dumpsys meminfo | grep \$i | grep sh | grep -m 1 pid
done
fi
SLEEPING=\`cat /sys/power/wait_for_fb_sleep\`
if [ "\$SLEEPING" = "sleeping" ]; then
exec 1>/data/TrimDropOff/Sleep.log
echo "\$(date +"%r %Y.%m.%d"): Trimming, Offing."
echo "/system:"
busybox sync
fstrim -v /system
echo "/data:"
busybox sync
fstrim -v /data
echo "/cache:"
busybox sync
fstrim -v /cache
svc wifi disable
fi
done
}
if [ "\`ps | grep -m 1 [a]ndroid\`" ]; then tdo_time
else exec > /data/TrimDropOff/Sync_BootErrors.log 2>&1
tdo_time &
fi
exit 0
EOF
}
wifi_drop(){
cat > /system/etc/init.d/Z99TrimDropOff_Sync << EOF
#!/system/bin/sh
tdo_time(){
while [ ! "\`ps | grep -m 1 [a]ndroid\`" ]; do sleep 10; done
while [ 1 ]; do
AWAKE=\`cat /sys/power/wait_for_fb_wake\`
if [ "\$AWAKE" = "awake" ]; then
exec 1>/data/TrimDropOff/Awake.log
svc wifi enable
echo "\$(date +"%r %Y.%m.%d"): Waiting for screen to sleep. Confirming script in memory..."
echo "PIDs:"
pgrep -f TrimDrop
pidls=\`pgrep -f TrimDrop\`
echo "Verify Correct PIDs:"
for i in \$pidls; do
cat /proc/\$i/cmdline
done
echo ""
echo "RAM Usage:"
for i in \$pidls; do
dumpsys meminfo | grep \$i | grep sh | grep -m 1 pid
done
fi
SLEEPING=\`cat /sys/power/wait_for_fb_sleep\`
if [ "\$SLEEPING" = "sleeping" ]; then
exec 1>/data/TrimDropOff/Sleep.log
echo "\$(date +"%r %Y.%m.%d"): Dropping, Offing."
echo "drop caches:"
busybox sync
busybox sysctl -w vm.drop_caches=3
svc wifi disable
fi
done
}
if [ "\`ps | grep -m 1 [a]ndroid\`" ]; then tdo_time
else exec > /data/TrimDropOff/Sync_BootErrors.log 2>&1
tdo_time &
fi
exit 0
EOF
}
fstrim_drop(){
cat > /system/etc/init.d/Z99TrimDropOff_Sync << EOF
#!/system/bin/sh
tdo_time(){
while [ ! "\`ps | grep -m 1 [a]ndroid\`" ]; do sleep 10; done
while [ 1 ]; do
AWAKE=\`cat /sys/power/wait_for_fb_wake\`
if [ "\$AWAKE" = "awake" ]; then
exec 1>/data/TrimDropOff/Awake.log
echo "\$(date +"%r %Y.%m.%d"): Waiting for screen to sleep. Confirming script in memory..."
echo "PIDs:"
pgrep -f TrimDrop
pidls=\`pgrep -f TrimDrop\`
echo "Verify Correct PIDs:"
for i in \$pidls; do
cat /proc/\$i/cmdline
done
echo ""
echo "RAM Usage:"
for i in \$pidls; do
dumpsys meminfo | grep \$i | grep sh | grep -m 1 pid
done
fi
SLEEPING=\`cat /sys/power/wait_for_fb_sleep\`
if [ "\$SLEEPING" = "sleeping" ]; then
exec 1>/data/TrimDropOff/Sleep.log
echo "\$(date +"%r %Y.%m.%d"): Trimming, Dropping."
echo "/system:"
busybox sync
fstrim -v /system
echo "/data:"
busybox sync
fstrim -v /data
echo "/cache:"
busybox sync
fstrim -v /cache
echo "drop caches:"
busybox sync
busybox sysctl -w vm.drop_caches=3
fi
done
}
if [ "\`ps | grep -m 1 [a]ndroid\`" ]; then tdo_time
else exec > /data/TrimDropOff/Sync_BootErrors.log 2>&1
tdo_time &
fi
exit 0
EOF
}
wifi_fstrim_drop(){
cat > /system/etc/init.d/Z99TrimDropOff_Sync << EOF
#!/system/bin/sh
tdo_time(){
while [ ! "\`ps | grep -m 1 [a]ndroid\`" ]; do sleep 10; done
while [ 1 ]; do
AWAKE=\`cat /sys/power/wait_for_fb_wake\`
if [ "\$AWAKE" = "awake" ]; then
exec 1>/data/TrimDropOff/Awake.log
svc wifi enable
echo "\$(date +"%r %Y.%m.%d"): Waiting for screen to sleep. Confirming script in memory..."
echo "PIDs:"
pgrep -f TrimDrop
pidls=\`pgrep -f TrimDrop\`
echo "Verify Correct PIDs:"
for i in \$pidls; do
cat /proc/\$i/cmdline
done
echo ""
echo "RAM Usage:"
for i in \$pidls; do
dumpsys meminfo | grep \$i | grep sh | grep -m 1 pid
done
fi
SLEEPING=\`cat /sys/power/wait_for_fb_sleep\`
if [ "\$SLEEPING" = "sleeping" ]; then
exec 1>/data/TrimDropOff/Sleep.log
echo "\$(date +"%r %Y.%m.%d"): Trimming, Dropping, Offing."
echo "/system:"
busybox sync
fstrim -v /system
echo "/data:"
busybox sync
fstrim -v /data
echo "/cache:"
busybox sync
fstrim -v /cache
echo "drop caches:"
busybox sync
busybox sysctl -w vm.drop_caches=3
svc wifi disable
fi
done
}
if [ "\`ps | grep -m 1 [a]ndroid\`" ]; then tdo_time
else exec > /data/TrimDropOff/Sync_BootErrors.log 2>&1
tdo_time &
fi
exit 0
EOF
}
echo "Do you want to sync fstrim, drop_caches=3, and/or"
echo "wifi with sleep?"
echo "WARNING: This will cause init.d scripts with a"
echo "priority lower than Z99 to NOT execute."
echo -n "Input es or o: "
read TDOsync
echo
case $TDOsync in
y|Y)echo "Which function(s) would you like to sync with sleep?"
echo "Input 1 for wifi only, 2 for fstrim only,"
echo "3 for drop_caches only, 4 for wifi and fstrim"
echo "5 for wifi and drop, 6 for fstrim and drop, or"
echo -n "7 for all: "
read sync_opt
echo
case $sync_opt in
1)wifi_only;;
2)fstrim_only;;
3)drop_only;;
4)wifi_fstrim;;
5)wifi_drop;;
6)fsrim_drop;;
7)wifi_fstrim_drop;;
*)input_error;;
esac
chmod 755 /system/etc/init.d/Z99TrimDropOff_Sync;;
n|N);;
*)input_error;;
esac
only_fstrim(){
cat > /data/TrimDropOff/TrimDropOff_Cron << EOF
#!/system/bin/sh
# This script was authored by Defiant07 @ xda. Feel free to use it as you see fit, but please give proper credits.
# Read Karl Marx.
exec 1>/data/TrimDropOff/CronRan.log
echo "\$(date +"%r %Y.%m.%d"): Trimming."
echo "/system:"
busybox sync
fstrim -v /system
echo "/data:"
busybox sync
fstrim -v /data
echo "/cache:"
busybox sync
fstrim -v /cache
exit 0
EOF
}
only_drop(){
cat > /data/TrimDropOff/TrimDropOff_Cron << EOF
#!/system/bin/sh
# This script was authored by Defiant07 @ xda. Feel free to use it as you see fit, but please give proper credits.
# Read Karl Marx.
exec 1>/data/TrimDropOff/CronRan.log
echo "\$(date +"%r %Y.%m.%d"): Dropping."
echo "drop caches:"
busybox sync
busybox sysctl -w vm.drop_caches=3
exit 0
EOF
}
both_funct(){
cat > /data/TrimDropOff/TrimDropOff_Cron << EOF
#!/system/bin/sh
# This script was authored by Defiant07 @ xda. Feel free to use it as you see fit, but please give proper credits.
# Read Karl Marx.
exec 1>/data/TrimDropOff/CronRan.log
echo "\$(date +"%r %Y.%m.%d"): Trimming, Dropping."
echo "/system:"
busybox sync
fstrim -v /system
echo "/data:"
busybox sync
fstrim -v /data
echo "/cache:"
busybox sync
fstrim -v /cache
echo "drop caches:"
busybox sync
busybox sysctl -w vm.drop_caches=3
exit 0
EOF
}
cron_starter(){
cat > /system/etc/init.d/07TrimDropOff_Cron << EOF
#!/system/bin/sh
# This script was authored by Defiant07 @ xda. Feel free to use it as you see fit, but please give proper credits.
# Read Karl Marx.
tdo_time(){
while [ ! "\`ps | grep -m 1 [a]ndroid\`" ]; do sleep 10; done
crond
exec 1>/data/TrimDropOff/CronBoot.log
echo "\$(date +"%r %Y.%m.%d"): cron.d service started."
echo "PIDs:"
pgrep crond
pidls=\`pgrep crond\`
echo "Verify Correct PIDs:"
for i in \$pidls; do
cat /proc/\$i/cmdline
done
echo ""
echo "RAM Usage:"
for i in \$pidls; do
dumpsys meminfo | grep \$i | grep -m 1 crond
done
}
if [ "\`ps | grep -m 1 [a]ndroid\`" ]; then tdo_time
else exec > /data/TrimDropOff/Cron_BootErrors.log 2>&1
tdo_time &
fi
exit 0
EOF
}
echo "Do you want to run fstrim and/or drop_caches"
echo "on a schedule?"
echo -n "Input es or o: "
read sched_opt
echo
case $sched_opt in
y|Y)echo "Which function do you want to schedule?"
echo "Input (f)strim only, (d)rop_caches only,"
echo -n "or (b)oth: "
read funct_opt
echo
case $funct_opt in
f|F)only_fstrim;;
d|D)only_drop;;
b|B)both_funct;;
*)input_error;;
esac
chmod 755 /data/TrimDropOff/TrimDropOff_Cron
echo "Do you want to schedule the function(s)"
echo "on an hourly or daily basis?"
echo -n "Input (h)ourly or (d)aily: "
read sched_opt
echo
if [ ! -d "/system/etc/cron.d" ]; then
mkdir /system/etc/cron.d
chmod 755 /system/etc/cron.d
fi
if [ ! -d "/system/etc/cron.d/crontabs" ]; then
mkdir /system/etc/cron.d/crontabs
chmod 755 /system/etc/cron.d/crontabs
fi
cron_starter
chmod 755 /system/etc/init.d/07TrimDropOff_Cron
case $sched_opt in
h|H)echo "Input 1 to run every hour, 2 to run every two hours,"
echo -n "3 to run every three hours...etc: "
read hour_opt
echo
if [ ! "`echo $hour_opt | awk '!/[^0-9]/'`" ]; then
input_error
fi
if [ -f "/system/etc/cron.d/crontabs/root" ]; then
echo "0 */$hour_opt * * * nohup /data/TrimDropOff/TrimDropOff_Cron" >> /system/etc/cron.d/crontabs/root
else
echo "0 */$hour_opt * * * nohup /data/TrimDropOff/TrimDropOff_Cron" > /system/etc/cron.d/crontabs/root
fi
chmod 755 /system/etc/cron.d/crontabs/root;;
d|D)echo "Input 0 to run at midnight every day,"
echo "1 to run at 1:00 am...13 to run at 1:00 pm"
echo -n "...etc...up to 23: "
read daily_opt
echo
if [ ! "`echo $daily_opt | awk '!/[^0-9]/ && $1<=23'`" ]; then
input_error
fi
if [ -f "/system/etc/cron.d/crontabs/root" ]; then
echo "0 $daily_opt * * * nohup /data/TrimDropOff/TrimDropOff_Cron" >> /system/etc/cron.d/crontabs/root
else
echo "0 $daily_opt * * * nohup /data/TrimDropOff/TrimDropOff_Cron" > /system/etc/cron.d/crontabs/root
fi
chmod 755 /system/etc/cron.d/crontabs/root;;
*)input_error;;
esac;;
n|N);;
*)input_error;;
esac
cat > /system/xbin/trimdrop << EOF
#!/system/bin/sh
# This script was authored by Defiant07 @ xda. Feel free to use it as you see fit, but please give proper credits.
# Read Karl Marx.
clear
trimmer(){
echo "/system:"
busybox sync
fstrim -v /system
echo "/data:"
busybox sync
fstrim -v /data
echo "/cache:"
busybox sync
fstrim -v /cache
}
dropper(){
echo "drop caches:"
busybox sync
busybox sysctl -w vm.drop_caches=3
}
echo -n "Do you want to run (f)strim, (d)rop_caches=3, or (b)oth? "
read funct_opt
echo
case \$funct_opt in
f|F)trimmer;;
d|D)dropper;;
b|B)trimmer
dropper;;
*)echo "That is not a valid input...try again...bye ."
exit 69;;
esac
echo
echo "All done...enjoy! You can close your app now."
exit 0
EOF
chmod 755 /system/xbin/trimdrop
mount_ro
echo "In addition to making the files required by"
echo "your desired configuration, I have also made"
echo "an on-the-fly script to run fstrim and/or"
echo "drop_caches on-demand."
echo "To use it, in terminal do: su -c trimdrop"
echo
sleep 3
echo "Reboot your device to start your desired services."
echo
sleep 3
echo "If you want to know how to verify everything"
echo "is working, read the script's OP (FFS)!"
echo
sleep 5
echo "All done...enjoy! You can close your app now."
exit 0
Click to expand...
Click to collapse
Changelog:
v2.0
made in to installer script
added cron options
added bootloop precautions to the init.d scripts (should make it compatible with all devices that meet the requirments)
the on-the-fly script, trimdrop, now allows user to choose fstrim and/or drop_caches=3
added more syncs to further ensure no data is lost
a bunch of other stuff I probably forget
v2.1
bug fixes - fixed issue if using only sync option (missing directory); fixed display of irrelevant errors in uninstall routine
cleaned code a bit (reduced redundancy)
Click to expand...
Click to collapse
Download History:
Defiant07s_TrimDropOff.zip - [Click for QR Code] (1.6 KB, 162 views)
Defiant07s_TrimDropOff_v2.0_[NOT_FLASHABLE].zip - [Click for QR Code] (3.0 KB, 89 views)
Click to expand...
Click to collapse
Credits:
Big thanks to @zeppelinrox, @dk_zero-cool, & @gu5t3r for their contributions to portions of this script (see the code of my other script SwapItOn for detailed citations).
Much thanks to @mdamaged for spotting the issue with sync init.d script and his note regarding syncing data.
Click to expand...
Click to collapse
Don't forget to click THANKS and RATE 5 STARS if you found this useful :highfive:.
peep my other script SwapItOn
Update to v2.1 if you were only using the sync option.
If you were using both the sync and schedule options or only the schedule option there is no need to update; the bug I found would not effect you.​
reserved...on the off chance it will be needed
Thanks, sounds interesting. I'm assuming the zip can be flashed right after flashing a new rom?
MidnightDevil said:
Thanks, sounds interesting. I'm assuming the zip can be flashed right after flashing a new rom?
Click to expand...
Click to collapse
Not a flashable ZIP per line 2.
AnarchoXen said:
Not a flashable ZIP per line 2.
Click to expand...
Click to collapse
Oh, thanks
Is compatible with custom kernel? Franco in my case
vía n7II r-paco
Will performing trimming operations too frequently cause additional flash memory degradation?
MidnightDevil said:
Thanks, sounds interesting. I'm assuming the zip can be flashed right after flashing a new rom?
Click to expand...
Click to collapse
As you were informed the zip is NOT flashable. If there is sufficient interest (say a 100 downloads) I'll make it flashable/aroma.
jordirpz said:
Is compatible with custom kernel? Franco in my case
vía n7II r-paco
Click to expand...
Click to collapse
Yes, it should be compatible...the fstrim utility is part of the rom (it should be in all nexus 4.3+ roms).
creeve4 said:
Will performing trimming operations too frequently cause additional flash memory degradation?
Click to expand...
Click to collapse
No, to my limited knowledge it should not be harmful (in fact it should increase lifespan - google "fstrim lifespan"). Did a quick google search but could not find anything definitive/reliable regarding frequency...what I did see seemed to suggest 'no' though.
If you are concerned about the frequency, you could not install the init.d script and just use the on-the-fly script, trimdrop, to trim on-demand. Should there be interest and if I have the motivation and time, I have been thinking about making this in to an installer script and/or aroma zip with cron-based options so it could be scheduled hourly, daily, or weekly.
Scheduling options would be awesome!
creeve4 said:
Scheduling options would be awesome!
Click to expand...
Click to collapse
+1
creeve4 said:
Scheduling options would be awesome!
Click to expand...
Click to collapse
BUBA0071 said:
+1
Click to expand...
Click to collapse
Seems there is a decent amount of interest (almost 100 downloads already ...thanks peeps), as such I'll add options and make things more configurable.
Regarding scheduling, I was thinking of doing hourly, daily (with ability to choose time), and weekly (with ability to choose day and time) options. Would every other hour or some other setting be desirable?
Regarding installation, what would be the preferred method, an installer script (e.g. V6 SuperCharger) or AROMA? Flashable zips would be another option, but would have less options/be less configurable.
Gimme some feedback and I'll put something together in the next week or two depending on work and my motivation .
wasn't this a nexus 7 2012 issue and fixed in the new version 2013?
defiant07 said:
Seems there is a decent amount of interest (almost 100 downloads already ...thanks peeps), as such I'll add options and make things more configurable.
Regarding scheduling, I was thinking of doing hourly, daily (with ability to choose time), and weekly (with ability to choose day and time) options. Would every other hour or some other setting be desirable?
Regarding installation, what would be the preferred method, an installer script (e.g. V6 SuperCharger) or AROMA? Flashable zips would be another option, but would have less options/be less configurable.
Gimme some feedback and I'll put something together in the next week or two depending on work and my motivation .
Click to expand...
Click to collapse
My 2 cents:
I would choose a daily option for my device.
I prefer Aroma over a script, but if you cannot get the customization you want with Aroma, then by all means go with a script.
Thanks again for the script and willingness to make it even better!
Thanks for the scripts, I time my startup, and this improved startup time by about 3-4secs, among other noticible improvements, apparently the stock OS does not run fstrim enough, initial operations freed several gigs on the data partition, and hundreds of megs on the others...
creeve4 said:
My 2 cents:
I would choose a daily option for my device.
I prefer Aroma over a script, but if you cannot get the customization you want with Aroma, then by all means go with a script.
Thanks again for the script and willingness to make it even better!
Click to expand...
Click to collapse
+1
Im going to turn this into a cron job, that will take care of scheduling, unless anyone else gets there first ( please lol )
Will give it a go in its present form, whats its resource footprint just sitting there waiting for screen off ?
Can we trigger the action from the screen off event ? or some other interupt type way ?
Great script by the way, your bash is damn site better than mine, jealous lol
KiaraTheDragon said:
wasn't this a nexus 7 2012 issue and fixed in the new version 2013?
Click to expand...
Click to collapse
Yes, I think this is true to a degree...it was more of a problem on the 2012 and other nexus devices. See the links in the OP for the conditions that need to be met for fstrim to autorun...for some users (myself included) the conditions will seldom if ever be met. Also see @mdamaged post; I get similar results the first time fstrim is initiated by my script after each boot...subsequent runs normally only frees up memory on /data.
creeve4 said:
My 2 cents:
I would choose a daily option for my device.
I prefer Aroma over a script, but if you cannot get the customization you want with Aroma, then by all means go with a script.
Thanks again for the script and willingness to make it even better!
Click to expand...
Click to collapse
imfun said:
+1
Click to expand...
Click to collapse
Okay will get to making an AROMA package...it will be my first, but it looks easy enough :fingers-crossed:...gimme a week or two to put it together and fully test.
mdamaged said:
Thanks for the scripts, I time my startup, and this improved startup time by about 3-4secs, among other noticible improvements, apparently the stock OS does not run fstrim enough, initial operations freed several gigs on the data partition, and hundreds of megs on the others...
Click to expand...
Click to collapse
Thanks for the feedback. I get similar results.
jubei_mitsuyoshi said:
Im going to turn this into a cron job, that will take care of scheduling, unless anyone else gets there first ( please lol )
Will give it a go in its present form, whats its resource footprint just sitting there waiting for screen off ?
Can we trigger the action from the screen off event ? or some other interupt type way ?
Great script by the way, your bash is damn site better than mine, jealous lol
Click to expand...
Click to collapse
See the first post on this page and my response to @creeve4 and @imfun in this post. I will make an AROMA package with cron options for fstrim and drop_caches=3.
However, should you feel ambitious and beat me to it, props to you...I will give you full credit in the OP and link your post as the d/l source so you should get the 'thanks' too.
Regarding triggering with screen on/off or some other event: It can probably be done, but I it's beyond my knowledge (screen on/off was actually the first trigger event I looked in to using, but despite fairly extensive searching I could not find how to detect it).
Regarding resource footprint: Read the OP (usage section) it explains where to find the log which contains this info and how to do it via terminal (should you not trust me )...also see OP (benefits section): in all my testing I have never seen it use more that .8 mb, but most of the time it is less than .2 mb.
Okay will get to making an AROMA package...it will be my first, but it looks easy enough :fingers-crossed:...gimme a week or two to put it together and fully test.
Click to expand...
Click to collapse
Can't wait already, because after whole day or two, hard usage of my nexus 7 tablet, the tablet starts to get laggy. I can see this on web browsing, touch press delay time, and onyl rebooting seems to help... Hope after istaling this will solve the problems
ohhh no dont want any credit lol lol, i have turned it into a cron job quite simply by adding it to the cron initilising script
Code:
###########
# IMPORTS #
###########
. /system/etc/init.d.cfg
#############
# FUNCTIONS #
#############
symlink_system_bin() {
# crond has "/bin/sh" hardcoded
if busybox [ ! -h /bin ]
then
mount -o remount,rw rootfs /
busybox ln -s /system/bin /bin
mount -o remount,ro rootfs /
fi
}
export_timezone() {
# set timezone (if you're not between -0500 and -0800 you get PST)
# todo - support other timezones
timezone=`date +%z`
if busybox [ $timezone = "-0800" ]; then
TZ=PST8PDT
elif busybox [ $timezone = "-0700" ]; then
TZ=MST7MDT
elif busybox [ $timezone = "-0600" ]; then
TZ=CST6CDT
elif busybox [ $timezone = "-0500" ]; then
TZ=EST5EDT
else
TZ=PST8PDT
fi
export TZ
}
set_crontab() {
# use /data/cron, call the crontab file "root"
if busybox [ -e /data/cron/root ]
then
mkdir -p /data/cron
cat > /data/cron/root << EOF
0 20 * * * sync; echo 3 > /proc/sys/vm/drop_caches
0 20 * * * sync; fstrim -v /system
0 20 * * * sync; fstrim -v /data
0 20 * * * sync; fstrim -v /cache
01 * * * * busybox run-parts /system/etc/cron/cron.hourly
02 4 * * * busybox run-parts /system/etc/cron/cron.daily
22 4 * * 0 busybox run-parts /system/etc/cron/cron.weekly
EOF
fi
busybox crond -c /data/cron
}
########
# MAIN #
########
if $enable_cron -a is_busybox_applet_available crond
then
symlink_system_bin
export_timezone
set_crontab
fi
adding the lines
Code:
0 20 * * * sync; echo 3 > /proc/sys/vm/drop_caches
0 20 * * * sync; fstrim -v /system
0 20 * * * sync; fstrim -v /data
0 20 * * * sync; fstrim -v /cache
should drop the caches and fstrim every 8 hours, oviously set to anything you want.
i also stuck it in boot at the end
/system/etc/init.d/92jubei
Code:
#!/system/bin/sh
if $file_system_speedups
then
busybox mount -o remount,noatime,barrier=0,nobh /system
busybox mount -o remount,noatime /data
busybox mount -o remount,noatime,barrier=0,nobh /cache
else
busybox mount -o remount,noatime,nobh /system
busybox mount -o remount,noatime /data
busybox mount -o remount,noatime,nobh /cache
fi
echo "$(date +"%r %Y.%m.%d"): Trimming, Dropping."
busybox sync
echo "/system:"
fstrim -v /system
echo "/data:"
fstrim -v /data
echo "/cache:"
fstrim -v /cache
echo "drop caches:"
busybox sysctl -w vm.drop_caches=3
exit 0
For an aroma script you will prob have to stick the file in /system/etc/cron/cron.hourly, daily, weekly and just give peeps that choice, will be most simple way. Ps not a fan of aroma lol
Ok, I should have spotted this issue right away, but did not, so here goes. It seems the use of while loop in the script in the OP causes any scripts with a lower priority in init.d to never get ran, if the script in the OP is the only one in your init.d this does not matter, nor should it matter if you have at boot script with a higher priority (they get ran before the OPs script).
I run the ElementalX kernel which depends on a init.d to initialize some parameters for the kernel, with this script in init.d they never get initialized, in my case this resulted in some things not 'taking' such as the battery life extender, which on my device, is set to stop charging at 4100mv, however, since the while loop kept the ElementalX init.d from running, it kept charging to ~4300mv, this is how I noticed (actually none of my settings wrt ElementalX were being initialized, but this symptom was most pronounced).
A simple fix would be to move up the priority of the ElementalX init.d script, but this would have to be done after each flash, and frankly since I run Tasker anyway, I saw no need for this, what I did was remove the OPs script from init.d and simply made a very simple task in Tasker to run /system/xbin/trimdrop when display goes off, it could just as easily be a time event.
Anyways, hope that helps someone who may come across this with other kernels, or other at-boot scripts which depend on being ran before the OPs script.
Again, thanks to the OP for his work. Also, I added another sync just before the drop caches, since the state of dirtyness could change after the fstrims.

[Tweak][Guide] Init.d Tweaks

Init.d Tweaks
(Needs ROM (Kernel) With init.d Access And Busybox, Open Empty File In Text Editor (Notepad ++ Or Similar), Insert Tweak You Want In Header,Save in /system/etc/init.d and name it Lomething Like 73tweaks)
1. Strict minfree handler tweak
Code:
echo "2048,3072,6144,15360,17920,20480" > /sys/module/lowmemorykiller/parameters/minfree
2. Internet speed tweaks
Code:
echo "0" > /proc/sys/net/ipv4/tcp_timestamps;
echo "1" > /proc/sys/net/ipv4/tcp_tw_reuse;
echo "1" > /proc/sys/net/ipv4/tcp_sack;
echo "1" > /proc/sys/net/ipv4/tcp_tw_recycle;
echo "1" > /proc/sys/net/ipv4/tcp_window_scaling;
echo "5" > /proc/sys/net/ipv4/tcp_keepalive_probes;
echo "30" > /proc/sys/net/ipv4/tcp_keepalive_intvl;
echo "30" > /proc/sys/net/ipv4/tcp_fin_timeout;
echo "404480" > /proc/sys/net/core/wmem_max;
echo "404480" > /proc/sys/net/core/rmem_max;
echo "256960" > /proc/sys/net/core/rmem_default;
echo "256960" > /proc/sys/net/core/wmem_default;
echo "4096,16384,404480" > /proc/sys/net/ipv4/tcp_wmem;
echo "4096,87380,404480" > /proc/sys/net/ipv4/tcp_rmem;
3. Vm management tweaks
Code:
echo "4096" > /proc/sys/vm/min_free_kbytes
echo "0" > /proc/sys/vm/oom_kill_allocating_task;
echo "0" > /proc/sys/vm/panic_on_oom;
echo "0" > /proc/sys/vm/laptop_mode;
echo "0" > /proc/sys/vm/swappiness
echo "50" > /proc/sys/vm/vfs_cache_pressure
echo "90" > /proc/sys/vm/dirty_ratio
echo "70" > /proc/sys/vm/dirty_background_ratio
4. Misc kernel tweaks
Code:
echo "8" > /proc/sys/vm/page-cluster;
echo "64000" > /proc/sys/kernel/msgmni;
echo "64000" > /proc/sys/kernel/msgmax;
echo "10" > /proc/sys/fs/lease-break-time;
echo "500,512000,64,2048" > /proc/sys/kernel/sem;
5. Battery tweaks
Code:
echo "500" > /proc/sys/vm/dirty_expire_centisecs
echo "1000" > /proc/sys/vm/dirty_writeback_centisecs
6. EXT4 tweaks (greatly increase I/O)
(needs /system, /cache, /data partitions formatted to EXT4)
a) removes journalism
Code:
tune2fs -o journal_data_writeback /block/path/to/system
tune2fs -O ^has_journal /block/path/to/system
tune2fs -o journal_data_writeback /block/path/to/cache
tune2fs -O ^has_journal /block/path/to/cache
tune2fs -o journal_data_writeback /block/path/to/data
tune2fs -O ^has_journal /block/path/to/data
b) perfect mount options
Code:
busybox mount -o remount,noatime,noauto_da_alloc,nodiratime,barrier=0,nobh /system
busybox mount -o remount,noatime,noauto_da_alloc,nosuid,nodev,nodiratime,barrier=0,nobh /data
busybox mount -o remount,noatime,noauto_da_alloc,nosuid,nodev,nodiratime,barrier=0,nobh /cache
7. Flags blocks as non-rotational and increases cache size
Code:
LOOP=`ls -d /sys/block/loop*`;
RAM=`ls -d /sys/block/ram*`;
MMC=`ls -d /sys/block/mmc*`;
for j in $LOOP $RAM
do
echo "0" > $j/queue/rotational;
echo "2048" > $j/queue/read_ahead_kb;
done
8. microSD card speed tweak
Code:
echo "2048" > /sys/devices/virtual/bdi/179:0/read_ahead_kb;
9. Defrags database files
Code:
for i in \
`find /data -iname "*.db"`
do \
sqlite3 $i 'VACUUM;';
done
9. Remove logger
Code:
rm /dev/log/main
10. Ondemand governor tweaks
Code:
SAMPLING_RATE=$(busybox expr `cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_transition_latency` \* 750 / 1000)
echo 95 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
echo $SAMPLING_RATE > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
11. Auto change governor and I/O Scheduler
a) I/O Scheduler (Best: MTD devices - VR; EMMC devices - SIO) - needs kernel with these
Code:
echo "vr" > /sys/block/mmcblk0/queue/scheduler
or
Code:
echo "sio" > /sys/block/mmcblk0/queue/scheduler
b) Governor (Best: Minmax > SavagedZen > Smoothass > Smartass > Interactive) - needs kernel with these
Code:
echo "governor-name-here" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
12. Move dalvik-cache to cache partition (if it's big enough) to free up data partition space
Code:
CACHESIZE=$(df -k /cache | tail -n1 | tr -s ' ' | cut -d ' ' -f2)
if [ $CACHESIZE -gt 80000 ]
then
echo "Large cache detected, moving dalvik-cache to /cache"
if [ ! -d /cache/dalvik-cache ]
then
busybox rm -rf /cache/dalvik-cache /data/dalvik-cache
mkdir /cache/dalvik-cache /data/dalvik-cache
fi
busybox chown 1000:1000 /cache/dalvik-cache
busybox chmod 0771 /cache/dalvik-cache
# bind mount dalvik-cache so we can still boot without the sdcard
busybox mount -o bind /cache/dalvik-cache /data/dalvik-cache
busybox chown 1000:1000 /data/dalvik-cache
busybox chmod 0771 /data/dalvik-cache
else
echo "Small cache detected, dalvik-cache will remain on /data"
fi
13. Disable normalize sleeper
Code:
mount -t debugfs none /sys/kernel/debug
echo NO_NORMALIZED_SLEEPER > /sys/kernel/debug/sched_features
14. GPS.conf
(create or edit your /system/etc/gps.conf with a text editor)
a) European NTP server (replace for america or asia in your case)
Code:
NTP_SERVER=europe.pool.ntp.org
XTRA_SERVER_1=http://xtra1.gpsonextra.net/xtra.bin
XTRA_SERVER_2=http://xtra2.gpsonextra.net/xtra.bin
XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra.bin
b) SE supl for A-GPS (better than Nokia's or Google's)
Code:
SUPL_HOST=supl.sonyericsson.com
SUPL_PORT=7275
Warning: Using these tweaks may brick your device. Use it with caution.
:good::good::good:
How can I know that my ROM / kernel support Init.d or not??
AK205 said:
How can I know that my ROM / kernel support Init.d or not??
Click to expand...
Click to collapse
Install Universal Init.d from Play Store and follow in-app instructions. Init.d support will be enabled on your device. Your device must be rooted first.
Build.prop tweaks by @bravonova
bravonova said:
Install Universal Init.d from Play Store and follow in-app instructions. Init.d support will be enabled on your device. Your device must be rooted first.
Click to expand...
Click to collapse
I make and init.d script and i copy your custom values to my init.d script. However, on net speed tweaks, the tcp_rmem and tcp_wmem didn't change the value at all even i edited it. Any help?
Should it be in text file or script file?
So we create a different text document containing each code for each tweak?? Not all In one document in the init.d folder??
Nice write up, bro. Thanks. Will have to try.
Guys so why aren't these enhancing tweaks and buildprop tweaks already available in our phones? Why aren't our phones optimized?
Tweaks good for one person or situation are not necessarily optimal for every case in general .
Medyredy said:
Guys so why aren't these enhancing tweaks and buildprop tweaks already available in our phones? Why aren't our phones optimized?
Click to expand...
Click to collapse
Can you help please?
Hello, I'm a newbie here. I wish to overclock my stock kernal, So it can be done through tweak? or I have to compile new overclock kernal from stock kernal source? Their's already a overclocked kernal for my device but its for cm11 and i want to use it on 4.1.2 JB stock ROM. Is their any simple way out?
Your help will be appreciated. Thanks .
use cm11 for s7392 or try
cm12 new developed
or stock i did give it to you before
choice is yours.......
i no longer have this device
rony raj said:
use cm11 for s7392 or try
cm12 new developed
or stock i did give it to you before
choice is yours.......
i no longer have this device
Click to expand...
Click to collapse
Thanks for suggesting new Cm12 kernal.
As of cm11, X264 encoding is important for me, plus their were some other minor bugs in that build. Though i agree its the best build compiled rom for Trend.
I will myself start some project after June~July.
What happened to your device though? You are among the few members who are guiding peoples on threads related to this device and i really appreciate it.

Categories

Resources