Dropbox fs.inotify错误

Geo*_*rge 5 dropbox

我经常收到以下Dropbox错误.错误消息的提议修复了错误,但我正在试图弄清楚它对我的系统做了什么,也许是否存在根本原因.

无法监控整个Dropbox文件夹层次结构.请跑

echo fs.inotify.max_user_watches=100000 | sudo tee -a /etc/sysctl.conf; sudo sysctl -p` 
Run Code Online (Sandbox Code Playgroud)

并重新启动Dropbox以解决问题.

Mar*_*oij 19

:我强烈建议您实际上DO的步骤,而不仅仅是阅读他们,如果你想了解Linux的!


如果我输入apropos inotify一个shell来查看哪个联机帮助页是关于"inotify"的,我会得到以下结果:

$ apropos inotify
inotify (7)          - monitoring filesystem events
inotify_add_watch (2) - add a watch to an initialized inotify instance
inotify_init (2)     - initialize an inotify instance
inotify_init1 (2)    - initialize an inotify instance
inotify_rm_watch (2) - remove an existing watch from an inotify instance
upstart-file-bridge (8) - Bridge between Upstart and inotify
Run Code Online (Sandbox Code Playgroud)

apropos找到联机帮助页.apropos是你的朋友.记住apropos.

第一个看起来很有希望,所以让我们尝试打开它man inotify.你现在应该得到的文件ifnotify.它说:

NAME
    inotify - monitoring filesystem events

DESCRIPTION
    The  inotify API provides a mechanism for monitoring filesystem events.
    Inotify can be used to monitor individual files, or to monitor directo?
    ries.   When  a  directory is monitored, inotify will return events for
    the directory itself, and for files inside the directory.
Run Code Online (Sandbox Code Playgroud)

所以现在我们已经学会了inotify粗略的做法.让我们看看它是否也有一些有用的错误说法.

我们可以通过按下来搜索联机帮助页/<term><enter>.所以让我们试试:/max_user_watches<enter>这将我们带到这一部分:

   /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.
Run Code Online (Sandbox Code Playgroud)

/proc/sys/fs/inotify/max_user_watches文件与中的fs.inotify.max_user_watches设置相同/etc/sysctl.conf.它们只是访问相同Linux内核参数的两种不同方式.

你可以按q退出.

我可以通过以下方式查看当前值:

$ cat /proc/sys/fs/inotify/max_user_watches
524288
Run Code Online (Sandbox Code Playgroud)

要么:

$ sysctl fs.inotify.max_user_watches
fs.inotify.max_user_watches = 524288
Run Code Online (Sandbox Code Playgroud)

它们都在Linux内核中使用相同的底层值.

请注意,这个值是实际的五倍大的比Dropbox的建议!这是在我的Ubuntu 15.10系统上.

所以现在我们了解到:

  1. inotify 是一个用于监视文件和目录更改的Linux系统.
  2. 我们可以设置允许用户同时观看的文件或目录的数量.
  3. Dropbox提供错误"无法监控整个Dropbox文件夹层次结构".

根据这些信息,似乎Dropbox无法观察足够的文件和目录以进行更改,因为fs.inotify.max_user_watches它太低了.

我建议的是:

  1. /etc/sysctl.conf使用任何文本编辑器检查root用户.确保这里没有fs.inotify.max_user_watches=100000线条.如果有,请删除它们.
  2. 重新引导系统以恢复默认值.
  3. 检查上述值fs.inotify.max_user_watches是什么.
  4. 通过运行加倍sudo echo 'fs.inotify.max_user_watches=XXX' >> /etc/sysctl.conf && sudo sysctl -p /etc/sysctl.conf.此更改后您无需重新启动.
  5. 希望现在修复此错误.时间会证明.如果没有,请尝试再次加倍.
    • 如果不解决这个问题,有可能是另一个问题,或者你只需要增加它.它取决于系统的默认值.

注意:较新版本的systemd不再加载/etc/sysctl.conf文件,它只会从/etc/sysctl.d/目录中加载文件.大多数Linux发行版都应该支持在/etc/sysctl.d目录中使用文件,因此我建议您使用它来进行面向未来的测试.


如果你想知道"为什么首先有限制?" 然后考虑如果一个程序会观看一百万个文件会发生什么.那还能用吗?十亿呢?100亿?10万亿?等等

在某些时候,您的系统将耗尽资源并崩溃.在这里看到一些"有趣"的方法来做到这一点;-)

  • 出色的回答,谢谢。但是,这并不是Arch上的永久解决方案,因为似乎已弃用/etc/sysctl.conf,并且重启后该设置会丢失。将行添加到`/ usr / lib / sysctl.d / 50-default.conf`中。参见https://bbs.archlinux.org/viewtopic.php?id=193020 (2认同)