automatically run fsck.msdos when USB flash drive is plugged in

  • Thread starter Thread starter j135
  • Start date Start date
J

j135

Hello,

Does anyone have any suggestion as to how to automatically run fsck.msdos -n on a USB flash drive when it is plugged in? I am developing hardware that writes stuff to a USB stick and as you can imagine all kinds of bad stuff occasionally happens to the filesystem of the sticks that are inserted into the device when it is connected to the debugger. It would be very helpful to get immediate feedback when something is wrong to help simplify what can be a convoluted debugging process.

I have tried adding the following line in it's own file in udev rules:
BUS=="usb", SUBSYSTEM=="block", PROGRAM="/home/john/bin/checkDrive.pl &"

in checkDrive.pl currently I pop up a big red popup window, the intent is once I see that the script is being called then to issue the fsck command and put the results in the popup window. One thing I don't like about this approach is that I need to run the fsck command as root which is probably not a good idea in a perl script. Not sure I understand why fsck needs to be run as root when I am not attempting to make any changes...

I have run checkDrive.pl from a command line and it functions as expected.

If anyone has a better approach I would welcome it, or if anyone has any suggestions as to how to make the approach I am trying to use work I would appreciate the input.

Continue reading...
 
Back
Top