[Tutorial]Sysctl and you, A guide to better preformance and battery life.

Jboxen

Premium Member
Premium Member
Developer
Joined
Jun 15, 2010
Messages
902
Reaction score
0
Location
Rochester, NY
[UPDATED FINAL]
First off I would like to say I have gotten all of my information for this mod here: imoseyon I would also like to thank the developer for posting all of his findings and for all of his hard work.

Changing all kernel tweaked values and an auto flush via flashing a .zip file:

Imoseyon was nice enough to make us all a flashable .zip file which makes all tweaks for us :). Thank you Imoseyon!!!

Due to the amount of times Imoseyon updates his zip I will from now on just be directing you to his site. Check back now and then to see if there is an update available.

http://www.imoseyon.com


Enabling Sysctl and changing (most) values via LIberty Settings (Update Liberty Toolbox in market and it will work)

Sysctl Support: Check
Min Free KBytes: 4096
Dirty Ratio: 90
Dirty Background Ratio: 70
VFS Cache Pressure: 1
Oom Allocating Task: Check

Reboot your phone, go to the terminal emulator and type in:

sysctl -a | grep vm


Note: This will not give you all of the mods that are available, if you want the remaining mods, continue down to the next methods.

If your settings have been saved using the App and you don't want the additional mods, then you are all done! Thanks Jrummy! Make sure you scroll down to the bottom of the post and read the IMPORTANT section as it applies to every version of this mod.

Edit: The NEWEST version of Liberty Toolbox fixes the bugs but if you're also running Droid Overclock then read below.



Enabling Sysctl and changing (most) values via Jrummy's Droid Overclock App
Note: If you have this and are running Liberty, you will have to change the settings in Droid Overclock too as the Liberty settings will be over-written.

Jrummy has released an update to Droid Overclock, v.2.0.2. So go to the market and update it if you haven't already. Open up his Droid Overclock app and press Menu>Settings>Advanced Settings. Scroll down until you see Sysctl and do the following.

Sysctl Support: Check
Min Free KBytes: 4096
Dirty Ratio: 90
Dirty Background Ratio: 70
VFS Cache Pressure: 1
Oom Allocating Task: Check

Reboot your phone, go to the terminal emulator and type in:

sysctl -a | grep vm

This version of Jrummy's Sysctl enabler and editor has worked for me so he must have squashed the bugs. Thanks Jrummy!

Note: This will not give you all of the mods that are available, if you want the remaining mods, continue down to the next methods.

Enabling Sysctl and changing values via Root Explorer

So now onto the next step, enabling and changing the values manually. First off we should start by enabling sysctl. This can be done with root explorer...
Open up root explorer and go to /data/liberty and mount the system RW. Long press on init.d.config and open it in the text editor. Now scroll down until you find SYSCTL and set that from 0 to 1.
Sysctl is now enabled.

Note: If for whatever reason you would like to disable this later on just use the backup file it created to do so.

Now to set the values that Sysctl will be changing, also done with root explorer. This will be done in the /etc folder. Navigate yourself to the /etc folder and see if you already have a sysctl.conf. If not, click the menu softkey and then click more>new file. Name this new file sysctl.conf . Mount the system RW now and open the file in the text editor again. Now type exaclty these lines into the file. (It's ok to delete what's there if anything and replace it with this.)


vm.swappiness = 0
vm.min_free_kbytes = 4096
vm.dirty_ratio = 90
vm.dirty_background_ratio = 70
vm.vfs_cache_pressure = 1
vm.panic_on_oom = 2
vm.oom_kill_allocating_task = 1
kernel.panic = 5
kernel.shmmax = 2268435456
kernel.shmall = 16777216


Save it and you can erase the backup that it creates as there is no original file.

Now reboot your phone and open your terminal up. Type in this command again:

sysctl -a | grep vm

You should see your settings have been applied and are working as intended. If you see any errors, go back to the file and make sure you typed everything into sysctl.conf correctly. (There will be 2 permission denied errors at the very bottom when typing in this command but they aren't important.)



Enabling Sysctl and changing values via VI commands

After mounting the system RW, going in to terminal emulation, at the prompt:

vi /data/liberty/init.d.conf

Now, vi is an old school text editor so you have to maneuver around using the following keys because we have no cursor keys in droid:

j = move cursor down one line
k = move cursor up one line
h = move cursor right one character
l = mover cursor left one character

Right now you are in vi's command mode. This allows you to move around and issue commands like save, undo, quit, etc.

Find the line that says:

SYSCTL=0

Move the cursor so it is sitting right on top of 0 and press r which means to replace the character underneath the cursor and type 1.

Save the file and quit back to the prompt by typing :wq (you will actually see this command typed at the bottom of the editor)

Once back at the prompt, to edit the other config file:

vi /etc/sysctl.conf

If was easier for me to delete all the lines in there and type everything in so typing dd deletes one line at a time.

Once all the lines are deleted, press i which means start inserting at the cursor. This puts you into edit mode in vi. Type in the following lines as detailed by Jboxen in his post:

vm.swappiness = 0
vm.min_free_kbytes = 4096
vm.dirty_ratio = 90
vm.dirty_background_ratio = 70
vm.vfs_cache_pressure = 1
vm.panic_on_oom = 2
vm.oom_kill_allocating_task = 1
kernel.panic = 5
kernel.shmmax = 2268435456
kernel.shmall = 16777216

Once you are done, we need to get back into command mode by press ESC. Since the keyboard doesn't support the ESC key, we need to change a setting in terminal emulation. Hit the menu button | Preferences | Control key. I changed mine to be Vol Down. Pressing Vol Down and then 1, gets me back to command mode. Type in :wq to save and quit.

After that reboot, go back into terminal emulation, check your work by typing:

sysctl -a | grep vm

If you screw up editing your files at any point and want to abandon your changes in vi, press ESC (in my settings it's Vol Down and then "1"), and type in ":q!" (minus quotes obviously)

Anyways, you can find more info on vi commands here.

Thank you to freezyfreaky for these instructions. :)


IMPORTANT: "after a day or two your device may start getting sluggish because the amount of RAM available to the applications continue to shrink to the point where they are starved for memory."

Note: If you chose the flashable .zip method then this is done for you automatically at 1AM PST and you don't need to read this.

There's two solutions to this really, and they are very easy.

1. Reboot your phone when you wake up and take it off the charger in the morning.(easy)
2. Run this script in terminal emulator when you wake up in the morning:

sync; echo 3 > /proc/sys/vm/drop_caches

"Tells the system to drop all file system caches"

**REVERTING BACK TO STOCK**

1) revert build.prop file
2) delete /etc/init.d/99imoseyon.



Now if you want to know why this works and what it does I would suggest following the link at the top of the page because he can explain it much better than I can. He also has so many more cool things that he has experimented with. I recomend reading it all.

Well, there you go! Enjoy guys this is a great mod and should make the Communitty very happy! :)

Disclaimer: I am not responisble for anything that happens to your phone as a result of this mod, anything you do to your device is your responsibility.
 
Last edited:

thebird36

Member
Joined
Oct 31, 2010
Messages
410
Reaction score
1
Location
New York
when you do the sysctl -a | grep vm how would i get the straight line because i cant go into symbols
EDIT: unless its the button in the top left corner with the line and arrow
 
OP
Jboxen

Jboxen

Premium Member
Premium Member
Developer
Joined
Jun 15, 2010
Messages
902
Reaction score
0
Location
Rochester, NY
when you do the sysctl -a | grep vm how would i get the straight line because i cant go into symbols
EDIT: unless its the button in the top left corner with the line and arrow

You'll need to use the onscreen keyboard for that symbol.
 

thebird36

Member
Joined
Oct 31, 2010
Messages
410
Reaction score
1
Location
New York
well i got it all done the phone seems to move faster which is a good sign i'll let you know later tonite on how the battery was i'm not going to be using it a whole lot since i have other things to do tonite
btw i was in rochester last week =) at montage music hall last saturday
 
OP
Jboxen

Jboxen

Premium Member
Premium Member
Developer
Joined
Jun 15, 2010
Messages
902
Reaction score
0
Location
Rochester, NY
I found the increase in battery life a lot more noticable than the increased prefomance. You'll see :)
 

jrummy16

Premium Member
Premium Member
Developer
Theme Developer
Joined
Jan 25, 2010
Messages
1,211
Reaction score
0
Location
Orange County, CA
Updated the toolbox in the android market.. bugs with sysctl should be fixed. If they are not shoot me a pm or something.
 
OP
Jboxen

Jboxen

Premium Member
Premium Member
Developer
Joined
Jun 15, 2010
Messages
902
Reaction score
0
Location
Rochester, NY
[UPDATED 2.2]
First off I would like to say I have gotten all of my information for this mod here: imoseyon I would also like to thank the developer for posting all of his findings and for all of his hard work.

Enabling Sysctl and changing (most) values via LIberty Settings (Update Liberty Toolbox from the market and it will work.)

Sysctl Support: Check
Min Free KBytes: 4096
Dirty Ratio: 90
Dirty Background Ratio: 70
VFS Cache Pressure: 1
Oom Allocating Task: Check

Reboot your phone, go to the terminal emulator and type in:

sysctl -a | grep vm


Note: This will not give you all of the mods that are available, if you want the remaining mods, continue down to the next methods.

If your settings have been saved using the App and you don't want the additional mods, then you are all done! Thanks Jrummy! Make sure you scroll down to the bottom of the post and read the IMPORTANT section as it applies to every version of this mod.

Edit: The NEWEST version of Liberty Toolbox fixes the bugs but if your also running Droid Overclock then read below.



Enabling Sysctl and changing (most) values via Jrummy's Droid Overclock App
Note: If you have this and are running Liberty, you will have to change the settings in Droid Overclock too as the Liberty settings will be over-written.

Jrummy has released an update to Droid Overclock, v.2.0.2. So go to the market and update it if you haven't already. Open up his Droid Overclock app and press Menu>Settings>Advanced Settings. Scroll down until you see Sysctl and do the following.

Sysctl Support: Check
Min Free KBytes: 4096
Dirty Ratio: 90
Dirty Background Ratio: 70
VFS Cache Pressure: 1
Oom Allocating Task: Check

Reboot your phone, go to the terminal emulator and type in:

sysctl -a | grep vm

This version of Jrummy's Sysctl enabler and editor has worked for me so he must have squashed the bugs. Thanks Jrummy!

Note: This will not give you all of the mods that are available, if you want the remaining mods, continue down to the next methods.



Enabling Sysctl and changing values via Root Explorer

So now onto the next step, enabling and changing the values manually. First off we should start by enabling sysctl. This can be done with root explorer...
Open up root explorer and go to /data/liberty and mount the system RW. Long press on init.d.config and open it in the text editor. Now scroll down until you find SYSCTL and set that from 0 to 1.
Sysctl is now enabled.

Note: If for whatever reason you would like to disable this later on just use the backup file it created to do so.

Now to set the values that Sysctl will be changing, also done with root explorer. This will be done in the /etc folder. Navigate yourself to the /etc folder and see if you already have a sysctl.conf. If not, click the menu softkey and then click more>new file. Name this new file sysctl.conf . Mount the system RW now and open the file in the text editor again. Now type exaclty these lines into the file. (It's ok to delete what's there if anything and replace it with this.)


vm.swappiness = 0
vm.min_free_kbytes = 4096
vm.dirty_ratio = 90
vm.dirty_background_ratio = 70
vm.vfs_cache_pressure = 1
vm.panic_on_oom = 2
vm.oom_kill_allocating_task = 1
kernel.panic = 5
kernel.shmmax = 2268435456
kernel.shmall = 16777216


Save it and you can erase the backup that it creates as there is no original file.

Now reboot your phone and open your terminal up. Type in this command again:

sysctl -a | grep vm

You should see your settings have been applied and are working as intended. If you see any errors, go back to the file and make sure you typed everything into sysctl.conf correctly. (There will be 2 permission denied errors at the very bottom when typing in this command but they aren't important.)



Enabling Sysctl and changing values via VI commands

After mounting the system RW, going in to terminal emulation, at the prompt:

vi /data/liberty/init.d.conf

Now, vi is an old school text editor so you have to maneuver around using the following keys because we have no cursor keys in droid:

j = move cursor down one line
k = move cursor up one line
h = move cursor right one character
l = mover cursor left one character

Right now you are in vi's command mode. This allows you to move around and issue commands like save, undo, quit, etc.

Find the line that says:

SYSCTL=0

Move the cursor so it is sitting right on top of 0 and press r which means to replace the character underneath the cursor and type 1.

Save the file and quit back to the prompt by typing :wq (you will actually see this command typed at the bottom of the editor)

Once back at the prompt, to edit the other config file:

vi /etc/sysctl.conf

If was easier for me to delete all the lines in there and type everything in so typing dd deletes one line at a time.

Once all the lines are deleted, press i which means start inserting at the cursor. This puts you into edit mode in vi. Type in the following lines as detailed by Jboxen in his post:

vm.swappiness = 0
vm.min_free_kbytes = 4096
vm.dirty_ratio = 90
vm.dirty_background_ratio = 70
vm.vfs_cache_pressure = 1
vm.panic_on_oom = 2
vm.oom_kill_allocating_task = 1
kernel.panic = 5
kernel.shmmax = 2268435456
kernel.shmall = 16777216

Once you are done, we need to get back into command mode by press ESC. Since the keyboard doesn't support the ESC key, we need to change a setting in terminal emulation. Hit the menu button | Preferences | Control key. I changed mine to be Vol Down. Pressing Vol Down and then 1, gets me back to command mode. Type in :wq to save and quit.

After that reboot, go back into terminal emulation, check your work by typing:

sysctl -a | grep vm

If you screw up editing your files at any point and want to abandon your changes in vi, press ESC (in my settings it's Vol Down and then "1"), and type in ":q!" (minus quotes obviously)

Anyways, you can find more info on vi commands here.

Thank you to freezyfreaky for these instructions. :)

IMPORTANT: "after a day or two your device may start getting sluggish because the amount of RAM available to the applications continue to shrink to the point where they are starved for memory."

There's two solutions to this really, and they are very easy.

1. Reboot your phone when you wake up and take it off the charger in the morning.(easy)
2. Run this script in terminal emulator when you wake up in the morning:

echo 3 > /proc/sys/vm/drop_caches

"Tells the system to drop all file system caches"



Now if you want to know why this works and what it does I would suggest following the link at the top of the page because he can explain it much better than I can. He also has so many more cool things that he has experimented with. I recomend reading it all.

Well, there you go! Enjoy guys this is a great mod and should make the Communitty very happy! :)

Disclaimer: I am not responisble for anything that happens to your phone as a result of this mod, anything you do to your device is your responsibility.
 
Last edited:

EagleStrike

Member
Joined
Mar 3, 2010
Messages
98
Reaction score
1
It would be really nice to divide it up into sections. A giant wall of text is very intimidating and can be very hard to read.
 
Top