LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 12-16-2016, 07:34 PM   #1
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
How to enable auto-sleep of an unused USB disk?


I would like to use an external USB disk (Buffalo HD-LCU3/N) on a Raspberry Pi as my home backup server. The Pi is always on, but the disk should shut itself off, be silent and consume little power when not in use.

On a Windows PC, the disk does shut itself down after a few minutes. On Linux (both Raspbian and Fedora on another PC), it doesn't.

I am rather ignorant as far as SCSI or USB connections are concerned. What do I have to do to enable sleep? Where should I look for errors or clues?

So far, I tried
Code:
hdparm -S 10 /dev/sdb 
 setting standby to 10 (50 seconds)
SG_IO: bad/missing sense data, sb[]:  70 00 01 00 00 00 00 0a 00 00 00 00 00 1d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I also ran hdparm -I. The whole output is at the end of my post.

I also learned that udisks2 polls disks regularly and can be disabled with a udev rule. I configured:
Code:
KERNEL=="sd*[!0-9]", ENV{ID_BUS}=="usb", ENV{DEVTYPE}=="disk", ENV{UDISKS_DISABLE_POLLING}="1"
Still no success. Killing udisks processes: No change.

The kernel message buffer only contains startup messages. I am surprised to see a ten seconds gap between the generic USB and SCSI messages and the storage-related messages, but doubt it has anything to do with my problem:
Code:
[   34.465819] usb 2-1.2: new high-speed USB device number 3 using ehci-pci
[   34.553740] usb 2-1.2: New USB device found, idVendor=0411, idProduct=0286
[   34.553751] usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   34.553756] usb 2-1.2: Product: HD-LCU3
[   34.553760] usb 2-1.2: Manufacturer: BUFFALO
[   34.553763] usb 2-1.2: SerialNumber: 00000029000017B6
[   34.613773] usb-storage 2-1.2:1.0: USB Mass Storage device detected
[   34.613974] scsi host6: usb-storage 2-1.2:1.0
[   34.614187] usbcore: registered new interface driver usb-storage
[   34.619263] usbcore: registered new interface driver uas
[   35.618282] scsi 6:0:0:0: Direct-Access     BUFFALO  External HDD     0000 PQ: 0 ANSI: 3
[   35.619339] sd 6:0:0:0: Attached scsi generic sg1 type 0
[   45.796102] sd 6:0:0:0: [sdb] Very big device. Trying to use READ CAPACITY(16).
[   45.796860] sd 6:0:0:0: [sdb] 5860533168 512-byte logical blocks: (3.00 TB/2.73 TiB)
[   45.796867] sd 6:0:0:0: [sdb] 4096-byte physical blocks
[   45.798053] sd 6:0:0:0: [sdb] Write Protect is off
[   45.798065] sd 6:0:0:0: [sdb] Mode Sense: 73 00 10 08
[   45.799294] sd 6:0:0:0: [sdb] Write cache: enabled, read cache: enabled, supports DPO and FUA
[   45.800945] sd 6:0:0:0: [sdb] Very big device. Trying to use READ CAPACITY(16).
[   45.857980]  sdb: sdb1
[   45.860309] sd 6:0:0:0: [sdb] Very big device. Trying to use READ CAPACITY(16).
[   45.863436] sd 6:0:0:0: [sdb] Attached SCSI disk
hdparm -I output. What I consider significant is highlighted.
Code:
$ sudo hdparm -I /dev/sdb

/dev/sdb:

ATA device, with non-removable media
        Model Number:       TOSHIBA DT01ACA300
        Serial Number:      76CDSS9AS
        Firmware Revision:  MX6OABB0
        Transport:          Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0; Revision: ATA8-AST T13 Project D1697 Revision 0b
Standards:
        Used: unknown (minor revision code 0x0029)
        Supported: 8 7 6 5
        Likely used: 8
Configuration:
        Logical         max     current
        cylinders       16383   16383
        heads           16      16
        sectors/track   63      63
        --
        CHS current addressable sectors:   16514064
        LBA    user addressable sectors:  268435455
        LBA48  user addressable sectors: 5860533168
        Logical  Sector size:                   512 bytes
        Physical Sector size:                  4096 bytes
        Logical Sector-0 offset:                  0 bytes
        device size with M = 1024*1024:     2861588 MBytes
        device size with M = 1000*1000:     3000592 MBytes (3000 GB)
        cache/buffer size  = unknown
        Form Factor: 3.5 inch
        Nominal Media Rotation Rate: 7200
Capabilities:
        LBA, IORDY(can be disabled)
        Queue depth: 32
        Standby timer values: spec'd by Standard, no device specific minimum
        R/W multiple sector transfer: Max = 16  Current = 0
        Advanced power management level: disabled
        DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6
             Cycle time: min=120ns recommended=120ns
        PIO: pio0 pio1 pio2 pio3 pio4
             Cycle time: no flow control=120ns  IORDY flow control=120ns
Commands/features:
        Enabled Supported:
           *    SMART feature set
                Security Mode feature set
           *    Power Management feature set
           *    Write cache
           *    Look-ahead
           *    Host Protected Area feature set
           *    WRITE_BUFFER command
           *    READ_BUFFER command
           *    NOP cmd
           *    DOWNLOAD_MICROCODE
                Advanced Power Management feature set
                Power-Up In Standby feature set
           *    SET_FEATURES required to spinup after power up
                SET_MAX security extension
           *    48-bit Address feature set
           *    Device Configuration Overlay feature set
           *    Mandatory FLUSH_CACHE
           *    FLUSH_CACHE_EXT
           *    SMART error logging
           *    SMART self-test
                Media Card Pass-Through
           *    General Purpose Logging feature set
           *    WRITE_{DMA|MULTIPLE}_FUA_EXT
           *    64-bit World wide name
           *    URG for READ_STREAM[_DMA]_EXT
           *    URG for WRITE_STREAM[_DMA]_EXT
           *    WRITE_UNCORRECTABLE_EXT command
           *    {READ,WRITE}_DMA_EXT_GPL commands
           *    Segmented DOWNLOAD_MICROCODE
           *    unknown 119[7]
           *    Gen1 signaling speed (1.5Gb/s)
           *    Gen2 signaling speed (3.0Gb/s)
           *    Gen3 signaling speed (6.0Gb/s)
           *    Native Command Queueing (NCQ)
           *    Host-initiated interface power management
           *    Phy event counters
           *    NCQ priority information
                Non-Zero buffer offsets in DMA Setup FIS
           *    DMA Setup Auto-Activate optimization
                Device-initiated interface power management
                In-order data delivery
           *    Software settings preservation
           *    SMART Command Transport (SCT) feature set
           *    SCT Write Same (AC2)
           *    SCT Error Recovery Control (AC3)
           *    SCT Features Control (AC4)
           *    SCT Data Tables (AC5)
Security:
        Master password revision code = 65534
                supported
        not     enabled
        not     locked
        not     frozen
        not     expired: security count
        not     supported: enhanced erase
        492min for SECURITY ERASE UNIT.
Logical Unit WWN Device Identifier: 5000039fe3d3e51e
        NAA             : 5
        IEEE OUI        : 000039
        Unique ID       : fe3d3e51e
Checksum: correct
 
Old 12-18-2016, 09:29 PM   #2
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,818

Rep: Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144
I can't offer a lot of advice about hdparm, but I know not all HDD controllers work with it satisfactorily. Just in case this is helpful to you
http://www.htpcguides.com/spin-down-...-raspberry-pi/

It mentions alternatives such as 'hd-idle' or using 'sdparm' with a cron job to achieve similar power management behaviour.
 
1 members found this post helpful.
Old 12-18-2016, 09:36 PM   #3
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,818

Rep: Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144
BTW, from quick read of 'man hdparm' I wondered if power management needs to be enabled explicitly first
Quote:
-B
Get/set Advanced Power Management feature, if the drive supports it. A low value means aggressive power management and a high value means better performance. Possible settings range from values 1 through 127 (which permit spin-down), and values 128 through 254 (which do not permit spin-down). The highest degree of power management is attained with a setting of 1, and the highest I/O performance with a setting of 254. A value of 255 tells hdparm to disable Advanced Power Management altogether on the drive (not all drives support disabling it, but most do).
Check with
Code:
sudo hdparm -B /dev/sdb
If necessary set it with something like
Code:
sudo hdparm -B 127 /dev/sdb
 
1 members found this post helpful.
Old 02-26-2017, 08:06 PM   #4
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Original Poster
Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by ferrari View Post
I can't offer a lot of advice about hdparm, but I know not all HDD controllers work with it satisfactorily. Just in case this is helpful to you
http://www.htpcguides.com/spin-down-...-raspberry-pi/

It mentions alternatives such as 'hd-idle' or using 'sdparm' with a cron job to achieve similar power management behaviour.
It's only now that I took the time to try out the options. Nothing worked - with the exception of the refreshingly simple hd-idle, a 500-lines C program. Just by the way - hd-idle doesn't need cron; it puts itself in the background, monitors any access to the configured disk(s) and puts them into standby mode after the configured number of seconds. The disk then spins up immediately when it's accessed.

Everything else I tried, hdparm, sdparm, sg_start and directly writing into /sys/bus/usb/... or /sys/block/sdXYZ/device/.... , either didn't work at all or only worked for a few seconds, after which interval the disk spun up again. I don't know what those utilities do differently than hd-idle.

Last edited by berndbausch; 02-26-2017 at 08:07 PM.
 
1 members found this post helpful.
Old 02-26-2017, 08:48 PM   #5
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,818

Rep: Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144
Glad to read that hd-idle is working for your needs. It might be helpful to others who come searching.
 
  


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
xhci smart auto: Cannot enable port 1. Maybe the USB cable is bad? pverha10 Slackware 5 04-18-2015 08:29 AM
USB disk won't sleep under Slackware-14.1 ljb643 Slackware 2 12-01-2013 06:12 AM
[SOLVED] USB disk won't sleep under Slackware-14.0 ljb643 Slackware 4 10-31-2012 03:02 PM
I want to know usb-hard-disk is how to be auto mounted? zhoueryang Linux - Desktop 1 01-26-2010 05:06 AM
I messed up my usb external disk auto-mounting alek66 Ubuntu 14 05-28-2007 11:11 AM

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

All times are GMT -5. The time now is 02:15 AM.

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