/proc/sys values be changed at boot?
sysctl.conf doesn't exist on Android and echoing values to the
proc files isn't persistent.
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It only takes a minute to sign up.Sign up to join this community
write command in
/init.rc or any other
.rc file. You may also create your own:
# /system/etc/init/custom.rc on property:sys.boot_completed=1 write /proc/sys/kernel/hostname MyDroid
Set permissions and reboot device.
~# chown 0.0 /system/etc/init/custom.rc ~# chmod 0644 /system/etc/init/custom.rc ~# chcon u:object_r:system_file:s0 /system/etc/init/custom.rc
You may also use some early trigger like
on init or
on boot but your value may get overwritten by some later trigger.
Also some values aren't allowed by SELinux to be written by
/proc/sys/vm/dirty_ratio are writable only by
vold. In this case you can use
exec command which allows changing SELinux label before command execution.
# /data/sysctl.conf kernel.hostname=MyDroid vm.dirty_ratio=20
# /system/etc/init/custom.rc on property:sys.boot_completed=1 exec u:r:magisk:s0 -- /system/bin/sysctl -p /data/sysctl.conf
toybox applet. Or you may use
For other options see this answer. Some apps may also provide similar functionality but I never used one.