Increase Inotify Watches
This tutorial will teach you how to increase the number of inotify watches in order to fix possible issues in Seafile, Sublime, and file browsers like Nautilus.
Background
The Linux kernel offers an interface — called inotify — which allows an application to obtain change notifications for files and directories, if the application has registered watches for the files and directories it is interested in.
The advantage of this is twofold: First, it is not necessary to perform regular filesystem scans to detect file changes, i.e. the I/O load is drastically reduced. Secondly, changes can be reported immediately, thus allowing faster responses.
Symptoms
I noticed recently that files were not appearing in my Nautilus file browser. This was especially noticeable when I would compress a folder and the zip would not appear. I would have to manually press f5 in order to see the files. I have a feeling this is something to do with the fact that I am running both Seafile and Dropbox.
Also, when opening a folder in Sublime, I got the following error message which indicated the same issue.
Steps
We just need to add a line to the /etc/sysctl.conf
file, specifying the number of inotify watches to provide.
NUM_WATCHES=2140000000
sudo echo "fs.inotify.max_user_watches=$NUM_WATCHES" | sudo tee -a /etc/sysctl.conf
Then to apply the change without needing to reboot, run
sudo sysctl --system
/etc/sysctl.conf
in an editor and change the line at the bottom.
References
- la-samhna.de - Inotify support on Linux (instantaneous reports, no I/O load)
- Medium - Ubuntu change fs.inotify.max_user_watches for IDEA
- Ask Ubuntu - Files in Nautilus stopped updating automatically, how to fix this?
- Ask Ubuntu - How can I tell if I am out of inotify watches?
First published: 17th June 2021