Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.


  Search this Thread
Old 06-30-2014, 06:22 PM   #1
LQ Newbie
Registered: Aug 2013
Posts: 2

Rep: Reputation: Disabled
How to use udev to detect when any SD card is plugged into a usb adaptor.

I would like to have a script run whenever I plug any SD card into a specific SD adaptor, I've been told that udev is the way to go but I'm at a complete loss, I've done some searching and can find plenty of information that relates to running scripts when a specific drive is plugged in but not anything about any cards plugged into a specific adaptor/hub.

I've only managed to get so far that the hub itself has an entry in the output of lsusb which is
Bus 001 Device 011: ID 0bda:0119 Realtek Semiconductor Corp.
After that I'm lost completely, all the guides assume you know which /dev/sd? entry you're looking for, which I don't

Additionally if I remove and then reconnect the adaptor this is the output written to /var/log/messages
Jun 30 22:22:57 raspberrypi kernel: [ 2114.145106] usb 1- USB disconnect, device number 11
Jun 30 22:23:00 raspberrypi kernel: [ 2116.427548] usb 1- new high-speed USB device number 12 using dwc_otg
Jun 30 22:23:00 raspberrypi kernel: [ 2116.534769] usb 1- New USB device found, idVendor=0bda, idProduct=0119
Jun 30 22:23:00 raspberrypi kernel: [ 2116.534808] usb 1- New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jun 30 22:23:00 raspberrypi kernel: [ 2116.534826] usb 1- Product: USB2.0-CRW
Jun 30 22:23:00 raspberrypi kernel: [ 2116.534839] usb 1- Manufacturer: Generic
Jun 30 22:23:00 raspberrypi kernel: [ 2116.534852] usb 1- SerialNumber: 20090815198100000
Jun 30 22:23:00 raspberrypi kernel: [ 2116.540723] usb-storage 1- USB Mass Storage device detected
Jun 30 22:23:00 raspberrypi kernel: [ 2116.543236] scsi6 : usb-storage 1-
Jun 30 22:23:01 raspberrypi kernel: [ 2117.540126] scsi 6:0:0:0: Direct-Access     Generic- SD/MMC           1.00 PQ: 0 ANSI: 0 CCS
Jun 30 22:23:01 raspberrypi kernel: [ 2117.542785] sd 6:0:0:0: Attached scsi generic sg3 type 0
Jun 30 22:23:01 raspberrypi kernel: [ 2117.548659] sd 6:0:0:0: [sdb] Attached SCSI removable disk
I'm running up to date Raspian (debian) on a raspberry pi,

Can someone point me in the right direction at least?

Many Thanks for your help


Last edited by CaptainMark; 06-30-2014 at 06:43 PM.
Old 07-04-2014, 08:49 PM   #2
Registered: Aug 2006
Location: Arizona
Distribution: ubuntu dirivatives mostly Mate
Posts: 260

Rep: Reputation: 19
I'm having a similar problem. maybe this can help.

I'm using Debian derivatives, and don't know if others are the same.

Most (maybe all) USB thumb drives, and/or USB adapters with sd chips in them will register in /media with an automatic name which is the block ID for that unit. With Thumb drives, or sd chips, that is two two segments of four digits each separated by a dash. (For instance /media/86C8-2CBD).

I want to be able to record identical (or dis-similar) programs onto 10 or more chips, as quickly as possible, and (in case one fails, or is two slow), to be able with certainty to know which one it is without testing each one.

Maybe my observations can help you.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using udev events and edid to detect a specific monitor being plugged in akamikeym Linux - General 1 11-10-2013 06:16 AM
Zenwalk 6.4 udev rules for disabling touchpad when usb mouse is plugged ?? hottdogg Zenwalk 0 11-21-2010 09:10 AM
In AIX how to check/detect new USB devices plugged in ravikumarv AIX 2 03-31-2010 10:32 PM
How to detect programatically if a USB device is is plugged-in / plugged out? franc Linux - Software 3 02-01-2007 05:01 AM
USB Mouse only works when plugged into USB PCI Card helliax Slackware 6 12-05-2005 02:18 AM > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 10:52 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration