5

I am running Fedora 27 with kernel 4.14.5 and have a problem that /etc/sysctl.conf is not being loaded upon boot.

If I run:

sudo sysctl -p

after boot, my settings are loaded and everything works fine.

What do I need to do to enable the loading of /etc/sysctl.conf or what alternatives are there to load it?

  • Be careful with potential alternatives, because depending on what you have in /etc/sysctl.conf, some sysctl settings need to be read early at boot time (e.g. before device creation), otherwise they may not have any effect. See https://bugzilla.kernel.org/show_bug.cgi?id=11655 for instance about such particular settings. – vinc17 Jun 01 '22 at 08:43

2 Answers2

7

In systemd operating systems like Fedora, loading these settings is done with the systemd-sysctl commmand, run by the systemd-sysctl service. Your problem is that you have put the settings in the wrong configuration file.

systemd-sysctl does not read /etc/sysctl.conf. It reads a whole bunch of *.conf files in (amongst other places) the /etc/sysctl.d directory. You should create such a file and put your settings there.

Further reading

  • Lennart Poettering et al. (2016). systemd-sysctl. systemd manual pages. Freedesktop.org.
  • Lennart Poettering et al. (2016). sysctl.d. systemd manual pages. Freedesktop.org.
JdeBP
  • 68,745
1

Edit your root's CRON:

sudo crontab -e

Paste the following:

@reboot /sbin/sysctl --load=/etc/sysctl.conf
  • 2
    This will work, but is a kludge around a different configuration problem. – mattdm Dec 16 '17 at 14:12
  • @mattdm I myself am using it. Tell me in detail, what problems it might cause as for your claim. Thanks. – Vlastimil Burián Dec 16 '17 at 14:19
  • It's not the normal way to configure this. There's many ways to do things, and if you like a certain way, that's fine, but the other answer represents the standard way. That's important if you ever work on other systems, or if other people work on yours, or if you want the knowledge to transfer for a job or something. – mattdm Dec 16 '17 at 15:13
  • 1
    Additionally, this will trigger after a reboot when cron starts. The systemd-sysctl service usually starts very early. That's probably not going to cause a problem in real life, but could, depending on what you want to set. – mattdm Dec 16 '17 at 15:14