在 Debian 里,inotify 本身是 Linux 内核功能,不需要“安装”软件包,只要内核支持即可(几乎所有现代 Debian 都支持)。
你通常说的“安装 inotify”,一般是下面几种情况之一:
ls /proc/sys/fs/inotify
如果看到:
max_queued_events max_user_instances max_user_watches
说明 inotify 已启用 ✅
常用的是 inotify-tools:
sudo apt update
sudo apt install inotify-tools
安装后可用:
inotifywait -m /path/to/dir
如果你用 Python:
pip install pyinotify
# 或
pip install watchdog
如果报错:
Failed to watch ...: No space left on device
提高限制:
sudo sysctl fs.inotify.max_user_watches=524288
永久生效:
echo "fs.inotify.max_user_watches=524288" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
比如:
systemd 使用 inotifyfail2bansyncthing可以告诉我你具体想用 inotify 做什么,我可以给你更精确的方案。