Page 1 of 1

CentOs7 vm.swappiness cannot be set on boot

Posted: 2015/12/30 09:48:13
by hunter86_bg
Hi guys,
I'm currently studying for the RHCE and one of the topics is system optimization. I'm trying to set "vm.swappiness" to a non-default setting.
First, I've created a swappiness.conf file in "/etc/sysctl.d" and removed the link pointing to the sysctl.conf file - on reboot it doesn't do it. (sysctl -p and systemctl restart systemd-sysctl works).
Then, I decided to revert all changes and enter vm.swappiness=<digit> in sysctl.conf file (with and without empty spaces around the "=") and after each reboot - swappiness was set to default.After a "systemctl restart systemd-sysctl or with "sysctl -p sysctl.conf" - everything seems to be ok.
I'm using CentOs 7.2 with kernel 3.10.0-327.3.1

I'm out of any ideas.
Thanks for your time reading this long post.

Best Regards,
Strahil Nikolov

Re: CentOs7 vm.swappiness cannot be set on boot

Posted: 2015/12/30 11:19:54
by hunter86_bg
I've tried with net.ipv4.ip_forward = 1 and it worked. It seems that systemd-systemctl.service is started too early and it can't change the swappiness level.

Re: CentOs7 vm.swappiness cannot be set on boot

Posted: 2015/12/30 12:04:47
by hunter86_bg
Update:
I've just tested the 2 tunables under Centos 7.0 and it worked.

Re: CentOs7 vm.swappiness cannot be set on boot

Posted: 2015/12/30 13:14:00
by hunter86_bg
It looks like a bug and I've reported it as https://bugs.centos.org/view.php?id=10045.

Re: CentOs7 vm.swappiness cannot be set on boot

Posted: 2015/12/30 16:09:53
by avij
Works fine here via /etc/sysctl.conf. Perhaps there is something that sets swappiness back to the default after sysctl has set the custom value? grep -r swappiness /etc may give you some clues.

Re: CentOs7 vm.swappiness cannot be set on boot

Posted: 2015/12/30 22:51:12
by hunter86_bg
I've tested it today.
In CentOs 7.0 - works fine, in 7.0 with latest kernel - still OK.
In CentOs7.0 updated to -> 7.2 - not working.
In CentOs7.2 from DVD with no updates - not working.

It just seems to be a bug. For kernel tunables only sysctl config files (located in /etc/sysctl.d/ folder , and /etc/sysctl.conf) should change these parameters. On 7.2 after restart of systemd-sysctl everything works fine.

Re: CentOs7 vm.swappiness cannot be set on boot

Posted: 2016/01/09 16:14:22
by hunter86_bg
Ok,
here is the reson why the swappiness got changed. In my tune profile

Code: Select all

# tuned-adm active
there is a setting for vm.swappiness which overrides the sysctl setting.The settings for the different profiles are in /usr/lib/tuned.