To increase the inotify limit in Linux, you will need to modify the kernel parameter that controls the maximum number of inotify instances and watches that can be used at a given time. By default, Linux distributions have a limit on the number of inotify instances and watches to prevent resource exhaustion.
Follow these steps to increase the inotify limit:
-
Check the Current Inotify Limits: You can check the current inotify limits on your system by running the following command:
-
cat /proc/sys/fs/inotify/max_user_instances cat /proc/sys/fs/inotify/max_user_watches
These commands will display the maximum number of inotify instances and watches per user, respectively.
-
Temporarily Increase the Limits (Optional): If you need to temporarily increase the limits to test or use inotify with a higher value, you can use the following commands:
-
sudo sysctl -w fs.inotify.max_user_instances=8192 sudo sysctl -w fs.inotify.max_user_watches=8192
Replace "8192" with the desired number of instances and watches. These values will be in effect until you reboot your system.
-
Modify sysctl Configuration (Permanent Change): To make the changes permanent, you need to edit the sysctl configuration file. Create or edit a file, typically located at
/etc/sysctl.conf
or in a file under the/etc/sysctl.d/
directory, with a.conf
extension. For example:
sudo nano /etc/sysctl.d/99-inotify-limits.conf
Add the following lines to the file to set the inotify limits to your desired values:
-
fs.inotify.max_user_instances=8192 fs.inotify.max_user_watches=8192
Replace "8192" with your desired values.
-
Reload the sysctl Configuration: After making the changes, reload the sysctl configuration to apply the new limits:
bash -
sudo sysctl --system
-
Verify the Changes: You can verify that the changes have taken effect by running the following commands:
bash
-
cat /proc/sys/fs/inotify/max_user_instances cat /proc/sys/fs/inotify/max_user_watches
The values should now reflect your new limits.
Remember that setting very high values for inotify instances and watches can consume system resources, so it's important to choose reasonable limits based on your needs. Also, different Linux distributions may have slightly different paths for sysctl configuration files, so be sure to check the specific location for your distribution if needed.