Linux does support dynamic power management of usb discs. The only difficult part is to find the place in /sys
. Here a shell function to do that:
# 'powerpath /path/to/dev/node' gets the path of the /power directory # for that device powerpath() { devpath=$(udevinfo --query=path --name="`realpath $1`") case "$devpath" in /block/*/*) devpath=${devpath%/*} ;; /block/*) ;; *) return 1 ;; esac echo $(realpath /sys$devpath/device/../../../../power) }
To suspend a disk with label backup
:
echo 'suspend' >`powerpath /dev/disk/by-label/backup`/level
And to bring it back up
echo 'on' >`powerpath /dev/disk/by-label/backup`/level