1

I don't often post, so apologies in advance if my etiquette is poor.

I'm being directed to add vm.swappiness=0 in /etc/sysctl.conf.

When I view the contents of that file, I see the comments below. I'm not clear on if I should just append vm.swappiness=0 to the bottom of the file, or if I need to place that in one of the other files referenced by the comments:

# /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.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).```
user495043
  • 11
  • 3
  • usually in /etc/sysctl. dbut remember that zero is a really bad choice, and at least in my experience is at least 1 a better solution for your specific situation – djdomi May 03 '22 at 17:06

1 Answers1

0

On Linux with systemd, /etc/sysctl.d/*.conf is the site specific directory, and is a good place to put your tuning as the system administrator. See the man pages cited in the comments.

Drop in directories are easier to manage, each set of tuning can be installed as a file. Ensuring one particular line exists in a file is non-trivial to automate.

Create file /etc/sysctl.d/vm.conf that contains the line vm.swappiness=1

swappiness of 1, because swap space should be used if it exists. If a system is to never swap, delete paging spaces.

For completeness, note that tuned is a separate performance profiles thing that can tweak sysctl. Unlikely you are using it, however.

John Mahowald
  • 32,050
  • 2
  • 19
  • 34
  • Thanks. What I ended up doing was adding `/etc/sysctl.d/vm.conf` with the line vm.swappiness=0. This seemed to do the trick. This server runs commercial software and the vendor wants that line specifically so the JVM can keep more pages in memory without RHEL swapping them out so often. – user495043 May 04 '22 at 18:13
  • PS @John Mahowald: tried to give your answer an upvote but the site wouldn't let me (not enough reputation or some such)! – user495043 May 04 '22 at 19:03
  • Yes, a reputation system exists. Two voted up good questions or answers and you can also up vote. – John Mahowald May 05 '22 at 13:29