I want to know if there is any possible way to monitor these information using system libraries or any python modules?

  • Size of files or Files copied to USB drive
  • Size of files or Files copied from USB drive
  • Files removed from USB drive
  • Event at which any of the above activity occurs

For size added/removed I can use change in free space but I couldn't find any helpful attribute that could provide me with the free space info in libudev. I am using pyudev in python by the way.

1 Answer 1


I don't this is possible with UDev. UDev watches only for changes in device superblock and header areas so for filesystem changes it can track only events like label change or some other filesystem attribute changes but not for changes that don't affect header like changes in files.

You can get free space information relatively quickly using statfs (that's how df works) and you could pair this with inotify or fanotify to watch for all changes on the filesystem. But I'm not aware of any library or system daemon already providing this kind of information in one place.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .