Skip to main content
Change directory to pathname
Source Link
Tom Hale
  • 33.4k
  • 42
  • 164
  • 257

List current inotify watches (directorypathname, PID)

How do I get a list of:

  • DirectoriesPathnames currently being watched by inotify, and
  • PID of the process watching

I ask because I have found that syncthing's inotify watches were preventing my disk from being unmounted.

As can be seen below, nothing appears in lsof or fuser listings.

I guessed well with syncthing... How do I remove the guesswork in future if a disk won't unmount due to inotify?


# umount /media/backup umount: /media/backup: target is busy. # lsof +f -- /media/backup/ # echo $? 1 # fuser -vmM /media/backup/ USER PID ACCESS COMMAND /media/backup: root kernel mount /media/backup # systemctl stop syncthing@ravi # umount /media/backup # echo $? 0 

List current inotify watches (directory, PID)

How do I get a list of:

  • Directories currently being watched by inotify, and
  • PID of the process watching

I ask because I have found that syncthing's inotify watches were preventing my disk from being unmounted.

As can be seen below, nothing appears in lsof or fuser listings.

I guessed well with syncthing... How do I remove the guesswork in future if a disk won't unmount due to inotify?


# umount /media/backup umount: /media/backup: target is busy. # lsof +f -- /media/backup/ # echo $? 1 # fuser -vmM /media/backup/ USER PID ACCESS COMMAND /media/backup: root kernel mount /media/backup # systemctl stop syncthing@ravi # umount /media/backup # echo $? 0 

List current inotify watches (pathname, PID)

How do I get a list of:

  • Pathnames currently being watched by inotify, and
  • PID of the process watching

I ask because I have found that syncthing's inotify watches were preventing my disk from being unmounted.

As can be seen below, nothing appears in lsof or fuser listings.

I guessed well with syncthing... How do I remove the guesswork in future if a disk won't unmount due to inotify?


# umount /media/backup umount: /media/backup: target is busy. # lsof +f -- /media/backup/ # echo $? 1 # fuser -vmM /media/backup/ USER PID ACCESS COMMAND /media/backup: root kernel mount /media/backup # systemctl stop syncthing@ravi # umount /media/backup # echo $? 0 
Source Link
Tom Hale
  • 33.4k
  • 42
  • 164
  • 257

List current inotify watches (directory, PID)

How do I get a list of:

  • Directories currently being watched by inotify, and
  • PID of the process watching

I ask because I have found that syncthing's inotify watches were preventing my disk from being unmounted.

As can be seen below, nothing appears in lsof or fuser listings.

I guessed well with syncthing... How do I remove the guesswork in future if a disk won't unmount due to inotify?


# umount /media/backup umount: /media/backup: target is busy. # lsof +f -- /media/backup/ # echo $? 1 # fuser -vmM /media/backup/ USER PID ACCESS COMMAND /media/backup: root kernel mount /media/backup # systemctl stop syncthing@ravi # umount /media/backup # echo $? 0