[systemd-devel] Best practice to set values in /proc?

Mantas Mikulėnas grawity at gmail.com
Tue Jun 14 18:25:20 UTC 2016


On Tue, Jun 14, 2016 at 9:16 PM, Nikolaus Rath <Nikolaus at rath.org> wrote:

> Hello,
>
> Are there any best practices for adjusting values in /proc on system
> boot?  Specifically, I'm looking for a way to do
>
>    echo 1 > /proc/sys/kernel/safename/mode_for_unprivileged
>    echo 1 > /proc/sys/kernel/safename/mode_for_privileged
>
> ..as soon as possible when booting.
>
> I think this file is going to be available right away, but I'm also
> wondering if there is some mechanism that would allow me to wait until
> the desired file in /proc shows up (e.g. due to a module load).
>

/proc/sys is different from the rest of /proc – its persistent
configuration has been /etc/sysctl.conf & /etc/sysctl.d/ since many years
ago.

By default, systemd-sysctl.service waits until systemd-modules-load.service
has finished processing /etc/modules-load.d before it loads the sysctl
configuration. udev also calls systemd-sysctl to reload net.ipv4.<dev>.*
and net.ipv6.<dev>.* settings whenever a new network interface appears.

To react to dynamically loaded modules, I guess you could use a udev rule
as well:

ACTION=="add", SUBSYSTEM=="module", KERNEL=="nfs", \
   RUN+="/usr/lib/systemd/systemd-sysctl --prefix=/fs/nfs"

For writing to various other /sys and /proc locations, use udev rules (with
ATTR{…}=) if it's a device setting, tmpfiles.d(5) otherwise.

-- 
Mantas Mikulėnas <grawity at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20160614/58472bc6/attachment.html>


More information about the systemd-devel mailing list