Make changes to /sys persistent between boots
Solution 1
Most distros have some sort of an rc.local script that you could use. Check your distro as names and path may vary. Normally expect to look under /etc.
Solution 2
Debian has the package sysfsutils
which has an init.d script that can apply settings to /sys
based on the configuration in /etc/sysfs.conf
.
The init script has an @debian.org author, so I suspect that this is debian-specific and may not have made it to other non-Debian distributions. However, all the logic is contained in the init script, so you could quite easily grab that package, extract the script and use it on your system.
Solution 3
/etc/sysctl.conf
is read by one of your init scripts. This is somewhat distribution-dependent; on Debian, it's /etc/init.d/procps
. Debian doesn't have anything like this for settings under /sys
in its default installation (there's the sysfsutils
package if you want it though). If your distribution doesn't either, write an init script of your own.
(Note that /etc/sysctl.conf
doesn't make /proc/sys
persistent: if you set something in /proc/sys
, it isn't saved in /etc/sysctl.conf
.)
Related videos on Youtube
xenoterracide
Former Linux System Administrator, now full time Java Software Engineer.
Updated on September 18, 2022Comments
-
xenoterracide over 1 year
I want to make
"echo 1 > /sys/kernel/mm/ksm/run"
persistent between boots. I know that I can edit/etc/sysctl.conf
to make/proc
filesystem changes persist, but this doesn't seem to work for/sys
. How would I make this change survive reboots? -
xenoterracide over 12 yearsbut @gilles
sysctl.conf
is for/proc
not/sys
-
xenoterracide over 12 yearsThis is what I ended up doing, though @camh 's answer allowed me to google for this.
sysfs.conf
obviously doesn't exist on arch -
Gilles 'SO- stop being evil' over 12 years@xenoterracide Not for
/proc
but for sysctl values, which are exposed in/proc/sys
. -
xenoterracide over 12 yearseither way it's still not
/sys
which is what this is about. -
clacke over 10 yearssysfsutils is packaged in AUR, but it seems that the sysfs.conf functionality is a debian patch that has not been upstreamed.