5

Trying to permanently change some vm kernel parameters, I created /etc/sysctl.d/01-custom.conf config file as it described in Red Hat knowledgebase article. Here is its content:

# cat /etc/sysctl.d/01-custom.conf
vm.swappiness=10
vm.dirty_ratio=20
vm.vfs_cache_pressure=200

But after reboot only vm.vfs_cache_pressure is changed and swappines and dirty_ratio have previous values.

# sysctl vm.swappiness
vm.swappiness = 30
# sysctl vm.dirty_ratio
vm.dirty_ratio = 30

In /etc/sysctl.conf file there is no changes for vm.dirty_ratio parameter and vm.swappines is set to 10 as well. Does it mean that the system takes these values from somewhere else? There are no any config files under /etc/sysctl.d besides mine and link to /etc/sysctl.conf:

# ll /etc/sysctl.d/
total 4
-rw-r--r--  1 root root 147 May 30 04:40 01-custom.conf
lrwxrwxrwx. 1 root root  14 Apr  3 15:00 99-sysctl.conf -> ../sysctl.conf

Update: sysctl --system shows that values from my config were taken. Nothing for vm.swappines and vm.dirty_ratio are set to 30.

sys463
  • 355
  • 3
  • 16
  • 2
    If you run `sysctl -p`, will the values you wanted come into effect? If so, it might be that the sysctl settings are applied in initramfs phase of the boot, and you'll just need to rebuild your initramfs to make the changes happen automatically at boot time.. – telcoM May 30 '18 at 09:27
  • 1
    Several parameters can be achieved from `/lib/sysctl.d/` directory. Maybe your parameters is stored there. All available paths you can get from `man 5 sysctl.conf` in **FILES** section. – Yurij Goncharuk May 30 '18 at 09:31
  • @telcoM, yes, running `sysctl -p` changes values but only till the reboot. – sys463 May 30 '18 at 09:35
  • Thanks @YurijGoncharuk. I've checked all the directories that are listed in `man` for `sysctl.conf` and found out a few more configs - nothing for `swappines` or `dirty_ratio` set to 30. Also, I checked with `sysctl --system` - updated description. – sys463 May 30 '18 at 09:58
  • @telcoM, strange, but rebuilding initramfs didn't help.. – sys463 May 30 '18 at 10:43
  • @sys463 I've tested your scenario on CentOS 7.5 and it works. Sorry, but I can't test it on RHEL. I think about another suggestion. – Yurij Goncharuk May 30 '18 at 10:46
  • Are you able to change the kernel parameters at boot via GRUB? – jc__ May 30 '18 at 14:08
  • @jc__, do you mean adding it to `GRUB_CMDLINE_LINUX` in `/etc/default/grub`? – sys463 May 30 '18 at 17:10

2 Answers2

0

If you are running tuned, it will take precedence over sysctl: Sysctl.conf parameters overridden by Tuned

Check if tuned is running:

systemctl status tuned

If it is running, check which profile is active:

tuned-adm active

Tuned's profiles can be found in /usr/lib/tuned/:

# grep -ri '^vm.swappiness' /usr/lib/tuned/
/usr/lib/tuned/latency-performance/tuned.conf:vm.swappiness=10
/usr/lib/tuned/throughput-performance/tuned.conf:vm.swappiness=10
/usr/lib/tuned/virtual-guest/tuned.conf:vm.swappiness = 30
Awgy
  • 101
  • 2
0

Default /etc/sysctl.conf file on the CentOS 7 server comments that;

# sysctl settings are defined through files in

# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.

#

# Vendors settings live in /usr/lib/sysctl.d/.

# To override a whole file, create a new file with the same in

# /etc/sysctl.d/ and put new settings there. To override

# only specific settings, add a file with a lexically later

# name in /etc/sysctl.d/ and put new settings there.

You can search these directories for the specific settings.

Kadir
  • 254
  • 1
  • 5