Skip to contentSkip to conversation

USB Key light on/off state depending on mount

DISCUSSION Casey Dahlin 5 participants 6 messages Aug 24, 2007 – Sep 7, 2007

lore
Share & tools
lore
#0 lore raw

Most USB keys nowadays have a small LED somewhere inside of them that lights up when they are plugged in. On a windows box, the key is lit up whenever it is mounted, and as soon as it is unmounted it turns off, giving a handy physical indicator that the key is safe to remove. On linux, the light is simply on whenever the key is plugged in.

Should linux toggle the light depending on mount state? Is it as trivial as it seems or does this reflect some larger issue?

-Casey Dahlin

#1 lore raw
Quoted 8 lines · Casey Dahlin

Most USB keys nowadays have a small LED somewhere inside of them that lights up when they are plugged in. On a windows box, the key is lit up whenever it is mounted, and as soon as it is unmounted it turns off, giving a handy physical indicator that the key is safe to remove. On linux, the light is simply on whenever the key is plugged in.

Should linux toggle the light depending on mount state? Is it as trivial as it seems or does this reflect some larger issue?

I think that depends on the key. My Corsair keys have the light flicker whenever I/O is on-going.

josh

#2 lore raw
Quoted 7 lines · Josh Boyer
Quoted 6 lines · Casey Dahlin

Most USB keys nowadays have a small LED somewhere inside of them that lights up when they are plugged in. On a windows box, the key is lit up whenever it is mounted, and as soon as it is unmounted it turns off, giving a handy physical indicator that the key is safe to remove. On linux, the light is simply on whenever the key is plugged in.

Quoted 5 lines
Quoted 2 lines

Should linux toggle the light depending on mount state? Is it as trivial as it seems or does this reflect some larger issue?

I think that depends on the key. My Corsair keys have the light flicker whenever I/O is on-going.

Yeah, it does, I am not a big expert in USB storage, and I haven't seen many USB sticks, but I might imagine how windows turns the LED off on unmount. Try "eject /dev/sdX", where sdX is your USB storage, after you unmount it. Be careful, especially if you have SATA (or SCSI) discs in your system or if you use libata for PATA discs not to eject the wrong one... For example, if you think you have to eject /dev/sdc, check before ejecting it with "mount" if there are any /dev/sdc* partitions mounted.

As for LED going on only when mounting, don't know. Maybe they also issue eject after initial enumeration? In which case the LED would go shortly on on plug in, then off, then on again on mount. You can try it under Linux too, if you issue eject after plugging in but before mount. I think, you won't be able to mount it directly after ejecting, you'd have to force re-enumeration under Linux.

Thanks
Guennadi
---
Guennadi Liakhovetski

#3 lore raw
Quoted 5 lines · Guennadi Liakhovetski

I might imagine how windows turns the LED off on
unmount. Try "eject /dev/sdX", where sdX is your USB storage, after you unmount it. Be careful, especially if you have SATA (or SCSI) discs in your system or if you use libata for PATA discs not to eject the wrong one...

If there is only one USB disk connected:

# eject /dev/disk/by-path/*usb*:0

Provided you let udev create links for you. BTW, the /dev/disk/by-id/ symlinks are nice for static mount points in /etc/fstab.

After a disk was mounted, eject also accepts the mountpoint as parameter and will unmount the disk before it tries to eject it.

Signature · 3 lines
Stefan Richter
-=====-=-=== =--- ==-=-
http://arcgraph.de/sr/
#4 lore raw

Sorry to have left this dormant for so long.

Running eject in either of the ways suggested still leaves the light on my particular key turned on.

Quoted 14 lines · Stefan Richter
Quoted 2 lines · Guennadi Liakhovetski

I might imagine how windows turns the LED off on unmount. Try "eject /dev/sdX", where sdX is your USB storage, after you unmount it. Be careful, especially if you have SATA (or SCSI) discs in your system or if you use libata for PATA discs not to eject the wrong one...

If there is only one USB disk connected:

# eject /dev/disk/by-path/*usb*:0

Provided you let udev create links for you. BTW, the /dev/disk/by-id/ symlinks are nice for static mount points in /etc/fstab.

After a disk was mounted, eject also accepts the mountpoint as parameter and will unmount the disk before it tries to eject it.

#5 lore raw
In reply to Guennadi Liakhovetski
Quoted 9 lines · Guennadi Liakhovetski
Quoted 3 lines · Josh Boyer
Quoted 2 lines · Casey Dahlin

Most USB keys nowadays have a small LED somewhere inside of them that lights up when they are plugged in. On a windows box, the key is lit

up

Quoted 3 lines
Quoted 3 lines

whenever it is mounted, and as soon as it is unmounted it turns off, giving a handy physical indicator that the key is safe to remove. On linux, the light is simply on whenever the key is plugged in.

Windows powers off the USB device on unmount, whereas linus does not. I think the problem may lie in HAL.

Xav