Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

My system have to auto-mount for usb devices, how can I be notified when a usb device is plugged? Where can I read more about?

I would like to treat that using shell script or C.

share|improve this question
    
And what about specifically "user space" options? I want my own shell script to run A) when a drive becomes available (e.g. auto-mount) and B) when a drive is about to become unavailable (e.g. "unmount" via gvfs or a gui file manager. –  user29020 Apr 16 at 14:31

1 Answer 1

up vote 4 down vote accepted

Udev support running external programs

KERNEL=="sdb", RUN+="/usr/bin/my_program"
share|improve this answer
    
Tip: You can use github.com/mgorny/sw-notify-send for that external program. –  lkraav May 19 '11 at 16:18
3  
@lkraav: FWIW, You should be able to edit this answer... –  Shog9 May 19 '11 at 19:08
    
Don't udev RUN commands run as root? Is there a way to set up a script to run from an unprivileged user space? Thanks. –  user29020 Apr 16 at 14:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.