Après démontage et synchronisation, tu peux débrancher sans craintes.
Démonter n’est pas éteindre. Le hub reste alimenté, la clé reste allumée bien que démontée.
Si tu tiens à réellement couper l’alimentation de la clé, la réponse pourrait se trouver en :
/usr/src/linux-*/Documentation/usb/power-management.txt
Je n’ai pas testé, je fais partie des utilisateurs qui se contentent de démonter avant de débrancher…
[quote=“caviardage”] Power Management for USB
Alan Stern <stern@rowland.harvard.edu>
October 28, 2010
What is Power Management?
-------------------------
Power Management (PM) is the practice of saving energy by suspending
parts of a computer system when they aren’t being used. While a
component is “suspended” it is in a nonfunctional low-power state; it
might even be turned off completely.
…
Note: Dynamic PM support for USB is present only if the kernel was
built with CONFIG_USB_SUSPEND enabled (which depends on
CONFIG_PM_RUNTIME). System PM support is present only if the kernel
was built with CONFIG_SUSPEND or CONFIG_HIBERNATION enabled.
…
When is a USB device idle?
--------------------------
A device is idle whenever the kernel thinks it’s not busy doing
anything important and thus is a candidate for being suspended. The
exact definition depends on the device’s driver; drivers are allowed
to declare that a device isn’t idle even when there’s no actual
communication taking place. (For example, a hub isn’t considered idle
unless all the devices plugged into that hub are already suspended.)
In addition, a device isn’t considered idle so long as a program keeps
its usbfs file open, whether or not any I/O is going on.
If a USB device has no driver, its usbfs file isn’t open, and it isn’t
being accessed through sysfs, then it definitely is idle.
…
The user interface for dynamic PM
---------------------------------
The user interface for controlling dynamic PM is located in the power/
subdirectory of each USB device’s sysfs directory, that is, in
/sys/bus/usb/devices/…/power/ where “…” is the device’s ID. The
relevant attribute files are: wakeup, control, and
autosuspend_delay_ms. (There may also be a file named “level”; this
file was deprecated as of the 2.6.35 kernel and replaced by the
"control" file. In 2.6.38 the “autosuspend” file will be deprecated
and replaced by the “autosuspend_delay_ms” file. The only difference
is that the newer file expresses the delay in milliseconds whereas the
older file uses seconds. Confusingly, both files are present in 2.6.37
but only “autosuspend” works.)
power/wakeup
This file is empty if the device does not support
remote wakeup. Otherwise the file contains either the
word "enabled" or the word "disabled", and you can
write those words to the file. The setting determines
whether or not remote wakeup will be enabled when the
device is next suspended. (If the setting is changed
while the device is suspended, the change won't take
effect until the following suspend.)
power/control
This file contains one of two words: "on" or "auto".
You can write those words to the file to change the
device's setting.
"on" means that the device should be resumed and
autosuspend is not allowed. (Of course, system
suspends are still allowed.)
"auto" is the normal state in which the kernel is
allowed to autosuspend and autoresume the device.
(In kernels up to 2.6.32, you could also specify
"suspend", meaning that the device should remain
suspended and autoresume was not allowed. This
setting is no longer supported.)
power/autosuspend_delay_ms
This file contains an integer value, which is the
number of milliseconds the device should remain idle
before the kernel will autosuspend it (the idle-delay
time). The default is 2000. 0 means to autosuspend
as soon as the device becomes idle, and negative
values mean never to autosuspend. You can write a
number to the file to change the autosuspend
idle-delay time.
Writing “-1” to power/autosuspend_delay_ms and writing “on” to
power/control do essentially the same thing – they both prevent the
device from being autosuspended. Yes, this is a redundancy in the
API.
…
Warnings
--------
The USB specification states that all USB devices must support power
management. Nevertheless, the sad fact is that many devices do not
support it very well. You can suspend them all right, but when you
try to resume them they disconnect themselves from the USB bus or
they stop working entirely. This seems to be especially prevalent
among printers and scanners, but plenty of other types of device have
the same deficiency.
For this reason, by default the kernel disables autosuspend (the
power/control attribute is initialized to “on”) for all devices other
than hubs. Hubs, at least, appear to be reasonably well-behaved in
this regard.
(In 2.6.21 and 2.6.22 this wasn’t the case. Autosuspend was enabled
by default for almost all USB devices. A number of people experienced
problems as a result.)
This means that non-hub devices won’t be autosuspended unless the user
or a program explicitly enables it. As of this writing there aren’t
any widespread programs which will do this; we hope that in the near
future device managers such as HAL will take on this added
responsibility. In the meantime you can always carry out the
necessary operations by hand or add them to a udev script. You can
also change the idle-delay time; 2 seconds is not the best choice for
every device.
If a driver knows that its device has proper suspend/resume support,
it can enable autosuspend all by itself. For example, the video
driver for a laptop’s webcam might do this (in recent kernels they
do), since these devices are rarely used and so should normally be
autosuspended.
Sometimes it turns out that even when a device does work okay with
autosuspend there are still problems. For example, the usbhid driver,
which manages keyboards and mice, has autosuspend support. Tests with
a number of keyboards show that typing on a suspended keyboard, while
causing the keyboard to do a remote wakeup all right, will nonetheless
frequently result in lost keystrokes. Tests with mice show that some
of them will issue a remote-wakeup request in response to button
presses but not to motion, and some in response to neither.
The kernel will not prevent you from enabling autosuspend on devices
that can’t handle it. It is even possible in theory to damage a
device by suspending it at the wrong time. (Highly unlikely, but
possible.) Take care.
The driver interface for Power Management
-----------------------------------------
The requirements for a USB driver to support external power management
are pretty modest; the driver need only define
.suspend
.resume
.reset_resume
…
[/quote]
Pour commencer, voir les possibilités offertes en
/sys/bus/usb/devices/*/power/