[MOD](UPDATED) For those with battery issues - Samsung Galaxy SL i9003

please dont forget to thank
loSconosciuto
ilcorsaronero
PureMotive
credits to loSconosciuto for modifying this mod to our galaxy sl and most especially to ilcorsaronero for the modification and for making the universal cwm flashable zip for our device
ilcorsaronero said:
Since noone was updating it, I provide a working flashable zip basing on this mod. There were more than one problem in the zip, but now I fixed them. Please report:
* if you notice a battery performance improvement
* how much is this improvement
* which MOD are you on
* which KERNEL are you on. This mod works only on init.d featured mod/kernels.
thanks.
Flash this through CWM recovery!
Click to expand...
Click to collapse
link to cwm flashable zip file
http://forum.xda-developers.com/showpost.php?p=25536103&postcount=27
original thread of this mod
credits to PureMotive
PureMotive said:
Okay guys, I just thought I'd give you my mod for achieving good-great battery life. This is the mod I use in Anthem™ which has given me 50+ hours on a single charge. Feel free to include it in your own ROM or whatever. Giving credit would be nice
First: Here is a flashable .zip of the mod that may or may not work with your ROM. I'd still advise doing it manually.
Sysctl.conf​
Step 1
Open up your ROM.zip (or whatever it's called) in 7zip (Windows) or Betterzip (OSX) and locate
sysctl.conf in /system/etc
If it's not in this directory, create it.
Step 2
In your sysctl.conf file, paste the following code and save it.
Code:
#sysctl.conf file
fs.nr_open=1053696;
fs.inotify.max_queued_events=32000;
fs.inotify.max_user_instances=256;
fs.inotify.max_user_watches=10240;
fs.lease-break-time=10;
fs.file-max=165164;
kernel.threads-max=525810;
kernel.random.write_wakeup_threshold=256;
kernel.random.read_wakeup_threshold=128;
kernel.panic=5;
kernel.sched_compat_yield=1;
kernel.panic=0;
kernel.panic_on_oops=1;
kernel.msgmni=2048;
kernel.msgmax=64000;
kernel.shmmni=4096;
kernel.shmall=2097152;
kernel.shmmax=268435456;
kernel.sem='500 512000 64 2048';
kernel.sched_features=24189;
kernel.hung_task_timeout_secs=30;
kernel.sched_latency_ns=18000000;
kernel.sched_min_granularity_ns=1500000;
kernel.sched_wakeup_granularity_ns=3000000;
kernel.sched_shares_ratelimit=256000;
kernel.sched_child_runs_first=0;
fs.lease-break-time=10;
fs.file-max=65536;
net.core.wmem_max=524288;
net.core.rmem_max=524288;
net.core.rmem_default=262144;
net.core.wmem_default=262144;
net.core.optmem_max=20480;
net.unix.max_dgram_qlen=50;
net.ipv4.tcp_keepalive_time=900;
net.ipv4.tcp_keepalive_probes=5;
net.ipv4.tcp_keepalive_intvl=156;
net.ipv4.tcp_timestamps=0;
net.ipv4.tcp_sack=1;
net.ipv4.tcp_fack=1;
net.ipv4.tcp_window_scaling=1;
net.ipv4.tcp_tw_recycle=1;
net.ipv4.tcp_tw_reuse=1;
net.ipv4.tcp_congestion_control=cubic;
net.ipv4.tcp_syncookies=1;
net.ipv4.conf.all.rp_filter=1;
net.ipv4.conf.default.rp_filter=1;
net.ipv4.tcp_synack_retries=2;
net.ipv4.tcp_syn_retries=2;
net.ipv4.tcp_max_syn_backlog=1024;
net.ipv4.tcp_max_tw_buckets=16384;
net.ipv4.icmp_echo_ignore_all=1;
net.ipv4.icmp_ignore_bogus_error_responses=1;
net.ipv4.tcp_no_metrics_save=1;
net.ipv4.tcp_fin_timeout=15;
net.ipv4.tcp_keepalive_intvl=30;
net.ipv4.tcp_keepalive_probes=5;
net.ipv4.tcp_keepalive_time=1800;
net.ipv4.ip_forward=0;
net.ipv4.conf.default.accept_source_route=0 ;
net.ipv4.conf.all.accept_source_route=0;
net.ipv4.conf.all.accept_redirects=0;
net.ipv4.conf.default.accept_redirects=0;
net.ipv4.conf.all.secure_redirects=0;
net.ipv4.conf.default.secure_redirects=0;
net.ipv4.udp_rmem_min=6144;
net.ipv4.udp_wmem_min=6144;
net.ipv4.tcp_rfc1337=1;
net.ipv4.ip_no_pmtu_disc=0;
net.ipv4.tcp_ecn=0;
net.ipv4.route.flush=1;
net.ipv4.tcp_rmem='6144 87380 524288';
net.ipv4.tcp_wmem='6144 87380 524288';
net.ipv6.conf.default.use_tempaddr=2;
net.ipv6.conf.all.use_tempaddr=2;
net.ipv6.conf.all.temp_prefered_lft=3600;
net.ipv6.conf.default.temp_prefered_lft=3600;
vm.dirty_ratio=90;
vm.dirty_background_ratio=80;
vm.oom_kill_allocating_task=1;
vm.overcommit_memory=1;
vm.page-cluster=3;
vm.drop_caches=3;
vm.min_free_kbytes=4096;
vm.panic_on_oom=0;
vm.dirty_expire_centisecs=1000;
vm.dirty_writeback_centisecs=2000;
vm.oom_kill_allocating_task=0;
vm.vfs_cache_pressure=10;
vm.min_free_order_shift=4;
vm.laptop_mode=0;
vm.block_dump=0;
Step 3
Now we need to enable it. So, navigate to /system/etc/init.d and create a file with the following code:
Code:
#!/system/bin/sh
# grep sysctl /etc/init.d/*
# Load /sys/etc/sysctl.conf
sysctl -p
sysctl -p is what initializes the code.
Just FYI: You don't actually need these lines:
Code:
# grep sysctl /etc/init.d/*
Code:
# Load /sys/etc/sysctl.conf
So this would have just sufficed.
Code:
#!/system/bin/sh
sysctl -p
If the above code does not work for any reason, try this:
Code:
#!/system/bin/sh
sysctl -p /system/etc/
Name your file something like this 10sysctl
Save your file.
NOTE: Your ROM must support init.d. You can do this by using dsixda's android kitchen
Step 4
Save your ROM and install it via recovery
OR
you could just push the files into your current ROM and try them out.
----------- For knowledge -----------​
Credits to imoseyon for portions of the info​
Ok, so what exactly is sysctl.conf?
The sysctl.conf is a configuration file for "sysctl" which is an interface for dynamically changing kernel parameters in the Linux OS. The configuration file contains the following elements, vm.min_free_kbytes, vm.dirty_ratio, vm.dirty_backgroud_ratio, vm.vfs_cache_pressure, vm.oom_kill_allocating_task. There are many other elements within the file, but we will be primarily focusing on these specifically (the vm prefix stands for virtual memory). The sysctl.conf file should be located in /etc (/system/etc) by default. To enable it you need your ROM to execute "sysctl -p" somewhere during the boot process (or shortly afterward). We will also be discussing how to enable it if it is not already done so. You can also run sysctl -p manually to enable it any time after the OS is started.
Now, let’s get down to what sysctl.conf does and how it works.
min free kbytes (vm.min_free_kbytes)
This is used to force the Linux VM to keep a minimum number of kilobytes free. The VM uses this number to compute a pages_min value for each lowmem zone in the system. Each lowmem zone gets a number of reserved free pages based proportionally on its size. Default is 2048kb.
dirty ratio (vm.dirty_ratio) and dirty background ratio (vm.dirty_background_ratio)
This controls how often the kernel writes data to "disk" (in our case the internal microSD system card, not the removable microSD card). When your apps write data to disk, Linux actually doesn't write the data out to the disk right away, it actually writes the stuff to system memory and the kernel handles when and how the data is actually going to be flushed to the disk. These values represent a percentage, the higher the percentage, the longer it waits to flush, the lower the percentage, the more often flushes will occur. Now remember, we are dealing with solid state storage, not the traditional disk platter and spindle. So we are actually able to delay flushes a little longer with solid state versus a traditional hard drive disk.
VFS Cache Pressure
Now here is where it gets interesting! File system cache (dentry/inode) is really more important than the block cache above in dirty ratio and dirty background ratio, so we really want the kernel to use up much more of the RAM for file system cache, this will increas the performance of the system without sacrificing performance at the application level. The default value is 100, as a percentage, and what you want to do is lower the value to tell the kernel to favor the file system cache and not drop them aggressively.
oom allocating task (vm.oom_kill_allocating_task)(enable or disable, generally in Linux this value is either a "1" or a "0," representing as on or off.)
This enables or disables killing the OOM-triggering task in out-of-memory (oom) situations. If this is set to zero, or disabled, the OOM killer will scan through the entire task list and select a task based on heuristics to kill. This normally selects a rogue memory-hogging task that frees up a large amount of memory when killed. If this is set to non-zero, or enabled, the OOM killer simply kills the task that triggered the out-of-memory condition. This avoids the expensive task list scan, which can take mass amounts of time and "hang" or freeze the system.
block_dump (vm.block_dump)
This enables block I/O debugging when set to a nonzero value. If you want to find out which process caused the disk to spin up (see /proc/sys/vm/laptop_mode), you can gather information by setting the flag.
When this flag is set, Linux reports all disk read and write operations that take place, and all block dirtyings done to files. This makes it possible to debug why a disk needs to spin up, and to increase battery life even more. The output of block_dump is written to the kernel output, and it can be retrieved using "dmesg". When you use block_dump and your kernel logging level also includes kernel debugging messages, you probably want to turn off klogd, otherwise the output of block_dump will be logged, causing disk activity that is not normally there.
overcommit_memory (vm.overcommit_memory)
This controls overcommit of system memory, possibly allowing processes to allocate (but not use) more memory than is actually available.
0 - Heuristic overcommit handling. Obvious overcommits of address space are refused. Used for a typical system. It ensures a seriously wild allocation fails while allowing overcommit to reduce swap usage. root is allowed to allocate slighly more memory in this mode. This is the default.
1 - Always overcommit. Appropriate for some scientific applications.
2 - Don't overcommit. The total address space commit for the system is not permitted to exceed swap plus a configurable percentage (default is 50) of physical RAM. Depending on the percentage you use, in most situations this means a process will not be killed while attempting to use already-allocated memory but will receive errors on memory allocation as appropriate.
page-cluster (vm.page-cluster)
This controls the number of pages which are written to swap in a single attempt. The swap I/O size.
It is a logarithmic value - setting it to zero means "1 page", setting it to 1 means "2 pages", setting it to 2 means "4 pages", etc.
The default value is three (eight pages at a time). There may be some small benefits in tuning this to a different value if your workload is swap-intensive.
panic_on_oom (vm.panic_on_oom)
This enables or disables panic on out-of-memory feature. If this is set to 1, the kernel panics when out-of-memory happens. If this is set to 0, the kernel will kill some rogue process, by calling oom_kill().
Usually, oom_killer can kill rogue processes and system will survive. If you want to panic the system rather than killing rogue processes, set this to 1.
The default value is 0.
Panic is a system error that is detected by the kernel.
dirty_expire_centisecs (vm.dirty_expire_centisecs)
How old "dirty" data should be before the kernel considers it old enough to be written to disk. It is expressed in 100ths of a second.
dirty_writeback_centisecs (vm.dirty_writeback_centisecs)
This is the interval of when the writeback daemons periodically wake up and write "old" data out to disk. It is expressed in 100ths of a second.
Click to expand...
Click to collapse
source:
http://forum.xda-developers.com/showthread.php?t=1621808

i use juice defender...with okayish usage, i got 3 days and 1 hour(1 time thing).....with my normal usage i get 24+ hours......
would have given this a try had there been just a .zip file

it comes with a zip file but flash at your own risk
Code:
http://www.androidfilehost.com/main/Incredible_Developers/PureMotive/Mods/Universal/Sysctl-conf.zip
i just saw this thread and see it really interesting as we all love longer battery life
it was classified as universal but i have not flashed file yet and am hoping first feedbacks about this from developers in our phone model

noypi_ako said:
it comes with a zip file but flash at your own risk
Code:
http://www.androidfilehost.com/main/Incredible_Developers/PureMotive/Mods/Universal/Sysctl-conf.zip
i just saw this thread and see it really interesting as we all love longer battery life
it was classified as universal but i have not flashed file yet and am hoping first feedbacks about this from developers in our phone model
Click to expand...
Click to collapse
I cannot flash it (status 0) in my MIUI 10.5...

tomjoad2 said:
I cannot flash it (status 0) in my MIUI 10.5...
Click to expand...
Click to collapse
Replace the meta-inf folder with the one in your rom zip file
Cheers
Sent from my GT-i9003 powered by Stable and Smooth CleanKpu rom

I had problems installing the zip on UC kernel stock rom. Nonetheless the kind of hack proposed in this mod should work here as well. It makes sense. Is anyone able to fix it?

it was mentioned by the developer that the best to do it is manually
and that custom rom developers can implement it on their roms

Those having status 0 error: replace the meta-inf folder in the flashable zip with the one in your rom
Cheers
Sent from my GT-i9003 powered by Stable and Smooth CleanKpu rom

bscraze said:
Those having status 0 error: replace the meta-inf folder in the flashable zip with the one in your rom
Cheers
Sent from my GT-i9003 powered by Stable and Smooth CleanKpu rom
Click to expand...
Click to collapse
thanks...done, but now I get error (status 7)
tryng to do it manually

i think it would be best if we hear feedbacks first from our kernel/rom developers of i9003

Even though sysctl.conf accepts ";", it breaks the conf file and sysctl can't parse it.
Use this instead:
http://pastebin.com/raw.php?i=3tDgbmG3
EDIT:
This file is simply the one in the OP without ";".
FYI some of its values overwrite the values used by kernel developers.
EDIT 2:
And without single quotes.

loSconosciuto said:
Even though sysctl.conf accepts ";", it breaks the conf file and sysctl can't parse it.
Use this instead:
http://pastebin.com/raw.php?i=3tDgbmG3
Click to expand...
Click to collapse
Done manually... but when I try to review with sysctl -a| grep vm cannot see any changes

tomjoad2 said:
Done manually... but when I try to review with sysctl -a| grep vm cannot see any changes
Click to expand...
Click to collapse
Sorry, I didn't notice the single quotes in sysctl.conf
File updated (same link).

loSconosciuto said:
Sorry, I didn't notice the single quotes in sysctl.conf
File updated (same link).
Click to expand...
Click to collapse
Still nothing...maybe sysctl -p cannot activate the script...

tomjoad2 said:
Still nothing...maybe sysctl -p cannot activate the script...
Click to expand...
Click to collapse
deeper part of the first post
developer said if this dont work
Code:
#!/system/bin/sh
sysctl -p
then try this
Code:
#!/system/bin/sh
sysctl -p /system/etc/

tomjoad2 said:
Still nothing...maybe sysctl -p cannot activate the script...
Click to expand...
Click to collapse
It should work. Maybe you don't have /etc, but only /system/etc (/etc is just a symlink)
If you run
Code:
sysctl -p
you should get as output the content of sysctl.conf
If you get
Code:
sysctl: /etc/sysctl.conf: No such file or directory
Try with
Code:
sysctl -p /PATH/TO/THE/FILE/sysctl.conf
Where /PATH/TO/THE/FILE/ is, of course, the path to sysctl.conf,

noypi_ako said:
deeper part of the first post
developer said if this dont work
Code:
#!/system/bin/sh
sysctl -p
then try this
Code:
#!/system/bin/sh
sysctl -p /system/etc/
Click to expand...
Click to collapse
This is what I get
and when a write sysctl -p then ---> sysctl: short write

tomjoad2 said:
This is what I get
and when a write sysctl -p then ---> sysctl: short write
Click to expand...
Click to collapse
i believe loSconosciuto is highly qualified for this one
many thanks to him for looking into this mod

Code:
ls -l /proc/sys/net/ipv4/route/flush
--w------- 1 root root 0 Apr 28 14:26 /proc/sys/net/ipv4/route/flush
That means no one can read the content of this file, even 'root'. That's why you get
Code:
sysctl: error reading key 'net.ipv6.route.flush': Permission denied
sysctl: error reading key 'net.ipv4.route.flush': Permission denied
sysctl tries to read it, but it can't.
tomjoad2 said:
This is what I get
and when a write sysctl -p then ---> sysctl: short write
Click to expand...
Click to collapse
Are you sure your sysctl.conf is correct? Did you remove all the ";" and "'"?

loSconosciuto said:
Code:
ls -l /proc/sys/net/ipv4/route/flush
--w------- 1 root root 0 Apr 28 14:26 /proc/sys/net/ipv4/route/flush
That means no one can read the content of this file, even 'root'. That's why you get
Code:
sysctl: error reading key 'net.ipv6.route.flush': Permission denied
sysctl: error reading key 'net.ipv4.route.flush': Permission denied
sysctl tries to read it, but it can't.
Are you sure your sysctl.conf is correct? Did you remove all the ";" and "'"?
Click to expand...
Click to collapse
would it work if we chmod 644 those file?

Related

Tweak Android for Performance, and increase battery by Saving Power Usage with Sysctl

Here I will post tweaks as I find them to optimize Android.
When echoing in the following sysctl settings they do not remain after reboot, so we can adb remount then create a sysctl.conf file on our pc's with these settings, then ./adb push sysctl.conf /etc/ then the kernel should apply the settings every reboot
For examples of a sysctl.conf use google: Sysctl.conf Examples
Open a Terminal and Execute these commands as root
Tweak virtual memory to conserve power when running on battery:
Code:
echo 0 > /proc/sys/vm/swappiness #can be ignored if you dont use swap
echo 0 > /proc/sys/vm/dirty_expire_centisecs #can be ignored if you dont use swap
echo 0 > /proc/sys/vm/dirty_writeback_centisecs #can be ignored if you dont use swap
echo 60 > /proc/sys/vm/dirty_background_ratio
echo 95 > /proc/sys/vm/dirty_ratio
Tweak virtual memory for running on Charger
Code:
echo 0 > /proc/sys/vm/swappiness #can be ignored if you dont use swap
echo 3000 > /proc/sys/vm/dirty_expire_centisecs #can be ignored if you dont use swap
echo 500 > /proc/sys/vm/dirty_writeback_centisecs #can be ignored if you dont use swap
echo 10 > /proc/sys/vm/dirty_background_ratio
echo 40 > /proc/sys/vm/dirty_ratio
Detecting apps/services that hog the battery/cpu:
Also while on battery, you should stop all applications that don't really stay idle when you're not using them, if you want to find which apps arent really staying idle you can:
Code:
strace -p $(pidof yourapp) # for all your running applications
ps aux | awk '{print$10,$11}' | sort -n # will list all running softs sorted by used cpu time
By default when Linux runs out of memory it goes through the process list and starts killing off processes that it thinks are using too much memory. This sysctl makes Linux kill the runaway process that made the system run out of memory instead, which is usually what you want.(this will also reduce cpu time and increase battery usage).
Code:
sysctl -w vm.oom_kill_allocating_task=1
Credit: ccpp0
vfs_cache_pressure to 10 , gives more mem to cache fs dentry and inode to save cpu
At the default value of vfs_cache_pressure = 100 the kernel will attempt to reclaim dentries and inodes at a "fair" rate with respect to pagecache and swapcache reclaim. Decreasing vfs_cache_pressure causes the kernel to prefer to retain dentry and inode caches. Increasing vfs_cache_pressure beyond 100 causes the kernel to prefer to reclaim dentries and inodes.
Code:
sysctl -w vm.vfs_cache_pressure=10
I'll be adding more tweaks for sysctl and basic cmd line tweaks as I find them, also these tweaks would be good integrated into roms, apps, and a power-save widget if anyone wants to get creative.
a few questions
do i enter this into the terminal emulator? also does this only need to be entered in one time? thank you in advance for any help.
great find.. will keep my eye on this thread
david1171 said:
do i enter this into the terminal emulator? also does this only need to be entered in one time? thank you in advance for any help.
Click to expand...
Click to collapse
yes you can enter it in via terminal emulator or ./adb shell, the echo'd settings are not permanent and will reset after reboot, so use the settings to test, then follow the directions to create a /etc/sysctl.conf file to make the settings permanent after you feel comfortable with the settings(if you notice improvement)
defcon
Wow, this is cool, thank you!
Could you maybe add some more comments, I don't really understand what the single commands do. Or some place, where the function of e.g. "dirty_expire_centisecs" is explained?
One more precise question though: If I don't have a swap file on sd, does the tweaking of the swappiness still change anything?
Greetings!
free-sidux said:
Wow, this is cool, thank you!
Could you maybe add some more comments, I don't really understand what the single commands do. Or some place, where the function of e.g. "dirty_expire_centisecs" is explained?
One more precise question though: If I don't have a swap file on sd, does the tweaking of the swappiness still change anything?
Greetings!
Click to expand...
Click to collapse
there is no swap space on G1, so settings related to the swap can be ignored.
echo 0 > /proc/sys/vm/dirty_expire_centisecs
echo 0 > /proc/sys/vm/dirty_writeback_centisecs
never writes out dirty pages ?
free-sidux said:
Wow, this is cool, thank you!
Could you maybe add some more comments, I don't really understand what the single commands do. Or some place, where the function of e.g. "dirty_expire_centisecs" is explained?
One more precise question though: If I don't have a swap file on sd, does the tweaking of the swappiness still change anything?
Greetings!
Click to expand...
Click to collapse
http://tinyurl.com/nlb9ws
Note: The value of vm.swappiness=0 states that no swap space will be used at all, basically it can be ignored if you dont use swap though
defconoi said:
http://tinyurl.com/nlb9ws
Note: The value of vm.swappiness=0 states that no swap space will be used at all, basically it can be ignored if you dont use swap though
Click to expand...
Click to collapse
set vfs_cache_pressure to 10 , gives more mem to cache fs dentry and inode to save cpu "wa".
how do i create a Sysctl.conf file with this script?
i tried the link of examples but all i could find was info about it.
everything else works but when i try
sysctl vm.block_dump=1
i get sysctl: error: 'vm.block_dump=1' is an unknown key
any ideas?
actually ya know what I think we can just disable sysctl all together in menuconfig->Filesystems->Pseudo Filesystems->Proc->Sysctl Support when compiling a new kernel and setting these tweaks right in the kernel.
Says in menuconfig"As it is generally a good thing, you should say Y here unless
building a kernel for install/rescue disks or your system is very
limited in memory."
So I think we can gain some memory disabling this since we dont really need it
disable /dev/mem
Also I think we can disable the Memory Device Driver, /dev/mem, it says it can be disabled for security conscious and can be disabled on memory tight systems, which we are definitely memory tight plus there's just no valid app that uses /dev/mem on actual memory.
Other popular users of /dev/mem are rootkits and the like.
(note: mmap access of memory via /dev/mem was already not allowed since
a really long time)
People who want to use /dev/mem for kernel debugging can enable the config
option.
tshizzle said:
how do i create a Sysctl.conf file with this script?
i tried the link of examples but all i could find was info about it.
everything else works but when i try
sysctl vm.block_dump=1
i get sysctl: error: 'vm.block_dump=1' is an unknown key
any ideas?
Click to expand...
Click to collapse
I have the same exact questions that u do
Unix98_ptys
Also do we really need UNIX98_PTYS enabled?
We can also use this to conserve memory if we dont need this as well...
menuconfig says:
"Unix98 PTY support UNIX98_PTYS
A pseudo terminal (PTY) is a software device consisting of two
halves: a master and a slave. The slave device behaves identical to
a physical terminal; the master device is used by a process to
read data from and write data to the slave, thereby emulating a
terminal. Typical programs for the master side are telnet servers
and xterms.
Linux has traditionally used the BSD-like names /dev/ptyxx for
masters and /dev/ttyxx for slaves of pseudo terminals. This scheme
has a number of problems. The GNU C library glibc 2.1 and later,
however, supports the Unix98 naming standard: in order to acquire a
pseudo terminal, a process opens /dev/ptmx; the number of the pseudo
terminal is then made available to the process and the pseudo
terminal slave can be accessed as /dev/pts/<number>. What was
traditionally /dev/ttyp2 will then be /dev/pts/2, for example.
All modern Linux systems use the Unix98 ptys. Say Y unless
you're on an embedded system and want to conserve memory."
jroid said:
I have the same exact questions that u do
Click to expand...
Click to collapse
ahhhh it looks vm.block_dump=1 isnt a valid sysctl option, disregard that, gonna remove it from the first post
defconoi said:
ahhhh it looks vm.block_dump=1 isnt a valid sysctl option, disregard that, gonna remove it from the first post
Click to expand...
Click to collapse
yea. all the other ones work though. how would we make the file??
jroid said:
yea. all the other ones work though. how would we make the file??
Click to expand...
Click to collapse
adb remount
create sysctl.conf on your system
then adb push sysctk.conf /etc and the settings will be set every reboot.
defconoi said:
adb remount
create sysctl.conf on your system
then adb push sysctk.conf /etc and the settings will be set every reboot.
Click to expand...
Click to collapse
ok so it would be something like this?
adb remount
adb shell
mkdir /system/sysctl.conf
adb push sysctl.conf /system/etc
jroid said:
ok so it would be something like this?
adb remount
adb shell
mkdir /system/sysctl.conf
adb push sysctl.conf /system/etc
Click to expand...
Click to collapse
no, adb push sysctl.conf /etc
this isn't working. i created the dir sysctl.conf in /system then tried adb pushing it but says no such file or dir. then i tried in adb shell cp /system/sysctl.conf /etc
it says cp: omitting sysctl.conf is a directory"
couldnt i just create it directly in /etc?
like this mkdir /system/etc/sysctl.conf
defconoi said:
no, adb push sysctl.conf /etc
Click to expand...
Click to collapse
on android /etc is within the /system/etc directory.

[MOD] One stop for tweaks and other useful cool stuff

ok, from my android tweaking and playing around with all kinds of settings and other things i know it can be somewhat hard to find everything you might need to make the most of your android device so i will put links to them here along with providing support and my own little discoveries here...if anyone knows anything else that is cool or useful just post it and i'll update this post (btw these are tested on droid 1 only but many may apply to most android devices)
*Anyone who knows of any other tweaks/mods/scripts/useful terminal commands please feel free to post and i'll add it here (after testing it if possible)*
***disclaimer- I am not responsible for any damage you may do to your device, please make sure to have a backup before doing any of these tweaks***
first off how about a simple rooting/returning to stock guide?
quick root guide
1)download these files
http://www.motorola.com/staticfiles/Support/Experiences/Global_Drivers/MotoHelper_2.0.40_Driver_4.9.0.exe
http://wonderly.com/bb/DROID/OEM/rsdlite_5.0.msi
http://wonderly.com/bb/DROID/OEM/VZW_A855_QSC6085BP_RZRECOVERY_UPDATE.sbf
http://wonderly.com/bb/DROID/OEM/update.zip
2)install the first 2 links in order
3)connect your phone via usb to your computer and copy the update.zip you downloaded to your sdcard
4)reboot your phone and hold power + vloume up + the camera button until you see the screen that says bootloader battery ok
5)open rsd lite and see if it recognizes your phone (basically any entry in the model column) and slide your phone keyboard open
6) click the ... near the start button and navigate and select the VZW_A855_QSC6085BP_RZRECOVERY_UPDATE.sbf file
7)click start and WATCH FOR "Phone[0000]: Phone is being rebooted" On your phone the screen will change to "SW Update Complete" and your phone will reboot within a second or two. You want to be already holding the x button on your keyboard to boot into recovery mode when the phone actually reboots so the stock OS doesnt erase the new recovery you just flashed
8) using the volume keys to move through the menu, the camera button to select and the power button to go back, go to install and select the update.zip you put on your sdcard earlier and select install update.zip
9) then select "reboot into android" and enjoy the benefits of being rooted
return to stock
1)download these files
http://www.motorola.com/staticfiles...al_Drivers/MotoHelper_2.0.40_Driver_4.9.0.exe
http://wonderly.com/bb/DROID/OEM/rsdlite_5.0.msi
http://wonderly.com/bb/DROID/OEM/VZW_A855_FRG22D_QSC6085BP_C_01.43.01P_SW_UPDATE.sbf
2)install the first 2 files
3)reboot your phone and hold power + vloume up + the camera button until you see the screen that says bootloader battery ok
4)connect your phone via usb to your computer and reboot your phone and hold power + vloume up + the camera button until you see the screen that says bootloader battery ok
5)open rsd lite and see if it recognizes your phone (basically any entry in the model column)
here are are some useful build.prop tweaks I've encountered along the way, just put the line into the build.prop or modify it if its already in there, save, wipe dalvik cache and reboot
6) click the ... near the start button and navigate and select the VZW_A855_FRG22D_QSC6085BP_C_01.43.01P_SW_UPDATE.sb f you downloaded earlier
7)click start and let it run and reboot automatically (it should work even if rsd lite says the result was fail)
8) you are now on stock unrooted froyo
FRG22D
(optional) 9) go to settings > about phone> check for updates and allow system updates to download and install (allows for a super clean setup if you are planning to re-root)
for possibly better scrolling speed, can be set to any number from 35-300:
# This defines the max event window manager can
# handle in 1 s. We may adjust this # for performance
# reason later
windowsmgr.max_events_per_sec=
change lcd density (already in build.prop), which is like changing the resolution on a windows computer can be anywhere from 140 to 260 (under 200 not recommended because everything may be too small for the phone to be usable:
ro.sf.lcd_density=
dalvik cache virtual memory size (already in build.prop)...can also help performance. set anywhere from 24m to 64m based on how complex your setup is. i.e. tons of apps, in depth theme, memory intensive apps, etc.
dalvik.vm.heapsize=
incoming ringer delay (already in build.prop) sets how soon the phone starts ringing when a call comes in. set between 0 and 2000
ro.telephony.call_ring.delay=
proximity delay. sets how long before screen turns off during call. set between 0 and 600
# Proximit sensor screen off delay
mot.proximity.delay=
tcp stack- optimizes data performance
net.tcp.buffersize.default=4096,87380,256960,4096, 16384,256960
net.tcp.buffersize.wifi=4096,87380,256960,4096,163 84,256960
net.tcp.buffersize.umts=4096,87380,256960,4096,163 84,256960
net.tcp.buffersize.gprs=4096,87380,256960,4096,163 84,256960
net.tcp.buffersize.edge=4096,87380,256960,4096,163 84,256960
enable hardware acceleration
# Render UI through GPU instead of CPU
# Comment out if this causes laggy UI (it should speed up UI)
debug.sf.hw=1
sleep mode for battery savings. 0 means power collapse suspend, 1 is power collapse (usually the best choice), 2 is apps go to sleep, 3 is show clock and wait, 4 is wait for interrupt...not sure which each one does or is good for, just know about this little tweak lol
# Battery Savings (Sleep Mode)
pm.sleep_mode=
more battery savings
# When moving through zones or losing signal, having a delay
# smooths out constant disconnects and reconnects, which in turn
# saves a ton of battery life!
ro.mot.eri.losalert.delay=1000
disable sending usage data
ro.config.nocheckin=1
wifi scan interval (already in build.prop) can save battery as well. set from 15 to 999
# Time between scans in seconds. Keep it high to minimize battery drain.
# This only affects the case in which there are remembered access points,
# but none are in range.
wifi.supplicant_scan_interval=
ok, now for some useful links (all credit goes to the creators of these cool tweaks/apps/programs
v6 supercharger by zepplinrox - http://forum.xda-developers.com/showpost.php?p=18703418&postcount=5021
Deodex/odex tweak by Nibras, Reeza & Danzano (thanks to BrUhNiGGs for finding this) - http://www.droidforums.net/forum/steel-droid/200388-ram-tweak-free-up-more-ram-make-apps-load-faster.html
setcpu for free (legitimately legal lol) - http://forum.xda-developers.com/showthread.php?t=505419
wifi tethering app Downloads - http://code.google.com/p/android-wifi-tether/downloads/list
wired tethering app Downloads - http://code.google.com/p/android-wired-tether/downloads/list
easy install of adb http://www.droidforums.net/forum/chevyno1/162984-your-1-adb-source-7-29-11-a.html
Guide to building a rom from source (credit to chevycam and SnkBitten) - http://www.droidforums.net/forum/steel-droid/196475-guide-how-build-your-own-rom-cm7-source.html
Ok, here's a new section with just general tips, tricks and scripts
Useful terminal emulator scripts run as superuser (su)
*Using the debugging logging to report issues
Code:
logcat > /mnt/sdcard/logcat.txt
wait 4-5 seconds then hold volume up and press f on the keyboard to stop it
if logcat is disabled then do this instead
Code:
dmesg > /mnt/sdcard/dmesg.txt
wait 4-5 seconds then hold volume up and press f on the keyboard to stop it
*Find top CPU/memory using apps. value after -m is how many apps to show, value after -n is how many times to update (be sure to set this value or it will run endlessly until terminal is closed)
Code:
top -m 10 -n 1
*Find md5sum for downloaded files (checks to ensure proper downloads especially for roms, just compare your result to whatever value the rom developer provides and they should match)
Code:
md5sum /mnt/sdcard/(file path on sdcard)
For example
Code:
md5sum /mnt/sdcard/download/SD_9.0.0.zip
*Use swap partition without swapper2.
Add this script to the end of any file in the /etc/init.d folder. If you don't have one just run it in terminal emulator each reboot and run it in terminal first since sometimes its mmcblk0p2 instead of mmcblk0p3 depending on where you have the swap partition (or use the app script manager to make it run at boot. Script manager doesn't run continuously like swapper2)
Code:
swapon /dev/block/mmcblk0p3
And to turn swap off
Code:
swapoff /dev/block/mmcblk0p3
*Setting swappiness
Add or edit this line in the file etc/sysctl.config using whatever value you want, just keep the spaces (open in text editor)
vm.swappiness = 30
Or add this to the end of a script in init.d or run in terminal emulator
Code:
sysctl -w vm.swappiness=30
*Loading a module for apps2sdext (link2sd style apps2sd)
Run this in terminal emulator with superuser permission, substituting ext3 for whatever extension you want loaded (keep the .ko though)
Code:
insmod /system/lib/modules/ext3.ko
or the simple way
Code:
modprobe ext3
*Listing loaded modules
Run this in terminal emulator with superuser permissions
Code:
lsmod
*Forcing a hot reboot to clear caches
Run this in terminal emulator with superuser permissions
Code:
pkill zygote
*terminal tips-
Find list of many possible scripts to run
Code:
busybox
List sysctl commands
Code:
sysct -h
List first or last 10 lines of another scripts output (note | is not lower case L, its a separate character)
First 10-
Code:
(script) | head
Last 10
Code:
(script) | tail
Example (list first 10 sysctl values)
Code:
sysctl -a | head
Finding lines with certain letters/word in another scripts output
Code:
(script) | grep (letters/word)
Example (show only sysctl lines with vm in them) (note | is not lower case L, its a separate character)
Code:
sysctl -a | grep vm
Don't worry more to come soon
Ok, those are the well tested tweaks, now for a few experimental ones. Please make sure to have a backup ready to restore since these ARE experimental and may cause your rom not to load
improve peformance?
Add this to the build.prop
#disable the zygote loader
ro.wmt.blcr.enable=0
Fix app issues? (change it to 0 to improve performance)
Add this to build.prop
ro.kernel.android.checkjni=1
Change the I/O scheduler (effects how your phone reads and writes data)(first line tells you whats available and what you currently have in [ ], then put whichever one you want in the "" after echo, and the last line will confirm the change)
Code:
cat /sys/block/*/queue/scheduler
for i in /sys/block/*/queue/scheduler
do
echo "deadline" > $i
done
cat /sys/block/*/queue/scheduler
Increse overall touch resposivness?
Add these to build.prop
debug.performance.tuning=1
video.accelerate.hw=1
ro.min_pointer_dur=8
Raise Photo and video quality?
Add these to build.prop
ro.media.enc.jpeg.quality=100
ro.media.dec.jpeg.memcap=8000000
ro.media.enc.hprof.vid.bps=8000000
change sdcard buffer speed
run in terminal emulator as superuser (su) or put #!/system/bin/sh as first line and put in /system/etc/init.d (you can change the value in the "echo 512 > /sys/devices/virtual/bdi/179:0/read_ahead_kb" line to suit your needs- common values are 256, 512, 1024, 2048, 3072, 4096, 5120, 6144)
Code:
for i in /sys/devices/virtual/bdi/*
do
echo 2 > $i/read_ahead_kb
done
echo 2048 > /sys/devices/virtual/bdi/179:0/read_ahead_kb
echo 2 > /sys/devices/virtual/bdi/default/read_ahead_kb
or you can try just simply using the simple version
Code:
echo 2048 > /sys/devices/virtual/bdi/179:0/read_ahead_kb
Disable boot animation
add to build.prop (use caution after wiping dalvik, it will appear to hang at the M but its usually still booting up all the way)
dev.sfbootcomplete=0
Use dalvik JIT compiler
add to build.prop (Just In Time compiler is much faster)
dalvik.vm.execution-mode=int:jit
Improve performance?
change in build.prop
ro.setupwizard.mode=DISABLED
Rom dependent tweaks (will only work if these features are included in your rom and most are included in settings anyway, most of the time they are but if not sure then ask the dev) add these to build.prop, 1 is on 0 is off
help to free up unused ram-
persist.sys.purgeable_assets=
stop usb debugging on notification-
persist.adb.notify=
Force capacitive buttons to stay on while screen is on?-
ro.mot.buttonlight.timeout=
Improve screen quality at the cost of performance-
persist.sys.use.dithering=
*reserved*
**reserved**
and one more just in case
***reserved***
btw, i hope i posted this right, I'm still new here to xda forums, i hope i posted in the right section too...if not then someone can go ahead move it (if possible)
Nice collection!
Say, do you have anything specific to CDMA bandwidth?
I know my 3G TurboCharger has a positive effect somehow even though most of the entries are GSM related but hey... every bit helps
zeppelinrox said:
Nice collection!
Say, do you have anything specific to CDMA bandwidth?
I know my 3G TurboCharger has a positive effect somehow even though most of the entries are GSM related but hey... every bit helps
Click to expand...
Click to collapse
not sure if any of these would apply to data at all but i know kfazz posted them as the only ril settings for the droid, maybe this could further improve speed on all devices if anything applies to mobile data
Moto ril sholes accepted properties found via strings
persist.ril.mux.timeout.enbld
persist.ril.enableradio.powerup
persist.ril.uart.flowctrl
persist.ril.mux.noofchannels
persist.ril.mux.ttydevice
persist.ril.mux.retries
persist.ril.mux.sleep
persist.ril.mux.logmask
persist.ril.rssi.enable.param6
persist.ril.modem.ttydevice
persist.ril.pppd.start.fail.max
ro.ril.ecclist
ro.ril.barcode
ro.build.id
/data/data/com.motorola.motoapr.service/paniclogging
/data/misc/ril/ril_apr.log
Click to expand...
Click to collapse
Ok I guess those are boolean values soget either = 0 or =1 values then?
Well that's weird.. I didn't know there are ro.cdma values...
http://pastebin.com/LWWcSMTD
zeppelinrox said:
Ok I guess those are boolean values soget either = 0 or =1 values then?
Well that's weird.. I didn't know there are ro.cdma values...
http://pastebin.com/LWWcSMTD
Click to expand...
Click to collapse
i searched for ro.cdma and found some others too
ril.cdma.ppp.up=3
ro.radio.use-ppp=yes
net.cdma.ppp-exit=0
cool... maybe you can test them see if you notice a difference?
zeppelinrox said:
cool... maybe you can test them see if you notice a difference?
Click to expand...
Click to collapse
I'll try it out but it I'll try it on something where the radio fully works lol, is still being fixed on the ics build but obviously I have to go back to gingerbread to make and receive calls, if it does anything on GB, then I'll test on ics, who knows it might fix the radio issues somehow
A friend of mine just asked me to root his old droid for him to use merely as a multimedia (music & video) and google docs device. Strictly Wifi, no service plan.
i plan on rooting, wiping, and running SteelDroid on it for him:
http://forum.xda-developers.com/showthread.php?t=1098483
I came across these tweaks and they look AWESOME. I just have a few questions about some of them in particular.
metalspring said:
for possibly better scrolling speed, can be set to any number from 35-300:
# This defines the max event window manager can
# handle in 1 s. We may adjust this # for performance
# reason later
windowsmgr.max_events_per_sec=
Click to expand...
Click to collapse
Is this in the build.prop or elsewhere?
metalspring said:
tcp stack- optimizes data performance
net.tcp.buffersize.default=4096,87380,256960,4096, 16384,256960
net.tcp.buffersize.wifi=4096,87380,256960,4096,163 84,256960
net.tcp.buffersize.umts=4096,87380,256960,4096,163 84,256960
net.tcp.buffersize.gprs=4096,87380,256960,4096,163 84,256960
net.tcp.buffersize.edge=4096,87380,256960,4096,163 84,256960
Click to expand...
Click to collapse
where do i find and change these? build.prop or elsewhere?
metalspring said:
enable hardware acceleration
# Render UI through GPU instead of CPU
# Comment out if this causes laggy UI (it should speed up UI)
debug.sf.hw=1
disable sending usage data
ro.config.nocheckin=1
Click to expand...
Click to collapse
in build.prop?
metalspring said:
Useful terminal emulator scripts run as superuser (su)
*Use swap partition without swapper2.
Add this script to the end of any file in the /etc/init.d folder. If you don't have one just run it in terminal emulator each reboot (or use the app script manager to make it run at boot. Script manager doesn't run continuously like swapper2)
swapon /dev/block/mmcblk0p3
And to turn swap off
swapoff /dev/block/mmcblk0p3
*Setting swappiness
Add or edit this line in the file etc/sysctl.config using whatever value you want, just keep the spaces (open in text editor)
vm.swappiness = 30
Or add this to the end of a script in init.d or run in terminal emulator
sysctl -w vm.swappiness=30
*Loading a module for apps2sdext (link2sd style apps2sd)
Run this in terminal emulator with superuser permission, substituting ext3 for whatever extension you want loaded (keep the .ko though)
insmod /system/lib/modules/ext3.ko
Click to expand...
Click to collapse
Can i make 2 scripts in script manager that can do this? or are there any available? I know on such a low ram & low internal storage device, swap and apps2sdext would be INCREDIBLY useful.. any tips on making this permanent? If i can make a script in SM i know i can set it start at boot. But i wouldn't need to do that for a2sdext right? once that's set, it's set and needs no changes right?
Also, would you suggest a custom rom like steeldroid or would i be better off stripping out the crapware from the stock ota rom (froyo) and just flashing a better compatible kernel and using some tweaks & scripts to speed things up a bit and optimize them for his purposes.
Let me know what you think?
thanks!
Originally Posted by metalspring
for possibly better scrolling speed, can be set to any number from 35-300:
# This defines the max event window manager can
# handle in 1 s. We may adjust this # for performance
# reason later
windowsmgr.max_events_per_sec=
Click to expand...
Click to collapse
Is this in the build.prop or elsewhere?
Originally Posted by metalspring
tcp stack- optimizes data performance
net.tcp.buffersize.default=4096,87380,256960,4096, 16384,256960
net.tcp.buffersize.wifi=4096,87380,256960,4096,163 84,256960
net.tcp.buffersize.umts=4096,87380,256960,4096,163 84,256960
net.tcp.buffersize.gprs=4096,87380,256960,4096,163 84,256960
net.tcp.buffersize.edge=4096,87380,256960,4096,163 84,256960
Click to expand...
Click to collapse
where do i find and change these? build.prop or elsewhere?
Originally Posted by metalspring
enable hardware acceleration
# Render UI through GPU instead of CPU
# Comment out if this causes laggy UI (it should speed up UI)
debug.sf.hw=1
disable sending usage data
ro.config.nocheckin=1
Click to expand...
Click to collapse
in build.prop?
Originally Posted by metalspring
Useful terminal emulator scripts run as superuser (su)
*Use swap partition without swapper2.
Add this script to the end of any file in the /etc/init.d folder. If you don't have one just run it in terminal emulator each reboot (or use the app script manager to make it run at boot. Script manager doesn't run continuously like swapper2)
swapon /dev/block/mmcblk0p3
And to turn swap off
swapoff /dev/block/mmcblk0p3
*Setting swappiness
Add or edit this line in the file etc/sysctl.config using whatever value you want, just keep the spaces (open in text editor)
vm.swappiness = 30
Or add this to the end of a script in init.d or run in terminal emulator
sysctl -w vm.swappiness=30
*Loading a module for apps2sdext (link2sd style apps2sd)
Run this in terminal emulator with superuser permission, substituting ext3 for whatever extension you want loaded (keep the .ko though)
insmod /system/lib/modules/ext3.ko
Click to expand...
Click to collapse
Can i make 2 scripts in script manager that can do this? or are there any available? I know on such a low ram & low internal storage device, swap and apps2sdext would be INCREDIBLY useful.. any tips on making this permanent? If i can make a script in SM i know i can set it start at boot. But i wouldn't need to do that for a2sdext right? once that's set, it's set and needs no changes right?
Also, would you suggest a custom rom like steeldroid or would i be better off stripping out the crapware from the stock ota rom (froyo) and just flashing a better compatible kernel and using some tweaks & scripts to speed things up a bit and optimize them for his purposes.
Let me know what you think?
thanks!
Click to expand...
Click to collapse
to the first 4 yes, just add them to the build.prop and for the last ones you can either use script manager to make a new script in the folder /system/etc/init.d
if you dont have an init.d folder then you have to have script manager to run them at boot (i'd suggest having the scripts in /data) and for apps2sdext, i'd suggest using the app link2sd, its basically the only way to control moving apps to the sdcard ext
also the biggest help for low ram devices is v6 supercharger and all the other zeppelinrox scripts
http://forum.xda-developers.com/showpost.php?p=18703418&postcount=5021
and i'd highly highly suggest steeldroid 10, its what i currently run and most of the tweaks i have in this thread are already included in it
and btw if you didnt know, in order to use swap and link2sd you have to format your sdcard and repartition it, the easiest way is installing rom manager, flashing clockwork recovery and there should be an option to partition your sdcard in rom manager (it will erase everything on your sdcard so back everything up)
also i'm going to update this thread with more stuff i've found
updated and cleaned up op
awesome! thanks! yea i know about partitioning the sdcard. I use both swap and a2ext on my htc g2, but they are part of the kernel on the ROM i run, i've never used any other software to initiate them.
Thanks for the tips!
Also, how can ANYONE flash roms from XDA and NOT know about the AMAZING supercharger v6 script!
first of all I want to thank the OP! being how this is not my phone but my brothers. he wants me to root it and install a rom. this thread made everything a whole lot simple.
now to bug you guys.. where can I find a suitable system recovery apk for this phone? I have one installed but it never boots into recovery. also I haz steel droid 10 running.
Sent from my DROID X2 using XDA App
motrinHD said:
first of all I want to thank the OP! being how this is not my phone but my brothers. he wants me to root it and install a rom. this thread made everything a whole lot simple.
now to bug you guys.. where can I find a suitable system recovery apk for this phone? I have one installed but it never boots into recovery. also I haz steel droid 10 running.
Sent from my DROID X2 using XDA App
Click to expand...
Click to collapse
if you're talking about a droid 1 then the instructions to root should install a custom recovery
If you're talking about a droid x2 as your signature suggests then I'd say try looking on droidforums.net... They are more dedicated to the droid series of android phones and I know any Motorola phone other than the droid 1 is more complicated because of a locked bootloader
You can try downloading rom manager to flash a recovery for either phone I believe
Also if you are already rooted and think you have a working recovery then try installing android terminal emulator from the market and typing in
su
reboot recovery
metalspring said:
if you're talking about a droid 1 then the instructions to root should install a custom recovery
If you're talking about a droid x2 as your signature suggests then I'd say try looking on droidforums.net... They are more dedicated to the droid series of android phones and I know any Motorola phone other than the droid 1 is more complicated because of a locked bootloader
You can try downloading rom manager to flash a recovery for either phone I believe
Also if you are already rooted and think you have a working recovery then try installing android terminal emulator from the market and typing in
su
reboot recovery
Click to expand...
Click to collapse
I am talking about the droid 1. tho I spf'd to 2.2 I then went with the one click root method. and it placed a system recovery apk on my sd but I find that it does not work. I'm going to try that emulator thing you suggested
Sent from my DROID X2 using XDA App
metalspring said:
to the first 4 yes, just add them to the build.prop and for the last ones you can either use script manager to make a new script in the folder /system/etc/init.d
if you dont have an init.d folder then you have to have script manager to run them at boot (i'd suggest having the scripts in /data) and for apps2sdext, i'd suggest using the app link2sd, its basically the only way to control moving apps to the sdcard ext
also the biggest help for low ram devices is v6 supercharger and all the other zeppelinrox scripts
http://forum.xda-developers.com/showpost.php?p=18703418&postcount=5021
and i'd highly highly suggest steeldroid 10, its what i currently run and most of the tweaks i have in this thread are already included in it
and btw if you didnt know, in order to use swap and link2sd you have to format your sdcard and repartition it, the easiest way is installing rom manager, flashing clockwork recovery and there should be an option to partition your sdcard in rom manager (it will erase everything on your sdcard so back everything up)
also i'm going to update this thread with more stuff i've found
Click to expand...
Click to collapse
MS,
I have learned alot from your posts. Thanks for the time spent sharing them. A few questions.
You mention and I have noticed many of the tweaks are already incorporated into Steel Droid X. (I am currently running the rc1 version with the last Deprimed Kernel.) Am am liking it ALOT!!.
Is there anyway you could somehow put a denotion on the tweaks that are already included in SDX? I think it would be helpful, as I certainly would find it so.
How much of a effect did you find running v6 supercharger had given the other changes already in SDX? Any conflicts or issues running it with this ROM?
I am planning on partitioning my SD card as I would like to try the benefits of a swap partition. Upon checking my usage I am considering a 128mb. Seems like a safe size all around. Believe you have posted this somewhere as well? Card is a 32g class 4. I have never messed with running a swap. Currently, I have a standard single FAT32 format part. I have a number of programs already set as loaded on the SD card so I will have to move those back.
I believe SDX has apps2sdext already, correct?
From your post I take I still need links2sd to have the apps to go to that swap partition?
Is there a good link to info on the hows, workings, etc on the swap partition, apps works? I can search for one, only if you happen to have a link handy.
Thanks for all your help.
BE

[SCRIPT][UPDATED 01.26.14] Enable Ram Swap & Create a Swap File with |=~>SwapItOn<~=|

[SCRIPT][UPDATED 01.26.14] Enable Ram Swap & Create a Swap File with |=~>SwapItOn<~=|
##### Added Minfree Option #####​
Hi, thanks for checking out my thread and your interest in…
Defiant07’s Super Stupendous & Splendid SwapItOn Script.
Now that I have blatantly lied and oversold things, let me explicitly state that I am new to android, in general, and to bash, especially, so I know the code is far from elegant and efficient. This is my first public script so devs don’t laugh too hard and please offer any suggestions. Now on to the good stuff…
Click to expand...
Click to collapse
What will this script do?
It will do three things: (1) it will create up to three swap files that are a sizes specified by the user [note: user also has choices for swap file locations]; (2) it will create an init.d script that enables ram swap and sets the swappiness level to a user specified value during each boot process; and (3) it will create 'shift' scripts so as to facilitate turning swap on/off, changing swappiness on the fly, and changing other swap related parameters on the fly.
Click to expand...
Click to collapse
What are the requirements?
root access
busybox: version does not matter so long as it has the following required applets - awk, cat, chmod, clear, cut, dd, df, echo, free, grep, id, mkdir, mkswap, mount, nohup, ps, rm, sed, sleep, swapoff, swapon, sysctl, tee, tr.
init.d support (if you don’t have it search XDA there are a of couple of apps and numerous scripts that add this feature)
a kernel capable of swap (to check if swap is supported in terminal enter
Code:
cat /proc/cpuinfo
and under ‘features’ you should see ‘swp’ or ‘swap’)
storage named “/mnt/sdcard” as opposed to /sdcard0 or something else from v3 forward the script is compatible with most storage locations/mount points
note: one of the benefits of the method deployed by this script is that it does NOT require a special partition
Click to expand...
Click to collapse
Disclaimer & Warning:
Although this script works as it should on my device I am not responsible for bootloops, bricks, bad big booty b*tches, or the imminently impending zombie apocalypse. Furthermore, please perform due diligence and do some research about the costs and benefits of ram swap before using this script. In addition, please use good practice and make a nandroid backup before making any changes to your system.
Click to expand...
Click to collapse
Usage:
Option 1 - Make a nandroid backup. Download the attached “swapit_[NOT_FLASHABLE]_v13” zip, extract it wherever you want it, and run the script with root/superuser permission in ScriptManager or a similar app, although I have found other apps lacking/deficient. Read the script’s output/follow the script’s instructions, reboot, and you’ll be good to go. Note: Users without an actual external sdcard may have to use /data to avoid swapon/swapoff errors. Should users choose to use a custom location this may result in swapon/swapoff errors and I will NOT respond to posts regarding such.
Option 2 - Make a nandroid backup. Download the attached “Defiant07s_SwapItOn_v13” zip and install it via cwm, reboot, and in a terminal emulator input
Code:
su
swapit
or
Code:
su -c swapit
. Read the script’s output/follow the script’s instructions, reboot, and you’ll be good to go. Note: Users without an actual external sdcard may have to use /data to avoid swapon/swapoff errors. Should users choose to use a custom location this may result in swapon/swapoff errors and I will NOT respond to posts regarding such.
Connecting to PC via USB in Storage Mode - To avoid possible problems use one of the two commands to turn swap off, which are listed below in the uninstall procedure, before connecting to your pc via usb in storage mode.
Uninstall - First in terminal enter
Code:
swapoff <swapfile location>
or
Code:
su -c swapitoff
; example of swapfile location: /sdcard/swapfile. Now you can delete the “swapfile” and “swappinessvalue” files located in where you chose to put them (e.g. /sdcard, /sdcard0, or /data) as well as the “Z99SwapOn” script located in /etc/init.d and the “swapit” script located wherever you put it or in /system/xbin if you flashed it. Also delete "Ran_SwapOn.log" from /data and "swapiton" "swapititoff" "swap0" "swap10" "swap20" "swap30" "swap40" "swap50" "swap60" "swap70" "swap80" "swap90" and "swap100" from /system/xbin.
OR even easier from v8 forward you can do:
Code:
su -c unswapit
and this will remove everything expect the base "swapit" script and /system/xbin/unswapit.
Click to expand...
Click to collapse
Possible FAQ:
There are other apps and scripts that perform the same/similar function, why use this script?
Unlike apps there is no ram and cpu usage - it applies your settings during the boot process…basically all you need to do set it up once and then you can forget about it. Unlike all the similar scripts I’ve looked at this script takes user input for the swapfile size and swappiness value - the others use predefined sizes and values, which imo is silly since preferences and needs vary from user to user and from device to device. In addition, unlike many similar apps and scripts there is NO need for a special partition.
What is ram swap?
Swap basically uses a portion of your sdcard kinda like ram. On a more technical level, your device will keep what it can in its normal ram until it starts hitting your minfrees or even before it hits your minfrees depending on swappiness level (e.g. a swappiness of 100 will aggressively preemptively swap thing whereas a swappiness of 0 will only swap things when oom/minfree values start taking effect). Once it hits your minfrees, instead of killing stuff, or once it hits the limit determined by your other swap related settings (swappiness, pressure, etc.) it will start moving/"swapping" inactive blocks/pages of memory (i.e. background stuffs) to the swap area, which could be a file or partition (from what I have read there seems to be no performance difference between a file and partition). This frees up ram for active/foreground stuff, which is great for hard gaming imo, especially if you have a low ram device. If something that was moved/"swapped" to the swap area needs to be accessed it will be moved/"swapped" back in to normal ram.
A couple of warnings/cautions: Stuff recalled from the swap area will likely be slower than stuff recalled from normal ram. Also the constant reading and writing can degrade sdcard lifespan, but from what I have read the degradation is negligible enough that something else will break first or you will simply replace your device due to the pace of technology before the degradation is noticed.
What is swappiness and what is the best swappiness value to use?
Swappiness controls the intensity/tendency with which things are swapped. The "best" swappiness value depends on your preferences, which is why I let the user set its value.
Maybe some guidelines will help you choose what's right for you...
100 will aggressively swap things
60 is most kernels default
20 is what V6 SuperCharger sets it to
0 will swap only when oom (out of memory) takes effect (i.e. when your minfrees start kicking in)
so I guess a general rule of thumb would be...
use a value between 0-50 if you want maximize for performance (you will notice little or no lag when multitasking because less stuff will be being recalled from the swap area)
use a value between 51-100 if you want to maximize for hard gaming (you will notice some lag when starting games due to things being more aggressively swapped, but it will clear and ultimately the game will run smoother)
use this rule of thumb to guide your experimentation...hands on testing and experience are your best teachers...you can change your swappiness on the fly/without rebooting by using:
Code:
echo "XX" > /proc/sys/vm/swappiness
where XX is your desired swappiness (you can do it with or without the quotation marks). Or even easier use the 'shift' scripts that are created by v5 forward.
The init.d script seems to be running on boot being that swap is enabled, but the swappiness value I chose is not sticking?
The most likely cause of this is a conflicting init.d script. The solution is to search your other init.d scripts for “swappiness” and edit value accordingly.
Why do you give the init.d script such high priority?
I personally am a user of V6 SuperCharger (<<best script ever imo) and I found that when running this script at lower priority two things would happen: (1) minfree and adj values did not stick; and (2) logging was totally jacked up. This may not happen on your device so feel free experiment with renaming the init.d script so as to adjust its priority. Note: should you rename it and then later rerun the main “swapit” script to change your settings, upon completion you should delete the new “Z99SwapOn” script located in /etc/init.d [do not worry your new settings will still be applied by the old script] otherwise you will have duplicate scripts. From v11 forward, do NOT rename or alter the contents of Z99SwapOn. Doing so will cause the switch swap scripts to function improperly, which may have deleterious consequences.
Click to expand...
Click to collapse
For those interested in the technical details, here’s the -lt optimal code:
CODE IS NOW TOO LONG TO EMBED IN POSTS...SEE TXT ATTACHMENT IN SECOND POST
Click to expand...
Click to collapse
Changelog:
Code:
[B][I]v2[/I][/B]
[LIST]
[*]forgot a few "\", which caused minor bugs in the Ran_SwapOn.log file created by the init.d script and would cause the user's new swappiness level setting to not be applied if they renamed the old init.d script and deleted the newly created "Z99SwapOn" script following rerunning the "swapit" script
[/LIST]
[B][I]v3[/I][/B]
[LIST]
[*]now compatible with all storage names (e.g. /sdcard, /sdcard0, etc.) - thanks to [user=3357461]@zeppelinrox[/user]
[*]added precautionary check for swap capability - thanks to [user=3357461]@zeppelinrox[/user]
[*]added precautionary check for existence of /etc/init.d (note: it does not check if it's working)
[*]added precautionary check to ensure user does not make a swap file larger than the available space
[*]cleaned up code: nested log file, removed unnecessary sleep commands, and minor changes to dialog
[/LIST]
[B][I]v4[/I][/B]
[LIST]
[*]added precautionary check for swappiness value to ensure user does not input an invalid value
[*]script now calculates and suggests a recommended swap file size based upon the user's accessible ram (by which I mean the value you'd get if you navigated to settings>>apps>>running and added the XXXmb used and XXX mb free values; note: the recommended size is half this sum)
[*]cleaned up dialog: it should be more readable for users of option 2 (i.e. in terminal) and for users with smaller screens (i.e. phone users) (added a space at the beginning of each line of dialog and limited number of spaces used in each line of dialog)
[*]remove dialog saying a 0 swappiness value "would be counterproductive" - I was misinformed via a post from some other forum...I've recently read from credible sources that in linux and ubuntu a zero value will still swap things, but only when oom/minfrees are hit
[*]code should now avoid all remount related errors using marginally modified code from [URL="http://forum.xda-developers.com/showthread.php?t=991276"]V6 SuperCharger[/URL] by [user=3357461]@zeppelinrox[/user]
[/LIST]
[B][I]v5[/I][/B]
[LIST]
[*]should now be compatible with devices that lack an actual external sdcard (note: user will have no location choice and be forced to use /data) - thanks to [user=3357461]@zeppelinrox[/user]
[*]new method for detecting storage location and some optimization of code - thanks to [user=3357461]@zeppelinrox[/user]
[*]added V6 SuperCharger style 'power shift' scripts aka "Super Stupendous Switch Swap Scripts" (ahh...gotta love alliteration) for: swapon, swapoff, swappiness=0, swappiness=20, swappiness=40, swappiness=60, swappiness=80, swappiness=100
[*]improved dialog
[/LIST]
[B][I]v6[/I][/B]
[LIST]
[*]init.d script, Z99SwapOn, should no longer cause bootloops - thanks to [user=3357461]@zeppelinrox[/user] (be sure to check out post #61 for Zep's credits and thank him as well as @[URL="http://forum.xda-developers.com/member.php?u=3147360"]dk_zero-cool[/URL] and @[URL="http://forum.xda-developers.com/member.php?u=4665716"]gu5t3r[/URL])
[*]init.d script, Z99SwapOn, will now make the swap file just in case the users accidentally somehow deletes it - thanks to [user=3357461]@zeppelinrox[/user]
[*]the swappiness applied by the switch swap scripts will now be applied during all furture reboots (previously the swappiness value was only applied to the current session and swappiness would revert to whatever value was selected in swapit following a reboot) - thanks to [user=3357461]@zeppelinrox[/user]
[*]improved swap detection - thanks to [user=3357461]@zeppelinrox[/user]
[*]switch swap scripts now in incriments of 10 (swap0, swap10, swap20...etc...swap100)
[*]improved precautionary check for swappiness value - it should catch typos involving non-numeric characters
[*]swapit will now ask user if detected storage location is copasetic just in case detected location is wrong or not to the user's liking
[/LIST]
[I][B]v7[/B][/I]
[LIST]
[*]better storage detection - thanks to [user=3357461]@zeppelinrox[/user] for updated code and [user=320962]@famewolf[/user] for bug report and testing
[*]changed method of getting accessible ram - thanks to [user=3357461]@zeppelinrox[/user]
[*]changed some of the info in Ran_SwapOn.log (instead of free, it now shows the output from cat /proc/swaps...this combined with the above change eliminates the usage of free, which should be good for users of Project Xtreme)
[*]fixed permissions on the switch swap scripts that were added to the pervious version - thanks to [user=5113073]@eushaun99[/user] for bug report
[*]improved dialog of switch swap scripts (swapiton and swapitoff now tell user "it may take a minute")
[/LIST]
[I][B]v8[/B][/I]
[LIST]
[*]added option to skip making the swap file if one is already detected - thanks to [user=5113073]@eushaun99[/user] for this suggestion
[*]added option to choose custom location - thanks to [user=320962]@famewolf[/user] for this suggestion
[*]added optional tweaks for dirty_background_ratio, dirty_ratio, vfs_cache_pressure, dirty_writeback_centisecs, and dirty_expire_centisecs. (if you want to know what these parameters control read relevant descriptions from [URL="https://www.kernel.org/doc/Documentation/sysctl/vm.txt"]THIS [/URL] and pages 109-110 from [URL="http://www.redbooks.ibm.com/redpapers/pdfs/redp4285.pdf"]THIS[/URL] - the values I have chosen are intended as compromise between swap usage and ram usage - i.e. I am trying to set values that produce a reasonable level of disk writes so as to more effectively use swap, while still keeping enough stuff in ram so as to allow for smooth performance should stuff need to be quickly accessed)
[*]added switch swap script: unswapit, which will delete everything except itself and the base swapit script
[*]added closing note regarding procedure for changing swapfile location
[*]added option to skip closing notes, which I advise against if it is your first use or if you are updating...posts asking questions regarding information therein will be ignored
[*]added color
[*]improved switch swap scripts dialogs (it won't hit you all at once; added the action that has been undertaken; added note that the value will also be applied on boot)
[*]cleaned up code and other minor changes
[/LIST]
[I][B]v9[/B][/I]
[LIST]
[*]redid optional tweaks: user can choose values that are: (1) from [URL="http://forum.xda-developers.com/showthread.php?t=1556013"]ThunderBolt![/URL]; (2) a middle ground by me; or (3) from [URL="http://forum.xda-developers.com/showthread.php?p=36794328#post36794328"]KickAssKernelizer[/URL] - thanks to [user=3599329]@pikachu01[/user] for giving me permission to use some of the sysctl tweaks from [URL="http://forum.xda-developers.com/showthread.php?t=1556013"]ThunderBolt![/URL]...and, of course, thanks to [user=3357461]@zeppelinrox[/user] as well for his generous/liberal usage policies
[*]less silly/improved precautionary check for swappiness value - thanks to [user=3357461]@zeppelinrox[/user]
[*]added switch swap scripts: tweakstb, tweaksmid, and tweakskak, which apply the respective optional tweaks on the fly
[*]reworked/reordered/improved the core options
[*]added precautionary check for valid swap file size
[*]added busybox/required applet check
[*]added running as root check
[*]switched back to output from 'free' in Ran_SwapOn.log (was output from 'cat /proc/swaps'; Project Xtreme fixed/renamed its bin script)
[*]improved the displayed information: the standard out from dd, free, mkswap, and sysctl are now indented one space and added dividers to break-up the dialog into sections
[*]other minor changes
[/LIST]
[I][B]v9_fix[/B][/I]
[LIST]
[*]fixed busybox test (aliased grep) - thanks to [user=5113073]@eushaun99[/user] for bug report
[/LIST]
[I][B]v9_fix2[/B][/I]
[LIST]
[*]improved busybox/required applet check: more efficient and all applets are aliased - thanks to [user=4629194]@LENAROX[/user] for sharing [URL="https://github.com/lenarox/avcore/blob/master/avcore.sh"]THIS[/URL] with me...it heavily inspired my code, which, of course, [user=3357461]@zeppelinrox[/user] subsequently improved/made less dumb...TY TY TY.
[*]fixed root check (should work with all versions of busybox id) - thanks to [user=320962]@famewolf[/user] for bug report
[*]fixed blank count in init.d script if swapfile creation is skipped bug - thanks to [user=320962]@famewolf[/user] for bug report
[/LIST]
[I][B]v9_fix3[/B][/I]
[LIST]
[*]changed running as root check to method used in [URL="http://forum.xda-developers.com/showthread.php?t=991276"]V6 Supercharger[/URL] - thanks to [user=3357461]@zeppelinrox[/user] for code and thanks to [user=4804849]@psyntific[/user] for bug report
[*]added debugging mechanisms
[*]cleaned up code considerably: reduced redundancy by restructuring an if statement and usage of functions
[*]other minor changes
[/LIST]
[I][B]v10[/B][/I]
[LIST]
[*]added option to add an additional delay to the init.d script, Z99SwapOn: users who have switched their internal and external sdcards via the vold.fstab trick should enable this option so as to avoid potential problems caused by the actual external sdcard taking longer to mount - thanks to [user=886367]@inunxelex[/user] for bug report and testing
[*]added new, hip closing graphics...SwapItOn & SmokeItUp, lol :P
[*]other minor changes/cleaning of code
[/LIST]
[I][B]v11[/B][/I]
[LIST]
[*]redid the swapXXX switch swap scripts so as to eliminate usage of the swappinessvalue.txt file - thanks to [user=320962]@famewolf[/user] for the suggestion which inspired this solution to protecting the swappiness value
[*]due to the above change, added closing note: users should NOT rename or alter the content of the init.d script, Z99SwapOn, otherwise the swapXXX and tweaksXXX switch swap scripts will not function as intended and may even deleteriously effect Z99SwapOn
[*]tweakstb, tweaksmid, and tweakskak will now apply the respectives settings on boot in addition to the current session
[*]added new switch swap script: tweaksno (which will cause none of the optional tweaks to be applied on boot; settings in the current session will be unaltered, reboot is required to restore defaults)
[*]unswapit now actually does what is says it does...forgot the potential Boot and Debug log files
[*]other minor changes
[/LIST]
[I][B]v12[/B][/I]
[LIST]
[*]added ability to create up to three prioritized swap files - thanks to [user=4729636]@hisname[/user] for the suggestion
[*]updated subsidiary scripts in accordance with the above change
[*]made it so the user does NOT have to run 'unswapit' before rerunning main script if they want to change the location, size, or priority of the swap file(s) - thanks to [user=4729636]@hisname[/user] for the suggestion
[*]added /cache and /system as 'quick options' for swap file location
[*]added 'Function not implemented' error check
[*]added ouput from 'cat /proc/swaps' to content of /data/Ran_SwapOn.log so as to confirm the number, priority, and location/name of swap file(s)
[*]updated the precautionary check for swapfile size(s): padded it to ensure there will be at least 20 mb of free space in the swap file location(s) in order to avoid potential problems, especially if using /cache
[*]other minor changes
[/LIST]
[I][B]v12_fix[/B][/I]
[LIST]
[*]fixed r/o issue in init.d script when using /system that caused swapon error - thanks to [user=5113073]@eushaun99[/user] for bug report
[/LIST]
[I][B]v13[/B][/I]
[LIST]
[*]added minfree option - thanks to [user=3357461]@zeppelinrox[/user] for his usage policies and SuperMinFree Calculator & thanks to [user=5107949]@killoid[/user] for the suggestion/feature request
[*]added switch swap scripts: 'changeminfree' (will change minfree values on the fly and for future boots) and 'nominfree' (will cause minfree values to not be applied to future boots, but will not change values for current session)
[/LIST]
Click to expand...
Click to collapse
Credits:
Much thanks to @zeppelinrox for his numerous suggestions/contributions and for all the great tricks contained in V6 SuperCharger.
Big thanks to @pikachu01 for giving me permission to use some of the sysctl tweaks from Thunderbolt!
Many thanks to @eushaun99 for his questions, suggestions, bug reports, and testing...you have helped move this project forward and have made the OP more informative.
Thanks times two to @famewolf, @psyntific, @inunxelex, @killoid, and @hisname for their suggestions, bug reports, and testing.
Muchas gracias to @LENAROX for his general help and inspirations.
Click to expand...
Click to collapse
Please hit THANKS and give a 5 STAR rating if you found this product of my labour useful…don’t be a total free rider. Also please post any comments and suggestions. Should you want to use or redistribute this script, even in an altered form, please feel free to do so; all I ask for in return is credit...gimme my props in the form of a shout out and/or a link to this thread.
Click to expand...
Click to collapse
### Download 13. Added Minfree Option ###​
peep my other script, TrimDropOff .
Code no longer fits in posts due to character limits. Click on the txt attachment for easy, quick viewing.
Click to expand...
Click to collapse
Download History:
File Type: zip Defiant07s_SwapItOn.zip - [Click for QR Code] (593.8 KB, 60 views)
File Type: zip swapit_[NOT_FLASHABLE].zip - [Click for QR Code] (1.5 KB, 30 views)
File Type: zip Defiant07s_SwapItOn_v2.zip - [Click for QR Code] (593.8 KB, 37 views)
File Type: zip swapit_[NOT_FLASHABLE]_v2.zip - [Click for QR Code] (1.5 KB, 22 views)
File Type: zip Defiant07s_SwapItOn_v3.zip - [Click for QR Code] (594.3 KB, 48 views)
File Type: zip swapit_[NOT_FLASHABLE]_v3.zip - [Click for QR Code] (2.1 KB, 33 views)
File Type: zip Defiant07s_SwapItOn_v4.zip - [Click for QR Code] (594.5 KB, 52 views)
File Type: zip swapit_[NOT_FLASHABLE]_v4.zip - [Click for QR Code] (2.2 KB, 50 views)
File Type: zip Defiant07s_SwapItOn_v5.zip - [Click for QR Code] (595.1 KB, 54 views)
File Type: zip swapit_[NOT_FLASHABLE]_v5.zip - [Click for QR Code] (2.9 KB, 42 views)
File Type: zip Defiant07s_SwapItOn_v6.zip - [Click for QR Code] (595.7 KB, 52 views)
File Type: zip swapit_[NOT_FLASHABLE]_v6.zip - [Click for QR Code] (3.5 KB, 32 views)
File Type: zip Defiant07s_SwapItOn_v7.zip - [Click for QR Code] (595.8 KB, 140 views)
File Type: rar swapit_[NOT_FLASHABLE]_v7.rar - [Click for QR Code] (3.4 KB, 80 views)
File Type: zip Defiant07s_SwapItOn_v8.zip - [Click for QR Code] (597.5 KB, 94 views)
File Type: zip swapit_[NOT_FLASHABLE]_v8.zip - [Click for QR Code] (5.3 KB, 73 views)
File Type: zip Defiant07s_SwapItOn_v9.zip - [Click for QR Code] (598.5 KB, 15 views)
File Type: zip swapit_[NOT_FLASHABLE]_v9.zip - [Click for QR Code] (6.2 KB, 22 views)
File Type: zip Defiant07s_SwapItOn_v9_fix.zip - [Click for QR Code] (598.5 KB, 45 views)
File Type: zip swapit_[NOT_FLASHABLE]_v9_fix.zip - [Click for QR Code] (6.2 KB, 41 views)
File Type: zip Defiant07s_SwapItOn_v9_fix2.zip - [Click for QR Code] (598.5 KB, 208 views)
File Type: zip swapit_[NOT_FLASHABLE]_v9_fix2.zip - [Click for QR Code] (6.3 KB, 119 views)
File Type: zip Defiant07s_SwapItOn_v9_fix3.zip - [Click for QR Code] (598.6 KB, 80 views)
File Type: zip swapit_[NOT_FLASHABLE]_v9_fix3.zip - [Click for QR Code] (6.4 KB, 56 views)
File Type: zip Defiant07s_SwapItOn_v10.zip - [Click for QR Code] (599.3 KB, 165 views)
File Type: zip swapit_[NOT_FLASHABLE]_v10.zip - [Click for QR Code] (7.0 KB, 117 views)
File Type: zip Defiant07s_SwapItOn_v11.zip - [Click for QR Code] (600.0 KB, 793 views)
File Type: zip swapit_[NOT_FLASHABLE]_v11.zip - [Click for QR Code] (7.8 KB, 575 views)
File Type: zip Defiant07s_SwapItOn_v12.zip - [Click for QR Code] (601.7 KB, 126 views)
File Type: zip swapit_[NOT_FLASHABLE]_v12.zip - [Click for QR Code] (9.4 KB, 102 views)
Click to expand...
Click to collapse
:laugh::victory:
Nice work dude,I'm actually a fan of Karl mark's ideas
whats about sdcard life,swap decrease the life of sd,s.
-CALIBAN666- said:
whats about sdcard life,swap decrease the life of sd,s.
Click to expand...
Click to collapse
That for sure,but Class 10 SDCard support swap with no problem.
realy?class 10 lives longer then as other cards with 2-4-6?
-CALIBAN666- said:
realy?class 10 lives longer then as other cards with 2-4-6?
Click to expand...
Click to collapse
Class 10 is faster so takes less time loading temporary files for swap.
-CALIBAN666- said:
whats about sdcard life,swap decrease the life of sd,s.
Click to expand...
Click to collapse
Yeah it will degrade the life of the sdcard, which is why I advise users to perform due diligence in the Disclaimer/Warning.
But from the research I did it seems that the degradation is negligible enough that something else in the device will break before the sdcard. Or even more likely the user will replace their device due to pace of technology before the degradation is really noticed.
you never stop learning,thanx
defiant07 said:
What are the requirements?
root access
init.d support (if you don’t have it search XDA there are a of couple of apps and numerous scripts that add this feature)
a kernel capable of swap (to check if swap is supported in terminal enter
Code:
cat /proc/cpuinfo
and under ‘features’ you should see ‘swp’ or ‘swap’)
storage named “/mnt/sdcard” as opposed to /sdcard0 or something else
note: one of the benefits of the method deployed by this script is that it does NOT require a special partition
Click to expand...
Click to collapse
Click to expand...
Click to collapse
Nice... just a couple of ideas.
You can check for support with awk '/swap/||/swp/&&/eature/' /proc/cpuinfo
ie.
Code:
if [ "`awk '/swap/||/swp/&&/eature/' /proc/cpuinfo`" ]; then echo " Swapping is Supported"
else echo " No Swap for You! :p"
fi
Check the sdcard path and use the found path.
From V6...
Code:
if [ "`ls $EXTERNAL_STORAGE`" ]; then storage=${EXTERNAL_STORAGE#*mnt}
elif [ "`ls $EXTERNAL_STORAGE2`" ]; then storage=${EXTERNAL_STORAGE2#*mnt}
elif [ "`ls $USBHOST_STORAGE`" ]; then storage=${USBHOST_STORAGE#*mnt}
elif [ "`ls $SECONDARY_STORAGE`" ]; then storage=${SECONDARY_STORAGE#*mnt}
elif [ "`ls $PHONE_STORAGE`" ]; then storage=${PHONE_STORAGE#*mnt}
else storage="/sdcard"
fi 2>/dev/null
I remove the /mnt tho just to make the output look cleaner and it doesn't cause any problems anyway.
So then I use the $storage variable everywhere instead of /sdcard
zeppelinrox said:
Nice... just a couple of ideas.
You can check for support with awk '/swap/||/swp/&&/eature/' /proc/cpuinfo
ie.
Code:
if [ "`awk '/swap/||/swp/&&/eature/' /proc/cpuinfo`" ]; then echo " Swapping is Supported"
else echo " No Swap for You! :p"
fi
Check the sdcard path and use the found path.
From V6...
Code:
if [ "`ls $EXTERNAL_STORAGE`" ]; then storage=${EXTERNAL_STORAGE#*mnt}
elif [ "`ls $EXTERNAL_STORAGE2`" ]; then storage=${EXTERNAL_STORAGE2#*mnt}
elif [ "`ls $USBHOST_STORAGE`" ]; then storage=${USBHOST_STORAGE#*mnt}
elif [ "`ls $SECONDARY_STORAGE`" ]; then storage=${SECONDARY_STORAGE#*mnt}
elif [ "`ls $PHONE_STORAGE`" ]; then storage=${PHONE_STORAGE#*mnt}
else storage="/sdcard"
fi 2>/dev/null
I remove the /mnt tho just to make the output look cleaner and it doesn't cause any problems anyway.
So then I use the $storage variable everywhere instead of /sdcard
Click to expand...
Click to collapse
thats the soul of LINUX!!!!
nice work for sure, I'm a swapper myself, though i prefer swap partitioning due to old habits
my2cents: make sure your other vm settings do not conflict with the swappiness you intend to achieve (or perceive hehe). things like cache pressure and page cluster can affect the swapping, but modifying these settings in order to *achieve* swap performance is silly and risky. V6 as noted has a swappiness setting that needs override, and make sure to create a power shift profile for low minfrees - works well with zepp's multi tasking mod
Sent from my DROID BIONIC using Tapatalk 2
zeppelinrox said:
Nice... just a couple of ideas.
You can check for support with awk '/swap/||/swp/&&/eature/' /proc/cpuinfo
ie.
Code:
if [ "`awk '/swap/||/swp/&&/eature/' /proc/cpuinfo`" ]; then echo " Swapping is Supported"
else echo " No Swap for You! :p"
fi
Check the sdcard path and use the found path.
From V6...
Code:
if [ "`ls $EXTERNAL_STORAGE`" ]; then storage=${EXTERNAL_STORAGE#*mnt}
elif [ "`ls $EXTERNAL_STORAGE2`" ]; then storage=${EXTERNAL_STORAGE2#*mnt}
elif [ "`ls $USBHOST_STORAGE`" ]; then storage=${USBHOST_STORAGE#*mnt}
elif [ "`ls $SECONDARY_STORAGE`" ]; then storage=${SECONDARY_STORAGE#*mnt}
elif [ "`ls $PHONE_STORAGE`" ]; then storage=${PHONE_STORAGE#*mnt}
else storage="/sdcard"
fi 2>/dev/null
I remove the /mnt tho just to make the output look cleaner and it doesn't cause any problems anyway.
So then I use the $storage variable everywhere instead of /sdcard
Click to expand...
Click to collapse
Thanks those are great suggestions and I will implement them in the near future. I was also thinking of adding a check to make sure the user does not make the swap file larger than the space available and cleaning things up with nest files.
nitephlight said:
nice work for sure, I'm a swapper myself, though i prefer swap partitioning due to old habits
my2cents: make sure your other vm settings do not conflict with the swappiness you intend to achieve (or perceive hehe). things like cache pressure and page cluster can affect the swapping, but modifying these settings in order to *achieve* swap performance is silly and risky. V6 as noted has a swappiness setting that needs override, and make sure to create a power shift profile for low minfrees - works well with zepp's multi tasking mod
Sent from my DROID BIONIC using Tapatalk 2
Click to expand...
Click to collapse
Thanks man...those are good tips and it wouldn't be worth having if it didn't work along side zep's mods .
I was reading an article about how swap works in Linux today and it said from some kernel in 2.0.x series onwards there is no performance difference between a swap partition and swap file. Thus, since android in based on 2.6.x, I am assuming, perhaps wrongly since there was divergent development, that this lack of performance difference holds true for all versions of android.
=====
hate that 8 thanks a day thing...they should let you roll them over like phone minutes or something
Released version 3.
Major Update:
v3
now compatible with all storage names (e.g. /sdcard, /sdcard0, etc.) - thanks to @zeppelinrox
added precautionary check for swap capability - thanks to @zeppelinrox
added precautionary check for existence of /etc/init.d (note: it does not check if it's working)
added precautionary check to ensure user does not make a swap file larger than the available space
cleaned up code: nested log file, removed unnecessary sleep commands, and minor changes to dialog
Click to expand...
Click to collapse
EDIT:
Should anyone want to add a precautionary check to ensure user does not input an invalid swappiness value, you can add the following code beginning on line 74:
Code:
if [ "100" -lt "$desiredswappiness" ]; then
echo Oops...that is not a valid value...try again...Bye :p
exit 69
fi
I will add this to the next update if I find other changes that warrant a new release.
Hey @defiant07, so I tried your script, and as you know I'm new to this swap file thing. My question is, what would be the recommended swappiness value? I dunno if a too high value may degrade SD card faster, or a too low value may be useless?
Sent from my GT-P7500 using Tapatalk HD
eushaun99 said:
Hey @defiant07, so I tried your script, and as you know I'm new to this swap file thing. My question is, what would be the recommended swappiness value? I dunno if a too high value may degrade SD card faster, or a too low value may be useless?
Sent from my GT-P7500 using Tapatalk HD
Click to expand...
Click to collapse
It depends on your preferences, which is why I let the user set its value. Logically, yeah higher values would accelerate degradation.
Maybe some guidelines will help choose what's right for you...
100 will aggressively swap things
60 is most kernels default
20 is what supercharger sets it to
0 will swap only when oom (out of memory) takes effect (i.e. when your minfrees start kicking in)
so I guess a general rule of thumb would be...
use a value between 0-50 if you want maximize for performance (i.e. you will notice little or no lag when multitasking because less stuff will be being recalled from the swap area)
use a value between 51-100 if you want to maximize for hard gaming (you'll notice some lag when starting games due to things being more aggressively swapped, but it will clear and ultimately the game will run smoother)
use the rule of thumb and experiment...you can change your swappiness on the fly/without rebooting by using:
Code:
echo "XX" > /proc/sys/vm/swappiness
where XX is your desired swappiness (you can do it with or without the quotation marks). This way you don't have to rerun the swapit script and wait for the swapfile to be created.
I personally use 100 and notice very little performance difference between when swap is off and when I have it on at 100, but I have a low ram device. I think your device has a decent amount of ram (724 mb accessible ram from what I see on google) so the difference maybe more noticeable...if you do not do a lot of hard gaming or really crazy multitasking I suppose I'd say you should stick to the lower end of your preference spectrum (maybe 0-20 or 50-70).
Thanks for yet another awesome explanation.
I've read your guideline a few times to understand fully, and I decided to try a swappiness value of 40, since I do play games quite often but not a hard gamer kinda type. In your script, there were some read only file system errors and the Z99SwapOn init.d script was empty. Here are the errors:
Code:
Please wait while I create the swap file and boot script...
according to your specifications. It could take 1-5 minutes.
The required files will be created in /storage/emulated/legacy.
360+0 records in
360+0 records out
377487360 bytes transferred in 13.889 secs (27178872 bytes/sec)
Setting up swapspace version 1, size = 377483264 bytes
swapon: /storage/emulated/legacy/swapfile: Invalid argument
mkdir failed for /sqlite_stmt_journals, Read-only file system
/system/xbin/swapit[141]: can't create temporary file /sqlite_stmt_journals/mksh.GGHkBF7419: No such file or directory
BTW, I think you should put the guideline and the explanation you gave me in the tab 10.1 forum in the second post of the OP so that newbies like me can understand better and input a more reasonable swappiness value instead of banging in numbers and then say that their SD card broke or the script did nothing.
Sent from my GT-P7500 using Tapatalk HD
eushaun99 said:
Thanks for yet another awesome explanation.
I've read your guideline a few times to understand fully, and I decided to try a swappiness value of 40, since I do play games quite often but not a hard gamer kinda type. In your script, there were some read only file system errors and the Z99SwapOn init.d script was empty. Here are the errors:
Code:
Please wait while I create the swap file and boot script...
according to your specifications. It could take 1-5 minutes.
The required files will be created in /storage/emulated/legacy.
360+0 records in
360+0 records out
377487360 bytes transferred in 13.889 secs (27178872 bytes/sec)
Setting up swapspace version 1, size = 377483264 bytes
swapon: /storage/emulated/legacy/swapfile: Invalid argument
mkdir failed for /sqlite_stmt_journals, Read-only file system
/system/xbin/swapit[141]: can't create temporary file /sqlite_stmt_journals/mksh.GGHkBF7419: No such file or directory
BTW, I think you should put the guideline and the explanation you gave me in the tab 10.1 forum in the second post of the OP so that newbies like me can understand better and input a more reasonable swappiness value instead of banging in numbers and then say that their SD card broke or the script did nothing.
Sent from my GT-P7500 using Tapatalk HD
Click to expand...
Click to collapse
No problem man, I am glad to be of whatever assistance I can to you .
Although I know you're smart enough to follow directions, just to double check you are running the script as root/superuser right?
Not totally sure why you are getting that invalid argument error for the swapon command. If you look in /system/bin and /system/xbin do you see a file named "swapon" in either location? If that is missing, you'll need to install a busybox that has it. I probably should add busybox to requirements and list the needed applets. But the mkdir and the temp file errors are related to /system not being remounted rw. Without that directory and temp file it cannot make the init.d script.
Does
Code:
mount -o rw,remount /system
mount /system as rw? Also please try
Code:
busybox mount -o rw,remount /system
an lmk if that remounts /system as rw.
And since it seems to have made the swapfile in /storage/emulated/legacy try turning swap on manually
Code:
swapon /storage/emulated/legacy/swapfile
does that return an invalid argument error?
BTW - I added it as FAQ and I plan to add my response to your previous inquiry as a FAQ as well...I will update the OP when I release v4 (it's a bit smarter and will calculate your recommended swapfile size)...need to test it first and wait for your reply as I may need to call busybox or use Zep's trick where he uses like ten different remount commands.
=====EDIT=====
nvm, just try v4...I got impatient and integrated Zep's solution. Although this will likely not solve that invalid argument error so lmk the answers to the swapon related questions.
Released v4...minor update.
v4
added precautionary check for swappiness value to ensure user does not input an invalid value
script now calculates and suggests a recommended swap file size based upon the user's accessible ram (by which I mean the value you'd get if you navigated to settings>>apps>>running and added the XXXmb used and XXX mb free values; note: the recommended size is half this sum)
cleaned up dialog: it should be more readable for users of option 2 (i.e. in terminal) and for users with smaller screens (i.e. phone users) (added a space at the beginning of each line of dialog and limited number of spaces used in each line of dialog)
remove dialog saying a 0 swappiness value "would be counterproductive" - I was misinformed via a post from some other forum...I've recently read from credible sources that in linux and ubuntu a zero value will still swap things, but only when oom/minfrees are hit
code should now avoid all remount related errors using marginally modified code from V6 SuperCharger by @zeppelinrox
Click to expand...
Click to collapse
defiant07 said:
No problem man, I am glad to be of whatever assistance I can to you .
Although I know you're smart enough to follow directions, just to double check you are running the script as root/superuser right?
Not totally sure why you are getting that invalid argument error for the swapon command. If you look in /system/bin and /system/xbin do you see a file named "swapon" in either location? If that is missing, you'll need to install a busybox that has it. I probably should add busybox to requirements and list the needed applets. But the mkdir and the temp file errors are related to /system not being remounted rw. Without that directory and temp file it cannot make the init.d script.
Does
Code:
mount -o rw,remount /system
mount /system as rw? Also please try
Code:
busybox mount -o rw,remount /system
an lmk if that remounts /system as rw.
And since it seems to have made the swapfile in /storage/emulated/legacy try turning swap on manually
Code:
swapon /storage/emulated/legacy/swapfile
does that return an invalid argument error?
BTW - I added it as FAQ and I plan to add my response to your previous inquiry as a FAQ as well...I will update the OP when I release v4 (it's a bit smarter and will calculate your recommended swapfile size)...need to test it first and wait for your reply as I may need to call busybox or use Zep's trick where he uses like ten different remount commands.
=====EDIT=====
nvm, just try v4...I got impatient and integrated Zep's solution. Although this will likely not solve that invalid argument error so lmk the answers to the swapon related questions.
Click to expand...
Click to collapse
Yes, it ran as root. There is swapon, swapoff, swapit files in /system/xbin. If I'm not mistaken, the mount command should be this, right?
Code:
mount -o remount,rw /system
BTW, I set TE to run
Code:
su
mount -o remount,rw /system
automatically each time I open TE. So I actually dunno why I have those errors. I'm using busybox 1.21.1-jb bionic if it matters. Maybe I should try another busybox? Oh yeah, the swapon command did not return any invalid argument error. I'll try v4 but you'll have to wait a few hours because I'm going out soon.
Edit: I tried v4, no more read only file system errors, but there is still the invalid arguments error.
Code:
Please wait while I create the swap file and
boot script according to your specifications.
It could take 1-5 minutes.
swapoff: /storage/emulated/legacy/swapfile: Invalid argument
360+0 records in
360+0 records out
377487360 bytes transferred in 40.941 secs (9220276 bytes/sec)
Setting up swapspace version 1, size = 377483264 bytes
UUID=861e05f3-9419-49df-93cd-644256fe4600
swapon: /storage/emulated/legacy/swapfile: Invalid argument
Does the invalid argument affect anything? Because overall I'm actually noticing a definite increase in performance.
Sent from my GT-P7500 using Tapatalk HD

Init.d for Oreo - root required

I have created a mod (initd-DJ9) to add init.d functionality to Oreo ROMs.
Anyone who has added init.d to Nougat ROMs by patching "init.qcom.post_boot.sh" will have learnt that this does not work with Oreo.
The initd-DJ9 mod avoids that problem.
What use is init.d?
1. init.d allows you to fine-tune/tweak your device or fix problems, and to make the changes persistent (i.e., to survive reboots) without changing your ROM
2. Typical uses include: a) setting new cpu frequencies (overclock or underclock) to override the stock ones; b) tweak interactive governor values; c) disable/enable cpu cores; d) running fstrim on your device's storage; d) retrieve hardware information that is normally difficult to ascertain; e) tweak I/O values; f) set the brightness of led/torch; g) do certain things that you want to happen each time the phone is booted up, etc, etc. - see the sample script that is attached.
Downloads
1A initd-DJ9 installer: Generic (activated on boot_completed)
OR;
1B. initd-DJ9 installer: Snapdragon only (activated on completion of qcom post-boot)
2. Readme
3. Sample init.d script (updated)
Installation
1. Backup your current boot image - if case something goes wrong, you can restore it with TWRP/OrangeFox recovery
2. Download your preferred initd-DJ9 zip installer to your internal (or external) SD
3. Boot to recovery
4. Install it as a normal zip, from TWRP/OrangeFox (or any other) recovery (what the installer does is to patch the boot image's ramdisk, using anykernel2 functionality by @osm0sis)
5. You are ready to roll!
Usage (your phone must be rooted)
1. Install initd-DJ9
2. Create a shell script (it must have the extension ".sh", and must have unix/linux line endings - not Windows or Mac line endings) - see the attachment below for a sample (rename it to sample.sh)
3. Copy the shell script to /system/etc/init.d/
4. Reboot the phone. Every time that the phone is booted, the init.d script(s) will be executed.
5. Check "/data/local/sysinitd.log" to see whether the scripts were executed. This file is updated on every bootup, and so you might want to delete it once in a while , so that it doesn't get too big.
6. This mod has been tested on a number of Oreo ROMs. It has not been tested on Nougat ROMs. It uses anykernel2 functionality, and so might work on Nougat and other ROMs. However, I have only tested it on Oreo. I would not recommend using it on Nougat or Marshmallow ROMs. If you do, you are on your own!
For what it will be helpful???
Sent from my Redmi Note 4 using XDA-Developers Legacy app
Vinay Patani said:
For what it will be helpful???
Click to expand...
Click to collapse
See the "What use is init.d?" section in the OP.
LeoPantera said:
Sample script say 'echo "0" > /proc/touchpanel/enable_dt2w' (disable double-tap-to-wake). You echo "1" to enable?
Click to expand...
Click to collapse
All you need to do is to delete the line, or comment it out.
LeoPantera said:
This can repleace kernel aduitor run startup script?
Click to expand...
Click to collapse
If you are asking about running scripts during the bootup process, then "yes".
Thank you for this.
One question though, is root required for your init.d mod to function or just to push the scripts and set the required permission.
I tried to figure it out by looking at the codes but I'm kinda noob to this.
thapaavijeet said:
Thank you for this.
One question though, is root required for your init.d mod to function or just to push the scripts and set the required permission.
I tried to figure it out by looking at the codes but I'm kinda noob to this.
Click to expand...
Click to collapse
Note the "root required" in the title of the thread? Although it should be possible for the init.d process to kick in without root, you would definitely need to be rooted to use the feature. How would you create or edit your own initd scripts in the /system/etc/init.d/ directory without root?
DarthJabba9 said:
Note the "root required" in the title of the thread? Although it should be possible for the init.d process to kick in without root, you would definitely need to be rooted to use the feature. How would you create or edit your own initd scripts in the /system/etc/init.d/ directory without root?
Click to expand...
Click to collapse
If you could include the directory creation in you mod, if not already there then placing scripts in it and chmod 775 on the script can be done though TWRP file manager itself.
The code should be something like this but I'm not sure about it. However, I was able to place scripts through custom recoveries on un rooted devices.
Code:
INITDIR=/system/etc/init.d
if [ ! -d $INITDIR ]; then
mkdir -p $INITDIR
fi
thapaavijeet said:
If you could include the directory creation in you mod, if not already there then placing scripts in it and chmod 775 on the script can be done though TWRP file manager itself.
Click to expand...
Click to collapse
All that is already there.
Can you correct me if this init.d script is right or wrong, if it is wrong how would it be right?
#!/system/bin/sh
# Cloudflare DNS
iptables -t nat -A OUTPUT -p tcp --dport 53 -j DNAT --to-destination 1.1.1.1:53
iptables -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination 1.0.0.1:53
iptables -t nat -I OUTPUT -p tcp --dport 53 -j DNAT --to-destination 1.1.1.1:53
iptables -t nat -I OUTPUT -p udp --dport 53 -j DNAT --to-destination 1.0.0.1:53
setprop net.eth0.dns1 1.1.1.1
setprop net.eth0.dns2 1.0.0.1
setprop net.dns1 1.1.1.1
setprop net.dns2 1.0.0.1
setprop net.ppp0.dns1 1.1.1.1
setprop net.ppp0.dns2 1.0.0.1
setprop net.rmnet0.dns1 1.1.1.1
setprop net.rmnet0.dns2 1.0.0.1
setprop net.rmnet1.dns1 1.1.1.1
setprop net.rmnet1.dns2 1.0.0.1
setprop net.pdpbr1.dns1 1.1.1.1
setprop net.pdpbr1.dns2 1.0.0.1
setprop 2606:4700:4700::1111
setprop 2606:4700:4700::1001
DarthJabba9 said:
I have created a mod (initd-DJ9) to add init.d functionality to Oreo ROMs.
Anyone who has added init.d to Nougat ROMs by patching "init.qcom.post_boot.sh" will have learnt that this does not work with Oreo.
The initd-DJ9 mod avoids that problem.
What use is init.d?
1. init.d allows you to fine-tune/tweak your device or fix problems, and to make the changes persistent (i.e., to survive reboots) without changing your ROM
2. Typical uses include: a) setting new cpu frequencies (overclock or underclock) to override the stock ones; b) tweak interactive governor values; c) disable/enable cpu cores; d) running fstrim on your device's storage; d) retrieve hardware information that is normally difficult to ascertain; e) tweak I/O values; f) set the brightness of led/torch; g) do certain things that you want to happen each time the phone is booted up, etc, etc. - see the sample script that is attached.
Downloads
1A initd-DJ9 installer: Generic (activated on boot_completed)
OR;
1B. initd-DJ9 installer: Snapdragon only (activated on completion of qcom post-boot)
2. Readme
3. Sample init.d script (updated)
Installation
1. Backup your current boot image - if case something goes wrong, you can restore it with TWRP/OrangeFox recovery
2. Download your preferred initd-DJ9 zip installer to your internal (or external) SD
3. Boot to recovery
4. Install it as a normal zip, from TWRP/OrangeFox (or any other) recovery (what the installer does is to patch the boot image's ramdisk, using anykernel2 functionality by @osm0sis)
5. You are ready to roll!
Usage (your phone must be rooted)
1. Install initd-DJ9
2. Create a shell script (it must have the extension ".sh", and must have unix/linux line endings - not Windows or Mac line endings) - see the attachment below for a sample (rename it to sample.sh)
3. Copy the shell script to /system/etc/init.d/
4. Reboot the phone. Every time that the phone is booted, the init.d script(s) will be executed.
5. Check "/data/local/sysinitd.log" to see whether the scripts were executed. This file is updated on every bootup, and so you might want to delete it once in a while , so that it doesn't get too big.
6. This mod has been tested on a number of Oreo ROMs. It has not been tested on Nougat ROMs. It uses anykernel2 functionality, and so might work on Nougat and other ROMs. However, I have only tested it on Oreo. I would not recommend using it on Nougat or Marshmallow ROMs. If you do, you are on your own!
Click to expand...
Click to collapse
-------
Thank you,
finally, I drop here and found a solution to enable init.d for Mido SND (stock kernel-Android N)
Try a lot solutions around but seem not to work (cann't find /data/init_test.log), even the solution to put scripts in magisk/.core/post-fs-data.d,...etc
until this zip (patch boot.img) is working for me

[LOS][SWAP][MEM] Snappier than ever

NOTE: BEFORE SAYING "yet another memory swapping evangelist", WATCH THE VIDEO: https://youtu.be/sdeKuPiR4II
I have been doing some research on system responsiveness with my good old Mofo Z. Then arrived at this.
24 hours after having configured:
LineageOS 15.1 (root enabled)
Swap file size = 4GB (in /data/swap)
vm.swap_ratio = 100 (default)
vm.swap_ratio_enable = 1
vm.swappiness = 75
I have achieved the readings contained in the attached screenshots, and the system acts snappier than ever. It's actually running pretty cool.
First I enabled init.d processing by adding an RC file to init, then created userinit.sh with the necessary systcl and swapon commands.
No system files were changed (new files were added only), so after an update the configuration won't revert to the original state (swap-less).
The least used pages (some [almost] never used) are being written to the swap file and therefore more room for active code (and cached apps) is made available.
It's almost like I had an 8GB RAM bastard in my hand. This with around 130 apps loaded.
STEPS USED
File init_d.rc was created (as described in https://forum.xda-developers.com/lineage/general/how-to-enable-init-d-to-function-t3810355)
Executed:
Code:
$ su
# cd /data
# mkdir swap
# cd swap
# dd if=/dev/zero of=swapfile bs=1048576 count=4096
# mkswap swapfile
Created /data/local/userinit.sh (called from within already existing /system/etc/init.d/90userinit) with the code:
Code:
#!/system/sbin/sh
# vm_swap_ratio=100 is default, no need to set
sysctl vm.swap_ratio_enable=1
sysctl vm.swappiness=75
swapon /data/swap/swapfile
Rebooted and let the system run for a few hours. Things only get better with uptime/usage.
The best part is that you can unroot afterwards and have it still working.
Merry Christmas!
thanx 4 ur work but i m newbie i dont understand what is for , what makes this for this device
murteci said:
thanx 4 ur work but i m newbie i dont understand what is for , what makes this for this device
Click to expand...
Click to collapse
It's for making your device multitasking better. Watch the video: https://youtu.be/sdeKuPiR4II
Guess what? The Galaxy Note 9 (SM-N9600, 6GB/128GB version) employs memory swapping. It has a 2GB active swap file right out of the box.
I received mine last friday, updated Android and went to check it out after I noticed it behaved and reported much like LineageOS with my mod applied. Then I installed a terminal emulator (no root needed) and ran "free -m".
Bang! The swapping is there!
Can't wait to root it and verify that the swappiness is set to... 75. Kinda keen those Samsung guys, huh? Heheheh.
Whammamoosha said:
Guess what? The Galaxy Note 9 (SM-N9600, 6GB/128GB version) employs memory swapping. It has a 2GB active swap file right out of the box.
I received mine last friday, updated Android and went to check it out after I noticed it behaved and reported much like LineageOS with my mod applied. Then I installed a terminal emulator (no root needed) and ran "free -m".
Bang! The swapping is there!
Can't wait to root it and verify that the swappiness is set to... 75. Kinda keen those Samsung guys, huh? Heheheh.
Click to expand...
Click to collapse
Can Make this tutorial to Video Tutorial on Youtube ?
Whammamoosha said:
It's for making your device multitasking better. Watch the video:
Click to expand...
Click to collapse
it looks fantastic, but does it wear the internal storage after time?
JuniorCaesar said:
it looks fantastic, but does it wear the internal storage after time?
Click to expand...
Click to collapse
Yes it does, everything is a trade-off, there's no such thing as a free lunch.
But the wear level added is roughly same as on a computer SSD, so we're talking about decades of use before everything wears out.
emrebozkurt99 said:
Can Make this tutorial to Video Tutorial on Youtube ?
Click to expand...
Click to collapse
I could, but everything is so simple that it's pretty unnecessary.
. Install terminal emulator app from Play Store
. Run terminal emulator app
. Type "free -m"
. Done!
As for the swap configuration for LOS I'm writing a shell script (BIG) that will handle the configuration as user-friendly as possible. Stay tuned!
Could this be used on a stock rom as well?
SlashSpeed said:
Could this be used on a stock rom as well?
Click to expand...
Click to collapse
This is for LineageOS. For stock ROMs (once rooted) one may make the necessary adaptions.
im noob
Hi, im noob and I followed your instructions (at least what I understood) n_nU
I hope that I did it right, the question is, how can I know that?
old thread, but this may not work for most because the script has a slight error:
Code:
#!/system/sbin/sh
It should be:
Code:
#!/system/bin/sh
then all is well.
justle said:
im noob
Hi, im noob and I followed your instructions (at least what I understood) n_nU
I hope that I did it right, the question is, how can I know that?
Click to expand...
Click to collapse
https://gist.github.com/iGlitch/be70d403ad1cfa42ac7e1d46f1b546db Amend a script to a script to track whether or not it executes. Note: You need to manually create the log folder and logs file in /storage/emulated/0 in order for it to work.
Code:
# Push a semi-needed log to the internal storage with a "report" if the script could be executed or not;
# Script log file location
LOG_FILE=/storage/emulated/0/logs
echo $(date) > /storage/emulated/0/logs/script.log
if [ $? -eq 0 ]
then
echo "Script executed. Enjoy!" >> /storage/emulated/0/logs/script.log
exit 0
else
echo "Script failed!" >> /storage/emulated/0/logs/script.log
exit 1
fi
# Done!
Thanks! Worked like a charm.
I use a bunch of fat apps and this caused a few seconds of load times with almost every app switch.
I'm running LOS 17.1 on gemini with 3GB RAM; swap file defaults to 0.5GB.
I've left
Code:
vm.swap_ratio_enable = 0
vm.swappiness = 60
as it was. Simply adding a new 4GB swap file fixed my daily pain.
I have to provide an update on the charm part. (I've tried other settings from first post too).
Previously system was stuck at fully utilized 500 MB default swap. Every app change (I'm using hungry ones) was a pain.
Now system uses ~300 MB more in swap, and for some use cases user experienced have gotten bettter.
I don't feel like this mode would be complete without changing app killer configuration. Would it even be efficient considering the memory read speed in mi5 (or at all)? Idk.
Bottom line.
If you are unhappy with the performance of your hardware and it's because of RAM and your system are using 100% of swap, then it is probably worth increasing the paging file size.
SyraAB said:
Thanks! Worked like a charm.
I use a bunch of fat apps and this caused a few seconds of load times with almost every app switch.
I'm running LOS 17.1 on gemini with 3GB RAM; swap file defaults to 0.5GB.
I've left
Code:
vm.swap_ratio_enable = 0
vm.swappiness = 60
as it was. Simply adding a new 4GB swap file fixed my daily pain.
Click to expand...
Click to collapse
Hi SyraAB.
I am glad that you successfully create swap and make swap service work, which I think now you are the only one who can solve my problems.
So I did every step that Whammamoosha said. However, I failed. When I check whether there was swap created using free -m in Termux there was nothing. Then I dig something out from some research. Here is my question:
1)
Whammamoosha said:
Created /data/local/userinit.sh (called from within already existing /system/etc/init.d/90userinit) with the code:
Click to expand...
Click to collapse
It appears that I don't have file 90userint under /system/etc/init.d (by the way I believe Whammamoosha meant /system/etc/init here because init.d does not exist in android). Also I notice your ROM is Lineage OS 17.1, which is the same as mine. So I am curious how did you make that work without file 90userinit.
2)
To my best knowledge that sysinit is killed in Los 17.1. There is a post on Reddit regarding to enable init.d on Los 17.1. Link is here. What makes me more curious is that how did you manage to make all things work without some key files? If you don't mind could you tell me how did you successfully create swap?
My phone is HTC m8 running on Lineage os 17.1.
Thanks in advance
Hello mrdet,
I didn't configure applying new swap on startup at all, so I didn't dance around absent init.d.
Increasing the paging file consist of two steps.
1. Create a file to be used as swap. This needs to be done once, as file persist after reboot.
Spoiler: mkswap example
Bash:
cd /data
mkdir swap
cd swap
# create swap file
dd if=/dev/zero of=swapfile bs=1048576 count=4096
mkswap swapfile
2. Activate it. This needs to be done after every reboot.
Spoiler: swapon example
Bash:
swapon /data/swap/swapfile
Hope this helps.

Categories

Resources