starting background processes from pid 1 before original init - Fire Q&A, Help & Troubleshooting

I am running CyanogenMod 12.1 on an Amazon 5th gen tablet. I've replaced the original init with a new init which tries to start other scripts as background processes before calling the original init. If the scripts are executed as foreground, they work as expected. If they are called as background processes, they simply are not run. I have tried the following :
Code:
sh /etc/init3 # works in foreground
/etc/init3 # does not work
sh /etc/init3 & # does not work
/sbin/busybox nohup /etc/init3 & # does not work
/sbin/busybox nohup /etc/init3 < /dev/null >> /android/log/jfh1.log 2>&1 & # does not work
sh /sbin/busybox nohup /etc/init3 < /dev/null >> /android/log/jfh1.log 2>&1 & # does not work
sh /sbin/busybox nohup /etc/init3 < /dev/null >> /android/log/jfh1.log 2>&1 # does not work
/sbin/busybox nohup sh /etc/init3 < /dev/null >> /android/log/jfh1.log 2>&1 # does not work
sh /etc/init3 < /dev/null >> /android/log/jfh1.log 2>&1 # does not work

Related

Tweak init.d script prevents boot

Hello everyone!
I made this script for myself from stuff I found online. But when I put it into init.d the phone stops booting before the cyanogen logo comes up (on the second LG logo). I can't figure out why... However it works (the settings are applied) if I run it with adb once the phone is booted.
This is the script:
Code:
#!/system/bin/sh
echo "0,1,2,4,6,15" > /sys/module/lowmemorykiller/parameters/adj;
echo "1536,2048,4096,10240,12800,15360" > /sys/module/lowmemorykiller/parameters/minfree;
# vm management tweaks:
echo "4096" > /proc/sys/vm/min_free_kbytes;
echo "1" > /proc/sys/vm/oom_kill_allocating_task;
echo "0" > /proc/sys/vm/panic_on_oom;
echo "0" > /proc/sys/vm/laptop_mode;
echo "0" > /proc/sys/vm/swappiness;
echo "70" > /proc/sys/vm/vfs_cache_pressure;
echo "15" > /proc/sys/vm/dirty_ratio;
echo "3" > /proc/sys/vm/dirty_background_ratio;
# misc kernel tweaks:
echo "8" > /proc/sys/vm/page-cluster;
#echo "64000" > /proc/sys/kernel/msgmni;
#echo "64000" > /proc/sys/kernel/msgmax;
echo "10" > /proc/sys/fs/lease-break-time;
#echo "500,512000,64,2048" > /proc/sys/kernel/sem;
# CPU scheduler tweaks:
#echo "1000000" > /proc/sys/kernel/sched_latency_ns;
#echo "25000" > /proc/sys/kernel/sched_wakeup_granularity_ns;
#echo "100000" > /proc/sys/kernel/sched_min_granularity_ns;
echo "-1" > /proc/sys/kernel/sched_rt_runtime_us ;
echo "100000" > /proc/sys/kernel/sched_rt_period_us;
echo "95000" > /proc/sys/kernel/sched_rt_runtime_us;
# battery tweaks:
echo "3000" > /proc/sys/vm/dirty_expire_centisecs;
echo "500" > /proc/sys/vm/dirty_writeback_centisecs;
echo "500" > /proc/sys/vm/dirty_expire_centisecs;
echo "1000" > /proc/sys/vm/dirty_writeback_centisecs;
echo "0" > /proc/sys/vm/oom_kill_allocating_task;
tune2fs -o journal_data_writeback /dev/block/mmcblk0p1;
tune2fs -O ^has_journal /dev/block/mmcblk0p1;
tune2fs -o journal_data_writeback /dev/block/mmcblk0p2;
tune2fs -O ^has_journal /dev/block/mmcblk0p2;
tune2fs -f -o journal_data_writeback /dev/block/mmcblk0p8;
tune2fs -f -O ^has_journal /dev/block/mmcblk0p8;
mount -o remount,noatime,noauto_da_alloc,nodev,nodiratime,barrier=0,nobh /system;
mount -o remount,noatime,noauto_da_alloc,nosuid,nodev,nodiratime,barrier=0,nobh /data;
mount -o remount,noatime,noauto_da_alloc,nosuid,nodev,nodiratime,barrier=0,nobh /cache;
rm -f /data/system/userbehavior.db;
chmod 400 /data/system/usagestats/;
chmod 400 /data/system/appusagestats/;
rm -f /dev/log/main;
echo "2048" > /sys/devices/virtual/bdi/179:0/read_ahead_kb;
echo "2048" > /sys/devices/virtual/bdi/default/read_ahead_kb;
setprop net.dns1 8.8.8.8;
setprop net.dns2 8.8.4.4;
setprop windowsmgr.support_rotation_270 true;
setprop persist.service.pcsync.enable 0;
setprop persist.service.lgospd.enable 0;
setprop user.feature.flex true;
setprop user.feature.lgdrm false;
setprop user.feature.lgresource false;
setprop user.feature.lgpoweroff false;
setprop user.feature.ls_event false;
setprop user.feature.ls_normal false;
setprop user.feature.sui false;
setprop media.stagefright.enable-player false;
setprop media.stagefright.enable-meta true;
setprop media.stagefright.enable-scan true;
setprop media.stagefright.enable-http true;
echo "0" > /proc/sys/net/ipv4/tcp_timestamps;
echo "1" > /proc/sys/net/ipv4/tcp_tw_reuse;
echo "1" > /proc/sys/net/ipv4/tcp_sack;
echo "1" > /proc/sys/net/ipv4/tcp_tw_recycle;
echo "1" > /proc/sys/net/ipv4/tcp_window_scaling;
echo "5" > /proc/sys/net/ipv4/tcp_keepalive_probes;
echo "30" > /proc/sys/net/ipv4/tcp_keepalive_intvl;
echo "30" > /proc/sys/net/ipv4/tcp_fin_timeout;
echo "404480" > /proc/sys/net/core/wmem_max;
echo "404480" > /proc/sys/net/core/rmem_max;
echo "256960" > /proc/sys/net/core/rmem_default;
echo "256960" > /proc/sys/net/core/wmem_default;
echo "4096,16384,404480" > /proc/sys/net/ipv4/tcp_wmem;
echo "4096,87380,404480" > /proc/sys/net/ipv4/tcp_rmem;
MAX_PHONE()
{
pidphone=`pidof com.android.phone`;
if [ $pidphone ];
then
/system/xbin/echo "-17" > /proc/$pidphone/oom_adj;
renice -20 $pidphone;
exit;
else
MAX_PHONE;
fi;
}
MAX_ACORE()
{
pidacore=`pidof android.process.acore`;
if [ $pidacore ];
then
/system/xbin/echo "-17" > /proc/$pidacore/oom_adj;
renice -3 $pidacore;
exit;
else
MAX_ACORE;
fi;
}
MAX_MEDIA()
{
pidmedia=`pidof android.process.media`;
if [ $pidmedia ];
then
/system/xbin/echo "-17" > /proc/$pidmedia/oom_adj;
renice -20 $pidmedia;
exit;
else
MAX_MEDIA;
fi;
}
MAX_UI()
{
pidui=`pidof com.android.systemui`;
if [ $pidui ];
then
/system/xbin/echo "-17" > /proc/$pidui/oom_adj;
renice -20 $pidui;
exit;
else
MAX_UI;
fi;
}
Thanks!
user.feature.lgdrm=false disable DRM Service, so you can not use the default phone ringtones and notifications but if you are planning to use your custom files without DRM then there are no problems.
Regards.

Proper executing of sysctl.conf during boot

Edit: For some strange reason it suddenly works after posting this topic.. :') Delete please
Ok so this is the deal, I'm currently working on broodKernel v1.2 (yes not 1.1 but 1.2) and I've noticed that sysctl.conf isn't loaded in any way, I tried loading it with "sysctl -p" and also with su -c "sysctl -p", both tried it in the kernel itself and in init.d scripts, for some reason it doesn't load on boot, but when I load it myself with "su -c "sysctl -p" it works correctly :silly:
mode is: 644, also tried to chown it to system and/or root, both didn't work. then I question myself. is my init.d method correct? Is it running in root mode? I use this:
Code:
service initd /system/bin/logwrapper /system/xbin/busybox run-parts /system/etc/init.d
oneshot
doesn't it need a "user root" at the bottom?, I feel kinda like this emoticon ":silly:" to ask such question, but I really don't know why it's not running correctly, anyhow the sysctl values from the latest thunderbolt seem so unrealistic?:
Code:
vm.dirty_expire_centisecs = 3000
vm.dirty_writeback_centisecs = 500
But ok that's the thunderbolt settings, also I'm not sure if this really improves the system, I've noticed that the first few benchmarks score pretty high but then suddenly the sdcard read/write speed gets screwed by something.
Anyway, here are the scripts (so far):
/system/etc/init.d/00broodkernel:
Code:
#!/system/bin/sh
# Created by broodplank1337
# broodKernel v1.2
# =================================== #
# broodKernel v1.2 Configuration File #
# =================================== #
# =================================== #
# >>> Available Settings <<< #
# =================================== #
#
# - Set I/O Scheduler
# - Set SDCARD Readahead
# - Enable/Disable Error Reporting
# - Enable/Disable sysctl.conf file
# - See 01screenstatescaling for (advanced) CPU Settings / Tweaks
#
# =================================== #
# =================================== #
#
# >>> I/O Scheduler <<<
#
SCHEDULER="noop"; # noop/cfq
#
# =================================== #
#
# >>> Set SDCard Read Ahead <<<
#
SDCARDREADAHEAD="1024"; # 128/256/512/1024/2048/3072/4096
#
# =================================== #
#
# >>> Google Error Reporting <<<
#
ERRORREPORTING="disabled"; # enabled/disabled
#
# =================================== #
#
# >>> Sysctl.conf Support <<<
#
SYSCTLSUPPORT="enabled"; # enabled/disabled
#
# =================================== #
# Execute Settings:
echo $SCHEDULER > /sys/block/mmcblk0/queue/scheduler
echo $SCHEDULER > /sys/block/mmcblk1/queue/scheduler
# Error Reporting
if [[ "$ERRORREPORTING" == "enabled" ]]
then
setprop profiler.force_disable_err_rpt 0
setprop profiler.force_disable_ulog 0
setprop ro.config.nocheckin 0
else
setprop profiler.force_disable_err_rpt 1
setprop profiler.force_disable_ulog 1
setprop ro.config.nocheckin 1
fi;
# Sysctl.conf
if [[ "$SYSCTLSUPPORT" == "enabled" ]]
then
sysctl -p
else
busybox mv /system/etc/sysctl.conf /system/etc/sysctl.conf.disabled
fi;
# Readahead
echo $SDCARDREADAHEAD > /sys/devices/virtual/bdi/179:0/read_ahead_kb;
echo "256" > /sys/devices/virtual/bdi/179:32/read_ahead_kb;
echo "256" > /sys/devices/virtual/bdi/default/read_ahead_kb;
/system/etc/init.d/01screenstatescaling: (really like this one )
Code:
#!/system/bin/sh
# Credits to pikachu01 and FloHimself for governor tweaks / screenstatescaling script
# Edited by broodplank1337 to fit broodKernel v1.2
# Mount
mount -o remount rw /system
# =====================================================================================
# >>> broodKernel v1.2 CPU Configuration File / Screenstatescaling Script >>> #
# =====================================================================================
# >>> Notes <<<
#
# - This script manages the cpu settings for awake and sleep state.
# - Be sure not to set the max frequency lower then the min frequency.
# - Please only use existing governors to prevent boot problems.
# - Additional governor tweaks can be enabled for a better battery life,
# the governor tweaks may lower performance (only theoretical, like cpu score in Antutu)
# - You can choose to use this file only for CPU Settings,
# this will modify the /system/etc/init.qcom.post_boot.sh file to not set a governor,
# when enabled and 01screenstatescaling is absent, your system will not boot properly
# settings can be restored by place this line:
# =====================================================================================
# >>> Basic CPU Settings <<< # Please only use the values below as settings
# =====================================================================================
# Awake CPU Settings
AWAKE_GOVERNOR="ondemand"; # ondemand/performance/conservative/userspace
MIN_SPEED_AWAKE="245760"; # 122880/245760/368640
MAX_SPEED_AWAKE="1401600"; # 768000/806400/1024000/1200000/1401600
# Sleep CPU Settings
SLEEP_GOVERNOR="ondemand"; # ondemand/conservative/powersave
MIN_SPEED_SLEEP="122880"; # 122880/245760/368640
MAX_SPEED_SLEEP="245760"; # 122880/245760/368640
# Governor Tweaks
ENABLE_ONDEMAND_TWEAKS="no"; # yes/no
ENABLE_CONSERVATIVE_TWEAKS="no"; # yes/no
# =====================================================================================
# =====================================================================================
# >>> Advanced CPU Settings << # Use at own risk, don't change if inexperienced.
# =====================================================================================
# Use 01screenstatescaling as primary CPU Management script
DISABLE_POSTBOOT_CPU="no"; # yes/no (only enable if you know what you're doing!)
# =====================================================================================
# Execute Settings
# Disable Postboot CPU Management
if [[ "$DISABLE_POSTBOOT_CPU" == "no" ]]
then
if [ -e /system/etc/init.qcom.post_boot.sh.bak ]; then
busybox cp -f /system/etc/init.qcom.post_boot.sh.bak /system/etc/init.qcom.post_boot.sh
else
sleep 1
fi;
else
if [ -e /system/etc/init.qcom.post_boot.sh.bak ]; then
sleep 1
else
busybox cp -f /system/etc/init.qcom.post_boot.sh /system/etc/init.qcom.post_boot.sh.bak
sed '33d' /system/etc/init.qcom.post_boot.sh > /sdcard/temp.sh # Remove line that sets governor
busybox mv -f /sdcard/temp.sh /system/etc/init.qcom.post_boot.sh
chmod 644 /system/etc/init.qcom.post_boot.sh
chown root:root /system/etc/init.qcom.post_boot.sh
fi;
fi;
# Ondemand Tweaks
if [[ "$ENABLE_ONDEMAND_TWEAKS" == "yes" ]]
then
if [ -e /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold ]; then
echo "95" > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold;
echo "5" > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/down_differential;
#echo "0" > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/io_is_busy;
echo "1" > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_down_factor;
echo "100000" > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate;
fi;
if [ -e /sys/devices/system/cpu/cpufreq/ondemand/up_threshold ]; then
echo "95" > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold;
echo "5" > /sys/devices/system/cpu/cpufreq/ondemand/down_differential;
#echo "0" > /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy;
echo "1" > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor;
echo "100000" > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate;
fi;
else
sleep 1
fi;
# Conservative Tweaks
if [[ "$ENABLE_CONVERVATIVE_TWEAKS" == "yes" ]]
then
if [ -e /sys/devices/system/cpu/cpu0/cpufreq/conservative/up_threshold ]; then
echo "95" > /sys/devices/system/cpu/cpu0/cpufreq/conservative/up_threshold;
echo "90" > /sys/devices/system/cpu/cpu0/cpufreq/conservative/down_threshold; # 35 # 12 # 30 (higher will lead to noticable lags) # 35 # screen off: # 50 ## 35
echo "20" > /sys/devices/system/cpu/cpu0/cpufreq/conservative/freq_step; # more aggressive ramping up (50) # screen off: # 10
echo "1" > /sys/devices/system/cpu/cpu0/cpufreq/conservative/sampling_down_factor;
echo "100000" > /sys/devices/system/cpu/cpu0/cpufreq/conservative/sampling_rate;
fi;
if [ -e /sys/devices/system/cpu/cpufreq/conservative/up_threshold ]; then
echo "95" > /sys/devices/system/cpu/cpufreq/conservative/up_threshold;
echo "90" > /sys/devices/system/cpu/cpufreq/conservative/down_threshold; # 35 # 12 # 30 (higher will lead to noticable lags) # 35 # screen off: # 50 ## 35
echo "20" > /sys/devices/system/cpu/cpufreq/conservative/freq_step; # more aggressive ramping up (50) # screen off: # 10
echo "1" > /sys/devices/system/cpu/cpufreq/conservative/sampling_down_factor;
echo "100000" > /sys/devices/system/cpu/cpufreq/conservative/sampling_rate;
fi;
else
sleep 1
fi;
# Screenstatescaling loop
(while [ 1 ];
do
# ==============================================================
# settings for while the screen is on / usage
# ==============================================================
AWAKE=`cat /sys/power/wait_for_fb_wake`;
if [ $AWAKE = "awake" ]; then
sleep 2
log -p i -t screenstate_scaling "State: Awake, switching CPU governor to -> $AWAKE_GOVERNOR"
echo $AWAKE_GOVERNOR > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor;
echo $MIN_SPEED_AWAKE > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq;
echo $MAX_SPEED_AWAKE > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq;
fi;
# ==============================================================
# settings for while the screen is off
# ==============================================================
SLEEPING=`cat /sys/power/wait_for_fb_sleep`;
if [ $SLEEPING = "sleeping" ]; then
sleep 2
log -p i -t screenstate_scaling "State: Sleeping, switching CPU governor to -> $SLEEP_GOVERNOR"
echo $SLEEP_GOVERNOR > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor;
echo $MIN_SPEED_SLEEP > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq;
echo $MAX_SPEED_SLEEP > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq;
fi;
done &);
/system/etc/sysctl.conf:
Code:
vm.page-cluster = 3
vm.laptop_mode = 0
vm.dirty_expire_centisecs = 3000
vm.dirty_writeback_centisecs = 500
vm.dirty_background_ratio = 40
vm.dirty_ratio = 80
vm.vfs_cache_pressure = 10
vm.overcommit_memory = 1
vm.oom_kill_allocating_task = 0
vm.min_free_kbytes = 4096
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_dsack = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_moderate_rcvbuf = 1
kernel.sem = "500 512000 100 2048"
kernel.shmmax = 268435456
kernel.msgmni = 1024

What's the fastest ROM to date?

Finally got a new battery after over a year of not using my Droid 4.
Flashed latest CM13 nightly, 1.4ghz OC. Everything seems slow.
My 512mb ram single core $19 cheapo runs smoother.
Anything I do has a half-second or so delay, clean install with nothing running in the background.
Ideally I would just go back to some minimal 2.3.7 ROM, but compatiblity for new programs is getting iffy.
So, as of 2016, what has the smoothest ROM to do date been?
azkay said:
Finally got a new battery after over a year of not using my Droid 4.
Flashed latest CM13 nightly, 1.4ghz OC. Everything seems slow.
My 512mb ram single core $19 cheapo runs smoother.
Anything I do has a half-second or so delay, clean install with nothing running in the background.
Ideally I would just go back to some minimal 2.3.7 ROM, but compatiblity for new programs is getting iffy.
So, as of 2016, what has the smoothest ROM to do date been?
Click to expand...
Click to collapse
I'm running very, very debloated, overclocked stock JB 4.1.2 with Greenify and ram manager and it works pretty well. Even most of new games and emulators rund good.
Cyanogenmod 11 is quite good. One thing I noticed is that the virtual ROM slots are extremely slow, due to the loopback devices.
One way to go is to install the ROM to the virtual ROM slots to test if they are working correctly and then install it into stock slot for real use.
Up, same question here
I use cm11 or cm12 (i find cm13 extremely slow) But with the following tweaks made from my daily experience feel free to try it
Add those lines on boot
swapoff /dev/block/zram0
echo 1 > /sys/block/zram0/reset
#
# setting zram size to 140 mb
echo 396286400 > /sys/block/zram0/disksize
#
# making zram swapable
mkswap /dev/block/zram0
#
# starting swap on zram
swapon /dev/block/zram0
sysctl -w vm.overcommit_ratio=2
sysctl -w vm.swappiness=100
sysctl -w vm.vfs_cache_pressure=70
swapoff /dev/block/zram0
swapon /dev/block/zram0
echo "0" > /sys/kernel/mm/ksm/run
chmod 755 /sys/kernel/dyn_fsync/Dyn_fsync_active
echo "1" > /sys/kernel/dyn_fsync/Dyn_fsync_active
#----------------------------------I/O------------------------------------
A=`ls -d /sys/block/mmcblk1` ;
B=`ls -d /sys/block/mmcblk0` ;
C=`ls -d /sys/block/mmcblk0/mmcblk0boot0` ;
D=`ls -d /sys/block/mmcblk0/mmcblk0boot1` ;
E=`ls -d /sys/block/mmcblk1/mmcblk0boot0` ;
F=`ls -d /sys/block/mmcblk1/mmcblk0boot1` ;
for i in $A $B $C $D $E $F;
do
chmod 755 $i/queue/scheduler
echo "sioplus" > $i/queue/scheduler
echo "16" > $i/queue/iosched/fifo_batch;
echo "1048576" > $i/queue/iosched/back_seek_max;
echo "128" > $i/queue/nr_requests;
echo "1" > $i/queue/add_random;
echo "1" > $i/queue/iosched/back_seek_penalty;
echo "1" > $i/queue/rq_affinity;
echo "3" > $i/queue/iosched/writes_starved;
echo "16" > $i/queue/iosched/quantum;
echo "0" > $i/queue/rotational
echo "1" > $i/queue/iostats
echo "500" > $i/queue/iosched/read_expire;
echo "3000" > $i/queue/iosched/write_expire;
#---------------------------ReadAhead------------------------------
echo "512" > /sys/devices/virtual/bdi/179:24/read_ahead_kb #SD CARD
done
G=`ls -d /sys/class/bdi/7:0` ;
H=`ls -d /sys/class/bdi/7:1` ;
I=`ls -d /sys/class/bdi/7:2` ;
J=`ls -d /sys/class/bdi/7:3` ;
L=`ls -d /sys/class/bdi/7:4` ;
M=`ls -d /sys/class/bdi/default` ;
N=`ls -d /sys/class/bdi/7:5` ;
O=`ls -d /sys/class/bdi/7:6` ;
P=`ls -d /sys/class/bdi/7:7` ;
for i in $G $H $I $J $L $M $N $O $P;
do
chmod 755 $i/read_ahead_kb
echo "512" > $i/read_ahead_kb
echo "512" > /sys/class/bdi/default/read_ahead_kb
done
echo "512" > /sys/class/bdi/253:0/read_ahead_kb
#----------------------------------I/O--FOR SD AND INTERNAL----------------------------------
AA=`ls -d /sys/block/mmcblk1` ;
BB=`ls -d /sys/block/mmcblk0` ;
for i in $AA $BB;
do
chmod 755 $i/queue/scheduler
echo "sioplus" > $i/queue/scheduler
echo "0" > $i/queue/rotational
echo "16" > $i/queue/iosched/quantum;
echo "1048576" > $i/queue/iosched/back_seek_max;
echo "1" > $i/queue/rq_affinity;
echo "1" > $i/queue/iosched/back_seek_penalty;
echo "256" > $i/queue/nr_requests;
echo "1" > $i/queue/add_random;
echo "16" > $i/queue/iosched/fifo_batch;
echo "3" > $i/queue/iosched/writes_starved;
#echo "1" > $i/queue/iosched/quantum;
echo "1" > $i/queue/iostats
echo "500" > $i/queue/iosched/read_expire;
echo "3000" > $i/queue/iosched/write_expire;
done
sysctl -w kernel.panic_on_oops=0
#sysctl -w vm.min_free_kbytes=3774
sysctl -w vm.vfs_cache_pressure=70
sysctl -w vm.swappiness=100
sysctl -w vm.drop_caches=0
sysctl -w vm.min_free_kbytes=3774
sysctl -w vm.page-cluster=3
#setsd speeds
chmod 666 /sys/block/mmcblk0/queue/read_ahead_kb
echo "512" > /sys/block/mmcblk0/queue/read_ahead_kb
chmod 666 /sys/block/mmcblk1/queue/read_ahead_kb
echo "512" > /sys/block/mmcblk1/queue/read_ahead_kb
chmod 666 /sys/devices/virtual/bdi/179:0/read_ahead_kb
echo "512" > /sys/devices/virtual/bdi/179:0/read_ahead_kb
######sd card
chmod 666 /sys/devices/virtual/bdi/179:24/read_ahead_kb
echo "512" > /sys/devices/virtual/bdi/179:24/read_ahead_kb
chmod 666 /sys/devices/virtual/bdi/179:16/read_ahead_kb
echo "512" > /sys/devices/virtual/bdi/179:16/read_ahead_kb
chmod 666 /sys/devices/virtual/bdi/179:8/read_ahead_kb
echo "512" > /sys/devices/virtual/bdi/179:8/read_ahead_kb
chmod 666 /sys/devices/virtual/bdi/179:32/read_ahead_kb
echo "512" > /sys/devices/virtual/bdi/179:32/read_ahead_kb
chmod 666 /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
chmod 666 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo "1300000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
chmod 666 /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo "1200000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
chmod 666 /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
echo "interactive" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
chmod 666 /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq
echo "1300000" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq
chmod 666 /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq
echo "1200000" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq
echo 20000 > /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay
echo 2 > /sys/devices/system/cpu/cpufreq/interactive/boost
echo 40000 > /sys/devices/system/cpu/cpufreq/interactive/boostpulse_duration
echo 70 > /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load
echo 300000 > /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq
echo 15000 > /sys/devices/system/cpu/cpufreq/interactive/min_sample_time
echo 60 > /sys/devices/system/cpu/cpufreq/interactive/target_loads
echo 20000 > /sys/devices/system/cpu/cpufreq/interactive/timer_rate
echo 30000 > /sys/devices/system/cpu/cpufreq/interactive/timer_slack
chmod 666 /sys/module/lowmemorykiller/parameters/minfree
echo '7936,16384,37120,57088,58880,65536' > /sys/module/lowmemorykiller/parameters/minfree
giannhs_n said:
I use cm11 or cm12 (i find cm13 extremely slow) But with the following tweaks made from my daily experience feel free to try it
Add those lines on boot
Click to expand...
Click to collapse
Thank you man, this script made my droid 4 a whole lot more responsive and it does not reboot every few hours anymore.
Quite a few commands in that script don't work, probably due to different paths (sio plus as io scheduler and stock rom boot slot), but those that work, really seem to help a lot.
Oh and you should update the comment in that script about the zram size.
Milp said:
Thank you man, this script made my droid 4 a whole lot more responsive and it does not reboot every few hours anymore.
Quite a few commands in that script don't work, probably due to different paths (sio plus as io scheduler and stock rom boot slot), but those that work, really seem to help a lot.
Oh and you should update the comment in that script about the zram size.
Click to expand...
Click to collapse
Was testing on different Kernels that's why the paths are wrong.. Please replace the sio plus with cfq or bfq (i forgot to change that)
I am glad that those tweaks help you
Regards john
What about this one? Mentor's ROM http://forum.xda-developers.com/showthread.php?t=2122709
That's what I found on my used Droid 4... should I give it a try?
giannhs_n said:
Was testing on different Kernels that's why the paths are wrong.. Please replace the sio plus with cfq or bfq (i forgot to change that)
I am glad that those tweaks help you
Regards john
Click to expand...
Click to collapse
why replace sio plus? I used bfq before, but when i googled for sio plus i only found people saying that sio plus was the best of them all.
Milp said:
why replace sio plus? I used bfq before, but when i googled for sio plus i only found people saying that sio plus was the best of them all.
Click to expand...
Click to collapse
If your kernel support sio plus, of course use it.. else cfq or bfq is a good alternative
giannhs_n said:
I use cm11 or cm12 (i find cm13 extremely slow) But with the following tweaks made from my daily experience feel free to try it
Add those lines on boot
swapoff /dev/block/zram0
echo 1 > /sys/block/zram0/reset
#
# setting zram size to 140 mb
echo 396286400 > /sys/block/zram0/disksize
#
# making zram swapable
mkswap /dev/block/zram0
#
# starting swap on zram
swapon /dev/block/zram0
sysctl -w vm.overcommit_ratio=2
sysctl -w vm.swappiness=100
sysctl -w vm.vfs_cache_pressure=70
swapoff /dev/block/zram0
swapon /dev/block/zram0
echo "0" > /sys/kernel/mm/ksm/run
chmod 755 /sys/kernel/dyn_fsync/Dyn_fsync_active
echo "1" > /sys/kernel/dyn_fsync/Dyn_fsync_active
#----------------------------------I/O------------------------------------
A=`ls -d /sys/block/mmcblk1` ;
B=`ls -d /sys/block/mmcblk0` ;
C=`ls -d /sys/block/mmcblk0/mmcblk0boot0` ;
D=`ls -d /sys/block/mmcblk0/mmcblk0boot1` ;
E=`ls -d /sys/block/mmcblk1/mmcblk0boot0` ;
F=`ls -d /sys/block/mmcblk1/mmcblk0boot1` ;
for i in $A $B $C $D $E $F;
do
chmod 755 $i/queue/scheduler
echo "sioplus" > $i/queue/scheduler
echo "16" > $i/queue/iosched/fifo_batch;
echo "1048576" > $i/queue/iosched/back_seek_max;
echo "128" > $i/queue/nr_requests;
echo "1" > $i/queue/add_random;
echo "1" > $i/queue/iosched/back_seek_penalty;
echo "1" > $i/queue/rq_affinity;
echo "3" > $i/queue/iosched/writes_starved;
echo "16" > $i/queue/iosched/quantum;
echo "0" > $i/queue/rotational
echo "1" > $i/queue/iostats
echo "500" > $i/queue/iosched/read_expire;
echo "3000" > $i/queue/iosched/write_expire;
#---------------------------ReadAhead------------------------------
echo "512" > /sys/devices/virtual/bdi/179:24/read_ahead_kb #SD CARD
done
G=`ls -d /sys/class/bdi/7:0` ;
H=`ls -d /sys/class/bdi/7:1` ;
I=`ls -d /sys/class/bdi/7:2` ;
J=`ls -d /sys/class/bdi/7:3` ;
L=`ls -d /sys/class/bdi/7:4` ;
M=`ls -d /sys/class/bdi/default` ;
N=`ls -d /sys/class/bdi/7:5` ;
O=`ls -d /sys/class/bdi/7:6` ;
P=`ls -d /sys/class/bdi/7:7` ;
for i in $G $H $I $J $L $M $N $O $P;
do
chmod 755 $i/read_ahead_kb
echo "512" > $i/read_ahead_kb
echo "512" > /sys/class/bdi/default/read_ahead_kb
done
echo "512" > /sys/class/bdi/253:0/read_ahead_kb
#----------------------------------I/O--FOR SD AND INTERNAL----------------------------------
AA=`ls -d /sys/block/mmcblk1` ;
BB=`ls -d /sys/block/mmcblk0` ;
for i in $AA $BB;
do
chmod 755 $i/queue/scheduler
echo "sioplus" > $i/queue/scheduler
echo "0" > $i/queue/rotational
echo "16" > $i/queue/iosched/quantum;
echo "1048576" > $i/queue/iosched/back_seek_max;
echo "1" > $i/queue/rq_affinity;
echo "1" > $i/queue/iosched/back_seek_penalty;
echo "256" > $i/queue/nr_requests;
echo "1" > $i/queue/add_random;
echo "16" > $i/queue/iosched/fifo_batch;
echo "3" > $i/queue/iosched/writes_starved;
#echo "1" > $i/queue/iosched/quantum;
echo "1" > $i/queue/iostats
echo "500" > $i/queue/iosched/read_expire;
echo "3000" > $i/queue/iosched/write_expire;
done
sysctl -w kernel.panic_on_oops=0
#sysctl -w vm.min_free_kbytes=3774
sysctl -w vm.vfs_cache_pressure=70
sysctl -w vm.swappiness=100
sysctl -w vm.drop_caches=0
sysctl -w vm.min_free_kbytes=3774
sysctl -w vm.page-cluster=3
#setsd speeds
chmod 666 /sys/block/mmcblk0/queue/read_ahead_kb
echo "512" > /sys/block/mmcblk0/queue/read_ahead_kb
chmod 666 /sys/block/mmcblk1/queue/read_ahead_kb
echo "512" > /sys/block/mmcblk1/queue/read_ahead_kb
chmod 666 /sys/devices/virtual/bdi/179:0/read_ahead_kb
echo "512" > /sys/devices/virtual/bdi/179:0/read_ahead_kb
######sd card
chmod 666 /sys/devices/virtual/bdi/179:24/read_ahead_kb
echo "512" > /sys/devices/virtual/bdi/179:24/read_ahead_kb
chmod 666 /sys/devices/virtual/bdi/179:16/read_ahead_kb
echo "512" > /sys/devices/virtual/bdi/179:16/read_ahead_kb
chmod 666 /sys/devices/virtual/bdi/179:8/read_ahead_kb
echo "512" > /sys/devices/virtual/bdi/179:8/read_ahead_kb
chmod 666 /sys/devices/virtual/bdi/179:32/read_ahead_kb
echo "512" > /sys/devices/virtual/bdi/179:32/read_ahead_kb
chmod 666 /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
chmod 666 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo "1300000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
chmod 666 /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
echo "1200000" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
chmod 666 /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
echo "interactive" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
chmod 666 /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq
echo "1300000" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq
chmod 666 /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq
echo "1200000" > /sys/devices/system/cpu/cpu1/cpufreq/scaling_min_freq
echo 20000 > /sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay
echo 2 > /sys/devices/system/cpu/cpufreq/interactive/boost
echo 40000 > /sys/devices/system/cpu/cpufreq/interactive/boostpulse_duration
echo 70 > /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load
echo 300000 > /sys/devices/system/cpu/cpufreq/interactive/hispeed_freq
echo 15000 > /sys/devices/system/cpu/cpufreq/interactive/min_sample_time
echo 60 > /sys/devices/system/cpu/cpufreq/interactive/target_loads
echo 20000 > /sys/devices/system/cpu/cpufreq/interactive/timer_rate
echo 30000 > /sys/devices/system/cpu/cpufreq/interactive/timer_slack
chmod 666 /sys/module/lowmemorykiller/parameters/minfree
echo '7936,16384,37120,57088,58880,65536' > /sys/module/lowmemorykiller/parameters/minfree
Click to expand...
Click to collapse
What am I supposed to do with these lines? And can somebody please explain what they are doing specifically?
I was trying to find a way to enable zram to cope with the small amount of memory. swap ram is an alternative, but i heard zram is faster and not stressing the storage like swap ram would.

/system/su.d

Hello. I found same questions in other topics, but couldn't find answer.
I would like run script from /system/su.d folder:
Code:
#!/system/bin/sh
echo 0 > /sys/fs/selinux/enforce
or
Code:
#!/system/bin/sh
setenforce 0
and I even tried to run test script:
Code:
#!/system/bin/sh
touch /data/local/tmp/test.txt
echo "test" >> /data/local/tmp/test.txt
But no one of them works. I tried different names for files, gave different chmod (644,700,755). Nothing helps me to run script.
Mb somebody can give me advice what's problem can be?
Phone: Xperia Z3c, MM, systemless SuperSU
On other phone (Xperia M5) this all works fine.
I have a the same problem with a different file in /system/su.d,
Code:
#!/system/bin/sh
logfile0=/data/local/tmp/exfat_mount.log
#logfile=$logfile0
logfile=/dev/null
if [ -e $logfile0 ]; then
logfile=$logfile0
fi
echo '******' $(date) '******' >> $logfile
echo 'id: ' $(id) >> $logfile 2>&1
if [ x$SECONDARY_STORAGE == x ]; then
SECONDARY_STORAGE=/storage/sdcard1
fi
device=/dev/block/mmcblk1p1
echo "Starting for $device" >> $logfile
while read line; do
words=($line)
if [ ${words[0]} == $device ]; then
echo "Error: $device already mounted:" >> $logfile
echo "$line" >> $logfile
exit 1
fi
if [ ${words[1]} == $SECONDARY_STORAGE ]; then
echo "Error: SECONDARY_STORAGE already in use:" >> $logfile
echo "$line" >> $logfile
exit 1
fi
done < /proc/mounts
binpath=/system/xbin
probe=$binpath/probe
if [ ! -e $probe ]; then
echo "Error: $probe not found!" >> $logfile
exit 1
fi
FS=($($probe $device))
echo "$device file system:" ${FS[0]} >> $logfile
# ***** Setup tools for different file systems:
if [ ${FS[0]} == "exFAT" ]; then
echo "$device is exFAT" >> $logfile
mount=$binpath/mount.exfat
if [ -f $mount ]; then
links=( "mkfs.exfat" "fsck.exfat" "dumpexfat" "exfatfsck" "exfatlabel" "mkexfatfs" "mount.exfat-fuse" )
for l in "${links[@]}"
do
if [ ! -e $binpath/$l ]; then
mount -o remount,rw /
ln -s $mount $binpath/$l
echo "Created symlink $binpath/$l" >> $logfile
fi
done
fi
fsck=$binpath/exfatfsck
fsck_ops=
elif [ ${FS[0]} == "NTFS" ]; then
echo "$device is NTFS" >> $logfile
mount=$binpath/ntfs-3g
fsck=$binpath/ntfsfix
fsck_ops='-n'
else
echo "Error: $device is not supported!" >> $logfile
exit 1
fi
# ***** Check if we have required tools.
if [ ! -e $mount ]; then
echo "Error: $mount not found!" >> $logfile
exit 1
fi
if [ ! -e $fsck ]; then
echo "Error: $fsck not found!" >> $logfile
exit 1
fi
# ***** Mount for rw only if the file system is not damaged.
options_ro="ro,uid=1023,gid=1023,umask=0000"
options_rw="rw,uid=1023,gid=1023,umask=0000,noatime"
mnt_cmd="$mount -o $options_rw $device /mnt/media_rw/sdcard1"
$fsck $fsck_ops $device >> $logfile 2>&1
if [ $? != 0 ]; then
mnt_cmd="$mount -o $options_ro $device /mnt/media_rw/sdcard1"
fi
echo "$mnt_cmd" >> $logfile
if [ -e /sys/fs/selinux/enforce ]; then
if [ -e /system/xbin/supolicy ]; then
# ***** Set permissions for fuse. Instead, our mounts would be RO for others.
echo "Using supolicy to provide permissions to fuse." >> $logfile
/system/xbin/supolicy --live "allow sdcardd unlabeled dir { append create execute write relabelfrom link unlink ioctl getattr setattr read rename lock mounton quotaon swapon rmdir audit_access remove_name add_name reparent execmod search open }"
/system/xbin/supolicy --live "allow sdcardd unlabeled file { append create write relabelfrom link unlink ioctl getattr setattr read rename lock mounton quotaon swapon audit_access open }"
/system/xbin/supolicy --live "allow unlabeled unlabeled filesystem associate"
/system/xbin/supolicy --live "allow sdcardd unlabeled filesystem { getattr mount remount unmount }"
/system/xbin/supolicy --live "allow vold unlabeled filesystem { getattr mount remount unmount }"
/system/xbin/supolicy --live "allow init unlabeled filesystem { getattr mount remount unmount }"
else
# ***** Turn SELinux to Permissive. Instead, our mounts would be RO for others.
echo "Using setenforce 0 to provide permissions to fuse." >> $logfile
setenforce 0
fi
fi
# ***** Try to mount:
if [ 0 != 0 ]; then
$mount -o $options_rw $device $SECONDARY_STORAGE
echo "Mounted directly" >> $logfile
else
mount -o remount,rw /system
rm -f /system/bin/debuggerd.mine
echo '#!/system/bin/sh' > /system/bin/debuggerd.mine
echo "$mnt_cmd" >> /system/bin/debuggerd.mine
echo 'start fuse_sdcard1' >> /system/bin/debuggerd.mine
chmod 777 /system/bin/debuggerd.mine
stop debuggerd
mv /system/bin/debuggerd /system/bin/debuggerd.its
mv /system/bin/debuggerd.mine /system/bin/debuggerd
start debuggerd
sleep 2
stop debuggerd
mv /system/bin/debuggerd /system/bin/debuggerd.mine
mv /system/bin/debuggerd.its /system/bin/debuggerd
start debuggerd
mount -o remount,ro /system
vdc volume mount $SECONDARY_STORAGE
echo "Mounted via debuggerd" >> $logfile
fi
The file is called 00mountsd and is used to give access to exfat microsd on stock android 5.1 running on a Chuwi Hi10pro tablet with cherry trail z8350 cpu. I used this on a previous version of the tablet and it worked fine although that tablet came with RemixOS.
The file runs without errors when run manually and succeeds at it task
ls -lZ returns this -rwxr-xr-x root root u: object_r:system_file:s0 00mountsd
I'm running SuperSU Free v2.79 everything else works fine.
Any ideas?

Badly made antivirus script I created

Bash:
#This script is satire. This is, like, the worst antivirus ever.
tput setaf 2
echo "Welcome to Web Antivirus."
echo "Make sure you are running this from a live Linux image as the root user."
lsblk
echo "Select your Windows drive: "
read drive
mount $drive /mnt
cd /mnt/Windows/system32/etc
wget https://github.com/T145/black-mirror/releases/download/latest/black_domain.txt >> /dev/null
wget https://github.com/T145/black-mirror/releases/download/latest/black_ipv4.txt >> /dev/null
echo "Downloaded blacklists."
cp hosts.txt hosts.txt.bak
mawk '{print "0.0.0.0 " $0}' black_domain.txt >> hosts.txt
echo "Wrote domain blacklist."
mawk '{print "0.0.0.0 " $0}' black_ipv4.txt >> hosts.txt
echo "Wrote IPv4 blacklist"
rm -f black_domain.txt black_ipv4.txt
echo "Deleted temporary files."
cd /mnt
echo "@echo off" > clean.bat
echo "del %userprofile%\\Downloads\\*.exe" >> clean.bat
echo "Created cleaner script."
echo "Put this in Task Scheduler so it runs at regular intervals."
echo "Options:"
echo "Type \"restore\" to restore original /etc/hosts."
echo "Type \"exit\" to leave."
echo "Select an option: "
alias restore="rm -f hosts.txt && mv hosts.txt.bak hosts.txt"
read option
$option

Categories

Resources