Skip to contentSkip to conversation

usb-storage

DISCUSSION Luca T. 4 participants 9 messages Mar 9, 2004 – Mar 10, 2004

lore
Share & tools
lore

Luca T.

author
#0 lore raw

Hello,
i would like to understand how hotplugging works, i did some experiments but without success.
If i did understand well, when i connect an usb-disk the script /etc/hotplug/usb/usb-storage should be fired... but this doesn't seem to happen.
I put a line inside it ( echo "test" >/tmp/test ) but the file is never created when i plug or unplug my usb-disk.
Why?

Thank you,
Luca

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#1 lore raw

This could be a configuration problem. Udev release 21, sysfs should be mounted, udev rules in /etc/udev/udev.rules etc. Also, a valid rule in udev.rules which would program your usb-storage device.

I was seeing the same problem but as I installed the above programs, it went away.
--
Atul

-------------------------------------------------------------
P.S: All opinions are my personal opinion(s) & responsibility and do not represent the view of my employer ( Intel Corporation ).

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Luca T.
Sent: Tuesday, March 09, 2004 9:11 AM
To: [email protected]
Subject: usb-storage

Hello,
i would like to understand how hotplugging works, i did some experiments

but without success.
If i did understand well, when i connect an usb-disk the script /etc/hotplug/usb/usb-storage should be fired... but this doesn't seem to

happen.
I put a line inside it ( echo "test" >/tmp/test ) but the file is never created when i plug or unplug my usb-disk.
Why?

Thank you,
Luca

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&opÌk
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#2 lore raw
In reply to Luca T.
Quoted 7 lines · Atul

This could be a configuration problem. Udev release 21, sysfs should be mounted, udev rules in /etc/udev/udev.rules etc. Also, a valid rule in udev.rules which would program your usb-storage device.

I was seeing the same problem but as I installed the above programs, it went away.

Hmmm,
i don't have this udev thing nor sysfs mounted (i believe, not sure). (Btw, i am running Mandrake 9.2)
So... i do not have udev nor sysfs but still, when i plug my usb-webcam, a new icon appears on my desktop. This means that in some way mandrake is doing it. I just want to understand how this is happening to make my custom scripts run instead.
Since i have /etc/hotplug i thought this was how.
Any idea?

Thanx,
Luca

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#3 lore raw
In reply to Luca T.
Quoted 6 lines · Luca T.

Hello,
i would like to understand how hotplugging works, i did some experiments but without success.
If i did understand well, when i connect an usb-disk the script /etc/hotplug/usb/usb-storage should be fired... but this doesn't seem to happen.

What kernel are you using?

Quoted 3 lines

I put a line inside it ( echo "test" >/tmp/test ) but the file is never created when i plug or unplug my usb-disk.
Why?

On 2.4 that script would only be run when the driver is first loaded. When the device is removed, the driver is never unloaded.

thanks,

greg k-h

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#4 lore raw
In reply to Luca T.

Ok,
as Greg suggested the script is fired only the first time an usb-disk is plugged in.
I verified this by unloading the usb-storage kernel module and then plugging in an usb-disk. The script has been executed correctly. Now, i need a way to detect when an usb-disk is plugged in and out, not only the first time, but everytime this happens.
I noticed that not only the usb-storage module isn't unloaded when the usb-disk is removed but it also leaves the device-file (for instance /dev/sda). So i have no way to know when the disk is removed :(

Any idea that could help me?

Thank you again,
Luca

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#5 lore raw
In reply to Luca T.
Quoted 7 lines · Luca T.

Ok,
as Greg suggested the script is fired only the first time an usb-disk is plugged in.
I verified this by unloading the usb-storage kernel module and then plugging in an usb-disk. The script has been executed correctly. Now, i need a way to detect when an usb-disk is plugged in and out, not only the first time, but everytime this happens.

You will get a scsi event every time this happens, but this is only in the 2.6 kernel. 2.4 does not support this.

Quoted 3 lines

I noticed that not only the usb-storage module isn't unloaded when the usb-disk is removed but it also leaves the device-file (for instance /dev/sda). So i have no way to know when the disk is removed :(

Only udev manages the /dev entries, unless you are using devfs. I'm guessing you aren't using udev or devfs? If so, the device nodes are always there.

Hope this helps,

greg k-h

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#6 lore raw
In reply to Luca T.
Quoted 5 lines · Greg KH

You will get a scsi event every time this happens, but this is only in

the 2.6 kernel. 2.4 does not support this.

:(

Quoted 5 lines

Only udev manages the /dev entries, unless you are using devfs. I'm guessing you aren't using udev or devfs? If so, the device nodes are always there.

I'm using devfs, the device-files are dinamically created and removed... beside for the usb-disks, they are dinamically created, but not removed once the device has been unplugged :(

Thanx,
Luca

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#7 lore raw
In reply to Luca T.
Quoted 3 lines · Luca T.

I'm using devfs, the device-files are dinamically created and removed... beside for the usb-disks, they are dinamically created, but not removed once the device has been unplugged :(

Then go bug the devfs developers :)

Good luck,

greg k-h

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#8 lore raw
In reply to Luca T.
Quoted 22 lines · Greg KH
Quoted 8 lines · Luca T.

Hello,
i would like to understand how hotplugging works, i did some experiments but without success.
If i did understand well, when i connect an usb-disk the script /etc/hotplug/usb/usb-storage should be fired... but this doesn't seem to happen.

What kernel are you using?

Quoted 5 lines

I put a line inside it ( echo "test" >/tmp/test ) but the file is never created when i plug or unplug my usb-disk.
Why?

Quoted 8 lines

On 2.4 that script would only be run when the driver is first loaded. When the device is removed, the driver is never unloaded.

thanks,

greg k-h

At least with recent hotplug packages user mode drivers are loaded even if kernel module is loaded or not, in 2.4 and 2.6.

--Mika

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel