Problem
When dropbox or guard says like:
Unable to monitor filesystem Please run: echo 100000 | sudo tee /proc/sys/fs/inotify/max_user_watches and restart Dropbox to correct the problem.
No space left on device - Failed to watch "…": The user limit on the total number of inotify watches was reached or the kernel failed to allocate a needed resource. (Errno::ENOSPC)
Solution
man inotify(7) says:
The following interfaces can be used to limit the amount of kernel memory consumed by inotify:
/proc/sys/fs/inotify/max_queued_events
The value in this file is used when an application calls inotify_init(2) to set an upper limit on the number of events that can be queued to the corresponding inotify instance. Events in excess of this limit are dropped, but an IN_Q_OVERFLOW event is always generated.
/proc/sys/fs/inotify/max_user_instances
This specifies an upper limit on the number of inotify instances that can be created per real user ID.
/proc/sys/fs/inotify/max_user_watches
This specifies an upper limit on the number of watches that can be created per real user ID.
In this case, Dropbox and guard have to use many watches, so do this and increase max_user_watches
.
# Check current maximum
$ cat /proc/sys/fs/inotify/max_user_watches
8192
# Increase the maximum
$ echo 100000|sudo tee /proc/sys/fs/inotify/max_user_watches
Password:
100000
# Check
$ cat /proc/sys/fs/inotify/max_user_watches
100000
Doing the above increases max_user_watches
temporally.
To increase max_user_watches
at boot, edit /etc/sysctl.conf
and add fs.inotify.max_user_watches=100000
or fix fs.inotify.max_user_watches=
to 100000
.
(Note: I'm using gentoo so some other distros may have another way to do this…)