6

Some software that I'm using needs a higher-than-default value in /proc/sys/fs/inotify/max_user_watches. I can modify this value with a text editor or from the terminal, and for a little while, everything is fine. However, after restarting my computer (not just logging out and in again, which works fine), the value has reset to 8192.

Why does this happen, and how can I make the change permanent?

Mark Amery
  • 188
  • 1
  • 1
  • 12
  • P.S. I'm *guessing* that the behaviour I'm observing happens by default on Ubuntu, but I don't *know* that's true - I've only tested on my own machine. If I'm wrong, then this will end up being a [Hail-Mary question](http://meta.stackoverflow.com/questions/255426/are-hail-mary-questions-on-topic-for-stack-overflow) that is only answerable if somebody can guess what odd thing I might've done or installed that would cause the `max_user_watches` value to reset to 8192 on reboot. My apologies if that is the case! – Mark Amery Jan 03 '16 at 18:08

2 Answers2

10

On Ubuntu 16.04 the following worked for me...

echo "fs.inotify.max_user_watches=524288" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

where 524288 is the higher-than-default number that I'm using. The second command is to make it take effect without rebooting.

Also, here is a link to a similar question with some good answers, in particular see the second answer from user3086182 which helped me.

kernel-inotify-watch-limit-reached

sweeneydavidj
  • 131
  • 1
  • 5
6

From: /usr/lib/sysctl.d/50-default.conf:

To override settings in this file, create a local file in /etc (e.g. /etc/sysctl.d/90-override.conf), and put any assignments there.

So create the file: nano /etc/sysctl.d/90-override.conf.
And populate it with: fs.inotify.max_user_watches=65536.

This will now be used when you restart your server to populate: /proc/sys/fs/inotify/max_user_watches

There is no need therefore to edit /proc/sys/fs/inotify/max_user_watches. Once you've followed the above you can restart your server for the new setting to take affect.

nick
  • 161
  • 1
  • 4