/etc/sysctl.conf doesn't persist after reboot

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:

  • Ubuntu way to run sysctl -p on each boot?
  • Ubuntu 12.04, why service procps start doesn't start procps?

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.


Solution 1:

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.

Solution 2:

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.