Results 1 to 8 of 8

Thread: Can't reduce swappiness in /etc/sysctl.conf

  1. #1

    Default Can't reduce swappiness in /etc/sysctl.conf

    I'm running on an SSD and I wanted to reduce swappiness in order to try to decrease the number of writes to the SSD. I may just reinstall without a swap partition but from all my googling (and experience on other distros) it looks like I should be able to set swappiness lower by adding
    Code:
    vm.swappiness=1
    to /etc/sysctl.conf. I've done so but the system doesn't seem to be respecting it as running
    Code:
    cat /proc/sys/vm/swappiness
    still returns 60. Is this the proper way to reduce swappiness on TW?

  2. #2
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    26,113
    Blog Entries
    15

    Default Re: Can't reduce swappiness in /etc/sysctl.conf

    Hi and welcome to the forum
    There are two items to set...
    Code:
    # Disable swap
    vm.swappiness = 1
    vm.vfs_cache_pressure = 50
    Also ensure no CR LF after the last line....

    Working fine here on Tumbleweed and other systems;
    Code:
    cat /proc/sys/vm/swappiness
    1
    cat /proc/sys/vm/vfs_cache_pressure
    50
    Have you restarted the system since the change?
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  3. #3

    Default Re: Can't reduce swappiness in /etc/sysctl.conf

    Thanks! So I went back and added the vfs_cache_pressure line and rebooted, but still no joy.


    Code:
    cat /etc/sysctl.conf 
    ####
    #
    # /etc/sysctl.conf is meant for local sysctl settings
    #
    # sysctl reads settings from the following locations:
    #   /boot/sysctl.conf-<kernelversion>
    #   /lib/sysctl.d/*.conf
    #   /usr/lib/sysctl.d/*.conf
    #   /usr/local/lib/sysctl.d/*.conf
    #   /etc/sysctl.d/*.conf
    #   /run/sysctl.d/*.conf
    #   /etc/sysctl.conf
    #
    # To disable or override a distribution provided file just place a
    # file with the same name in /etc/sysctl.d/
    #
    # See sysctl.conf(5), sysctl.d(5) and sysctl(8) for more information
    #
    ####
    vm.swappiness = 1
    vm.vfs_cache_pressure = 50

    Code:
    cat /proc/sys/vm/swappiness
    60
    cat /proc/sys/vm/vfs_cache_pressure 
    100
    Is there a typo I'm missing or something?

  4. #4
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    26,113
    Blog Entries
    15

    Default Re: Can't reduce swappiness in /etc/sysctl.conf

    Quote Originally Posted by raptir View Post
    Thanks! So I went back and added the vfs_cache_pressure line and rebooted, but still no joy.


    Code:
    cat /etc/sysctl.conf 
    ####
    #
    # /etc/sysctl.conf is meant for local sysctl settings
    #
    # sysctl reads settings from the following locations:
    #   /boot/sysctl.conf-<kernelversion>
    #   /lib/sysctl.d/*.conf
    #   /usr/lib/sysctl.d/*.conf
    #   /usr/local/lib/sysctl.d/*.conf
    #   /etc/sysctl.d/*.conf
    #   /run/sysctl.d/*.conf
    #   /etc/sysctl.conf
    #
    # To disable or override a distribution provided file just place a
    # file with the same name in /etc/sysctl.d/
    #
    # See sysctl.conf(5), sysctl.d(5) and sysctl(8) for more information
    #
    ####
    vm.swappiness = 1
    vm.vfs_cache_pressure = 50

    Code:
    cat /proc/sys/vm/swappiness
    60
    cat /proc/sys/vm/vfs_cache_pressure 
    100
    Is there a typo I'm missing or something?
    Hi
    Strange indeed..... anything in the logs when it boots up?
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  5. #5

    Default Re: Can't reduce swappiness in /etc/sysctl.conf

    Not 100% sure, but IIRC sysctl.conf files are put into initrd, so maybe
    rebuilding the initrd might be necessary.

    AK

    --
    Never attribute to malice that which can be adequately explained by stupidity.
    (R.J. Hanlon)


  6. #6

    Default Re: Can't reduce swappiness in /etc/sysctl.conf

    Alright, so the only interesting thing in the boot log is:

    Code:
     %G%G%G%G[FAILED] Failed to start Create Volatile Files and Directories.
     See 'systemctl status systemd-tmpfiles-setup.service' for details.
    And that just shows me:

    Code:
    ● systemd-tmpfiles-setup.service - Create Volatile Files and Directories
       Loaded: loaded (/usr/lib/systemd/system/systemd-tmpfiles-setup.service; static; vendor preset: disabled)
       Active: failed (Result: exit-code) since Sun 2017-05-21 21:51:39 EDT; 7min ago
         Docs: man:tmpfiles.d(5)
               man:systemd-tmpfiles(8)
      Process: 597 ExecStart=/usr/bin/systemd-tmpfiles --create --remove --boot --exclude-prefix=/dev (code=exited, st
     Main PID: 597 (code=exited, status=1/FAILURE)
    
    May 21 21:51:39 linux-vbzl systemd[1]: Starting Create Volatile Files and Directories...
    May 21 21:51:39 linux-vbzl systemd-tmpfiles[597]: [/usr/lib/tmpfiles.d/cups.conf:3] Unknown group 'sys'.
    May 21 21:51:39 linux-vbzl systemd-tmpfiles[597]: Cannot set file attribute for '/var/log/journal', value=0x008000
    May 21 21:51:39 linux-vbzl systemd-tmpfiles[597]: Cannot set file attribute for '/var/log/journal/faffae7d6378453b
    May 21 21:51:39 linux-vbzl systemd[1]: systemd-tmpfiles-setup.service: Main process exited, code=exited, status=1/
    May 21 21:51:39 linux-vbzl systemd[1]: Failed to start Create Volatile Files and Directories.
    May 21 21:51:39 linux-vbzl systemd[1]: systemd-tmpfiles-setup.service: Unit entered failed state.
    May 21 21:51:39 linux-vbzl systemd[1]: systemd-tmpfiles-setup.service: Failed with result 'exit-code'.
    Probably not related, but something I'd still like to figure out.

    I think I figured out the sysctl issue through a bit more digging. I noticed that systemd-sysctl.service is disabled by default on install. I assume this needs to be enabled for /etc/sysctl.conf to be read? Should I enable it, or is there a better way to deal with swappiness? I could just remove the partition from my fstab...

  7. #7

    Default Re: Can't reduce swappiness in /etc/sysctl.conf

    Got it! It wasn't the service. Apparently, systemd-sysctl does not read /etc/sysctl.conf directly but expects a link in /etc/sysctl.d/99-sysctl.conf > /etc/sysctl.conf. I created that link and it reads /etc/sysctl.conf as expected.

  8. #8

    Default Re: Can't reduce swappiness in /etc/sysctl.conf

    Quote Originally Posted by raptir View Post
    Got it! It wasn't the service. Apparently, systemd-sysctl does not read /etc/sysctl.conf directly but expects a link in /etc/sysctl.d/99-sysctl.conf > /etc/sysctl.conf. I created that link and it reads /etc/sysctl.conf as expected.
    I'm not sure why did this happen to you as i've never done that linking and all is fine with me, but i've added your comment in my bookmarks just in case lol

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •