Linux watched directories limit -- perhaps not as bad as you thought, and easy to change

I’m switching to a Linux server and took time today to look into this issue:

image

So, do I need to worry about this value or not?

Turns out @ChuckPa posted a great guide on how see how many folders you are currently watching, and how to increase the system limit:

But, before we think about updating the inotify value… what’s the default value? Is it really 8192?

You can verify your system’s setting like this:

cat /proc/sys/fs/inotify/max_user_watches

It turns out that in modern Ubuntu, the value is 65536, not 8192 any more. So, I don’t need to make any changes to my system yet. Cool.

(Chuck, maybe you can update your article to show how to check the value? Could save people from making unneeded changes.)

1 Like

Well so it is! :slight_smile:

Thank you for that. Seems the 5.x kernel has upgraded the limit.

The unfortunate part is many NAS vendors are still using 3.x kernels :frowning:

[chuck@lizum Downloads.1985]$ sudo sysctl -a | grep max_user_watches
fs.epoll.max_user_watches = 7279415
fs.inotify.max_user_watches = 65536
[chuck@lizum Downloads.1986]
1 Like

The kernel change is interesting! It’s now dynamic, based on the available memory in the system, and allowed to scale up to 2^20 or about ~1 million.

On those systems showing 65536 - I wonder if there’s a distro override, or if they don’t have much memory?

FYI. OpenSuSE also seems to be updated.

jkalchik@ceres:~> cat /proc/sys/fs/inotify/max_user_watches 
65536
jkalchik@ceres:~> uname -a
Linux ceres 5.3.18-59.19-default #1 SMP Tue Aug 3 14:11:23 UTC 2021 (055c4fd) x86_64 x86_64 x86_64 GNU/Linux
jkalchik@ceres:~> cat /etc/os-release
NAME="openSUSE Leap"
VERSION="15.3"
ID="opensuse-leap"
ID_LIKE="suse opensuse"
VERSION_ID="15.3"
PRETTY_NAME="openSUSE Leap 15.3"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:leap:15.3"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"

1 Like

So what will it be when I spin up my new 256 GB box?

256k at boot?

1 Like

“1.21 gigawatts!?” Doc stood up. “1.21 gigawatts!” he started for the door. “Great Scott!” he said, and made for the house.

On a quarter-TB box, I think it will be 1048576 unless the distro configures it to something lower.

(Probably because the old kernel default was archaically-low and the distro was in the habit of setting it higher …)

“What’s a gigawatt?”

( I’m building a DIY NAS. It’s going to be fun starting next week as the mail pieces arrive)

1 Like

Good point about the NAS world!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.