QNAP TVS-h874X-i9-64G Age old "failed to setup inotify handler" error, even after adding "inotify.max_user_watches=204800" to the sysctl.conf file

Note that the tee -a portion of the command-line above is short for tee --append, so every time it’s issued it adds another line of "fs.inotify.max_user_watches=204800” to /etc/sysctl.conf. :wink:

From a purely Linux point of view, if the sequence of commands is this…

  1. echo “fs.inotify.max_user_watches=204800” | sudo tee -a /etc/sysctl.conf
  2. cat /proc/sys/fs/inotify/max_user_watches

… because /etc/sysctl.conf is only loaded at boot time, command #2 above can only return the value 1000000 if /etc/sysctl.conf (or a /etc/sysctl.d/ directory) already contains the line “fs.inotify.max_user_watches=1000000” (if there’s more than one declaration, the last one found takes precedence).

I recommend forgetting about using command #1 because it’s obviously causing confusion. Reboot your QNAP, then without issuing any other commands, only issue command #2 to verify what inotify’s max user watches is immediately after booting. Then if the result isn’t 1000000, the next step will be clear(er).

Wouldn’t surprise me if it does because it’s not unusual for devices sold as appliances to have some kind of protection to reduce the chances of customer inadvertently bricking their devices.

Hi Gadget. My mistake. I am resubmitting the previous email with a value correction. I don’t know what else to do except that when I reboot any of the QNAP NAS servers I have to manually reapply the max_user_watches back to 1000000 all over again even though I’ve been using the following commands, logged in as admin, (just for this purpose because it wasn’t staying permanently either with an admin equivalent account user):

echo “fs.inotify.max_user_watches=1000000” | sudo tee -a /etc/sysctl.conf

and then I run the command:

sysctl -p

to load the sysctl.conf without rebooting to make sure the fs.inotify.max_user_watches=1000000 is being read from the sysctl.conf file.

Also, I have confirmed that the sysctl.conf file has only one entry. That entry being: fs.inotify.max_user_watches=1000000 I use sudo vim /etc/sysctl.conf to view it.

I will be signed in as admin so there are no excuses for the system to say I don’t have enough rights for this purpose only. Thank you.

I’d forget about using that echo + tee command above. Although it doesn’t specifically mention your QNAP model, it likely still applies:


So /etc/sysctl.conf is reset during reboot (likely as a preemptive measure to reduce the chances of a bad change bricking the NAS).

Instead, use the same command I provided earlier to dynamically change the kernel setting without editing /etc/sysctl.conf and running sysctl -p.

echo 1000000 > /proc/sys/fs/inotify/max_user_watches

Follow the instructions on the wiki page to add the command to your QNAP’s startup process.

Is this a QNAP only issue where changes don’t stay after a reboot? Tanks for the assist...

I don’t know if its a QNAP only issue. I know it’s happening to me on two QNAP servers, model numbers: TVS-h874X-i9-64GB, TVS-872XT-i7-16GB, both on firmware QTS as of today 2/9/2024.

Followed the steps above using the wiki link you provided above. QNAP unfortunately seems to cleanout and remove any files in those folders after a reboot. Well. It was fun and I can’t keep adding settings every time one of my NAS gets a reboot. So I will kindly move on to another Syncing app ASAP. Thanks for the attempted assists.

FYI: The problem has finally been fixed and confirmed that the solution found works via QNAP’s wonderful and patient technical support. I don’t know why but it did take them approximately 4 days to figure it out and send me the correct parameters for my particular QNAP NAS models. The articles above do not serve these models I have any justice, but they may help the others which have those models listed in the links above. QNAP tech support stated they will update their links to reflect my specific models to better work with SyncThing in the near future.
The following is what they will add:

:Login to the QNAP GUI as admin.

:Enable the “Run user defined process’s during startup” option and click on (View autorun.sh)

:(if you can view your changes in the next screen you’re successful)

:SSH into server and Login as admin.

:Type the following commands:

mount $(/sbin/hal_app --get_boot_pd port_id=0)6 /tmp/config cd /tmp/config

:using the vi editor, (See tutorials on how to use vi editor), (semi-colon W saves the file, semi-colon X exits the vi editor)

vi /tmp/config/autorun.sh

:add the lines below to the “autorun.sh” file:

echo 1000000 > /proc/sys/fs/inotify/max_user_watches

:Save and exit vi.

Type: chmod +x /tmp/config/autorun.sh

:Exit SSH

:reboot the NAS server

:Enable the “Run user defined process’s during startup” option and click on (View autorun.sh)

:if you can view your changes in the next screen you’re successful

:SSH back into the server, login as admin

:Type the following command to confirm the new changes: cat /proc/sys/fs/inotify/max_user_watches

You should see the number “1000000” if successful