5

In a mission to reduce frequent memory flushes to filesystem, I added the following two lines to /etc/syctl.conf.

vm.dirty_background_ratio = 50
vm.dirty_ratio = 80

I then ran, sudo sysctl -p and the changes were in effect right way. Upon a system reboot, however, I still see old values for dirty_ratio and dirty_background_ratio.

new-sys-admin@ThinkPad:~$ sysctl -n vm.dirty_background_ratio 
10
new-sys-admin@ThinkPad:~$ sysctl -n vm.dirty_ratio 
5

I'm running Ubuntu 12.04.3 LTS 3.2.0-52-generic-pae. After looking at a couple of posts:

it looks like the upstart job, /etc/init.d/procps is supposed to run on system boot and reload /etc/sysctl.d/* and /etc/sysctl.conf contents via /etc/init/procup.conf but it doesn't seem like it does.

On the next reboot, I ran service procps start and the changes were in effect. I'm wondering how to make procps run consistently on boot time and if I am missing an additional step in making these changes persistent.

EDIT 1

Also tried having these values in /etc/sysctl.d/10-local.conf as per Bill's suggestion.

new-sys-admin@ThinkPad:~$ cat /etc/sysctl.d/10-local.conf 
vm.dirty_background_ratio = 50
vm.dirty_ratio = 80

Upon restart, the values are reverted back.

3 Answers3

3

The answer from Gsus above also solved my problem.

/usr/lib/pm-utils/power.d/laptop-mode writes values dirty_ratio=10 dirty_background_ratio=5 writeback_centisecs=500 after sysctl processed the files in /etc/sysctl.d.

But I'm feeling not so comfortable with commenting out a line in a pm script.

Because I am running on a desktop system and being aware that I don't need the dirty_* changes from above, I tried moving /usr/lib/pm-utils/power.d/laptop-mode to another location. The pm utils didn't complain.

So a possiblity would be to divert the file, so that an update of the package won't recreate it.

sudo dpkg-divert --add --rename --divert /usr/lib/pm-utils/power.d/laptop-mode /usr/lib/pm-utils/laptop-mode.diverted

sudo mv /usr/lib/pm-utils/power.d/laptop-mode /usr/lib/pm-utils/laptop-mode.diverted

You should only do this if you want to adapt the parameters dirty_ratio dirty_background_ratio writeback_centisecs manually.

For the power management utils it would be clearer when they created a file in /etc/sysctl.d to better understand what is going on.

muru
  • 197,895
  • 55
  • 485
  • 740
steffel
  • 31
  • 1
  • Your command is incorrect, it should be: dpkg-divert --add --rename --divert /usr/lib/pm-utils/laptop-mode.diverted /usr/lib/pm-utils/power.d/laptop-mode Also, my dpkg-divert does the renaming automatically, so there's no need for the mv command. Otherwise the solution is very good. Thanks. – soger Apr 25 '16 at 10:57
1

In /usr/lib/pm-utils/power.d/laptop-mode, comment out the following line in function laptop_mode_ac():

write_values 0 10 5 500

There the values changes to:

dirty_ratio = 10
vm.dirty_background_ratio = 5

then reboot, the values of sysctl must persist.

muru
  • 197,895
  • 55
  • 485
  • 740
Gsus
  • 11
  • Thanks Gsus. I will try this out. From your post, it looks like the above changes override sysctl.conf settings during boot time. If you could add more information regarding that, it would be great. – new_sys_admin Apr 07 '14 at 15:35
  • In the link says that run the hooks in /etc/pm/power.d and /usr/lib/pm-utils/power.d, passing the argument true when entering power save and false when leaving. So I suppose that during boot time the hooks is executed at least once. I hope this help :) – Gsus Apr 09 '14 at 19:30
  • dealing with this on 14.04, seems like complete nonsense to have sysctl.conf, sysctl.d/, procps.conf and finally these pm-utils stuff, hopefully systemd does things better... – xealits Nov 09 '17 at 12:05
0

Place your commands in a file under /etc/sysctl.d. Something like 10-local.conf containing:

vm.dirty_background_ratio = 50
vm.dirty_ratio = 80

If the file stays in place it should be run each time you reboot.

BillThor
  • 4,698