LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 09-05-2008, 09:20 AM   #1
harryhaller
Member
 
Registered: Sep 2004
Distribution: Slackware-14.2
Posts: 468

Rep: Reputation: Disabled
How can one get USB external disk drive to "sleep"?


I have recompiled my kernel to include CONFIG_USB_SUSPEND but I do not see it sleeping.

My BIOS does not handle USB devices so I am relying on acpid to handle the drive - is that correct?

So far, using hdparm -B 1 -S 1 /dev/sda has not worked though hdparm -y /dev/sda does.

Is there something else that I should be changing?

Last edited by harryhaller; 09-05-2008 at 09:30 AM.
 
Old 09-05-2008, 09:50 AM   #2
checkmate3001
Member
 
Registered: Sep 2007
Location: Folsom, California
Distribution: Ubuntu, Mint, Debian, Suse
Posts: 307

Rep: Reputation: 32
I'm sorry, I don't know the answer to your question, but I am curious. Why do you want it to sleep?
 
Old 09-05-2008, 10:00 AM   #3
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
The drive itself can be commanded to sleep, but exactly how depends on the USB chipset that is providing the interface between the drive and the computer. You would do best to execute an lsusb command, then google on the chipset to find the answer that is appropriate to your system.

I make one of my drives spin down with this command (I had to install the relevant package first):

/usr/sbin/sg_start 0 --pc=2 /dev/sdf

I have another one that responds to the command:

sdparm --command=stop /dev/sdh

So, you just have to investigate it a bit.
 
Old 09-05-2008, 12:50 PM   #4
harryhaller
Member
 
Registered: Sep 2004
Distribution: Slackware-14.2
Posts: 468

Original Poster
Rep: Reputation: Disabled
Thanks Jim for the info on sg_utils (which I have downloaded) but they don't seem to offer power management such as spinning down and going into standby after a period of inactivity.

I've discovered this and it seems to do the trick.

After you've found your usb device in /sys/bus/usb/devices you change the autosuspend and level files as described in that link.

Quote:

Autosuspending USB devices
To attempt to autosuspend your USB device, first use lsusb as root to find out the bus number and device number of your usb device:

Code:
# lsusb
Bus 005 Device 014: ID 04b3:4485 IBM Corp.
Bus 005 Device 001: ID 0000:0000
Bus 004 Device 009: ID 0483:2016 SGS Thomson Microelectronics Fingerprint Reader
Bus 004 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 001 Device 008: ID 04b3:310c IBM Corp.
Bus 001 Device 007: ID 050d:0121 Belkin Components F5D5050 100Mbps Ethernet
Bus 001 Device 001: ID 0000:0000
Then find your device's directory in /sys/bus/usb/devices/. Look in directories that are named with two numbers separated with a dash:

Code:
/sys/bus/usb/devices# ls
1-0:1.0  1-1  1-1:1.0  1-2  1-2:1.0  2-0:1.0  3-0:1.0  4-0:1.0  4-2
4-2:1.0  5-0:1.0  5-6  5-6:1.0  usb1  usb2  usb3  usb4  usb5
/sys/bus/usb/devices# cat 1-1/busnum
1
/sys/bus/usb/devices# cat 1-1/devnum
8
/sys/bus/usb/devices# cat 1-2/busnum
1
/sys/bus/usb/devices# cat 1-2/devnum 
7
We know the USB to ethernet device's directory is 1-2 because the device and bus numbers match the lsusb output. Now we can tell the kernel that it should suspend this device automatically if it is not being used. First we set the idle timeout to 2 seconds:

Code:
/sys/bus/usb/devices# echo 2 > 1-2/power/autosuspend
The timeout can be set to any integer number of seconds. If set to -1, the device will not autosuspend. Then we make sure the kernel will automatically suspend the device, and resume the device if data needs to be transferred:

Code:
/sys/bus/usb/devices# echo auto > 1-2/power/level
Other options to echo to this file are "on" and "suspend":

* "on" will force the device to be on all the time.
* "suspend" will permanently suspend the device until the user echoes "on" or "auto" to this file.
(Note that this is a simplification, since the value of the power/wakeup file may allow the device to signal a remote wakeup.)



Checkmate, the reason for doing all this is to conserve power and save on wear and tear of the devices.
 
Old 09-06-2008, 12:55 AM   #5
checkmate3001
Member
 
Registered: Sep 2007
Location: Folsom, California
Distribution: Ubuntu, Mint, Debian, Suse
Posts: 307

Rep: Reputation: 32
oh... makes sense. I get curious from time to time - thank you for answering my question.
 
  


Reply



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
External "mybook" drive only mounts thru usb slacard Linux - Hardware 3 07-06-2007 11:58 AM
"disk sleep" processes, can I find what they're waiting for? karlmdv Linux - General 0 09-20-2006 06:24 AM
External Hard Drive "locked" in Mandriva 2006 VapourTrail Linux - Software 1 03-04-2006 12:53 AM
Why does "crond" sleep and "ssh" hung up? Chowroc Linux - Networking 0 01-12-2006 12:24 AM
USB external CD-RW: cdrecord "cannot open SCSI driver" Avatar Linux - Hardware 10 04-07-2004 11:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 03:28 PM.

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