Having trouble with sleeping the USB drive

10 posts
by CaptainFabulous » Sat May 11, 2013 3:30 pm

I have the RPI B running what I believe is Raspbian Wheezy. My intent is to use it as a NAS -- a low-powered always on file server that can be accessed by any device on my network, including multiple computers on various versions of Windows, a DLNA-equipped TV, multiple phones and an Android tablet (for right now, mostly the tablet).

Followed one of the many guides to get it set up, and after a sh*t ton of wrangling to get it all working (god damn do I #$Q@#$@ hate Samba and linux right now), and all devices (haven't tried the TV yet, I honestly don't have the strength right now) can read, write, and delete from the USB drive (Hitachi HTS721080G9A00 80 GB laptop drive attached via THIS), formatted as ext4 (soooo much faster to transfer files than NTFS or exFAT) and mounted via this command in fstab
Code: Select all
/dev/sda1  /media/video  ext4   defaults  0  1
But here's the thing, I can't get the drive to automatically standby/sleep, and I don't want it spinning all day long, especially since it's mostly only accessed at night. Using the command
Code: Select all
sudo hdparm -y /dev/sda
from a putty SSH shell the drive will spin down and stay down till accessed. So I know it *can* be put to sleep. But using the command
Code: Select all
sudo hdparm -S 60 /dev/sda
it says it successfully set the drive to automatically spin down after 5 minutes, but the drive doesn't actually ever spin down. I also tried hd-idle (default settings) and that also had no effect.

So I'm a bit flummoxed as to why this is happening. I could understand if the drive were being periodically accessed by some process, which would prevent it from automatically sleeping, but this doesn't seem to be the case cause when I manually shut it down it stays down. And obviously I don't want to have to ssh in every day to manually spin the drive down.

Any ideas as to why one works but not the other? Or better yet, a solution that actually get the drive to spin down on its own? I've thought about perhaps adding the manual spindown as a periodic chron job, but that's a.) inelegant and messy, and b.) I have no idea what would happen if the command was issued while the drive was actually in use (but from my current experience with linux I imagine the result would not be pretty).

I am open to suggestions and ideas. Thanks.
Posts: 5
Joined: Sat May 11, 2013 2:53 pm
by MaxK1 » Sat May 11, 2013 5:31 pm
Is that an APM BIOS function?
Posts: 561
Joined: Sun Aug 26, 2012 11:34 pm
by CaptainFabulous » Sat May 11, 2013 5:54 pm
MaxK1 wrote:Is that an APM BIOS function?

No idea. I've done a lot of reading and some people seem to have no trouble with hdparm or hd-idle, and for others it simply doesn't work at all. I don't know enough about Linux to have a clue why.

I could see if the drive didn't sleep at all. What gets me is that it *can* sleep if I tell it to, but it won't do it on its own. That's the part that's driving me to drink copious amounts of vodka.
Posts: 5
Joined: Sat May 11, 2013 2:53 pm
by MaxK1 » Sat May 11, 2013 6:16 pm
Sorry, I meant to ask if that function requires an APM BIOS.
Posts: 561
Joined: Sun Aug 26, 2012 11:34 pm
by MaxK1 » Sat May 11, 2013 6:18 pm
Not all drives support all functions. Try checking hdparm -I /dev/sd<whatever>
Posts: 561
Joined: Sun Aug 26, 2012 11:34 pm
by CaptainFabulous » Sat May 11, 2013 6:21 pm
I don't know. Since other people claim to have gotten it to work with their drives I assume the RPI's BIOS supports the necessary functions.
Posts: 5
Joined: Sat May 11, 2013 2:53 pm
by MaxK1 » Sat May 11, 2013 6:31 pm
There is NO bios on the pi.
Posts: 561
Joined: Sun Aug 26, 2012 11:34 pm
by CaptainFabulous » Mon May 13, 2013 8:40 pm
Code: Select all
pi@raspberrypi ~ $ sudo hdparm -I /dev/sda


ATA device, with non-removable media
        Model Number:       Hitachi HTS721080G9SA00
        Serial Number:      MPCDN7Y4HRVYZL
        Firmware Revision:  MC4OC10H
        Used: ATA/ATAPI-7 T13 1532D revision 1
        Supported: 7 6 5 4
        Logical         max     current
        cylinders       16383   16383
        heads           16      16
        sectors/track   63      63
        CHS current addressable sectors:   16514064
        LBA    user addressable sectors:  156301488
        LBA48  user addressable sectors:  156301488
        Logical/Physical Sector size:           512 bytes
        device size with M = 1024*1024:       76319 MBytes
        device size with M = 1000*1000:       80026 MBytes (80 GB)
        cache/buffer size  = 7538 KBytes (type=DualPortCache)
        LBA, IORDY(can be disabled)
        Queue depth: 32
        Standby timer values: spec'd by Vendor, no device specific minimum
        R/W multiple sector transfer: Max = 16  Current = 0
        Advanced power management level: 128
        Recommended acoustic management value: 128, current value: 254
        DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 *udma5
             Cycle time: min=120ns recommended=120ns
        PIO: pio0 pio1 pio2 pio3 pio4
             Cycle time: no flow control=240ns  IORDY flow control=120ns
        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
           *    Automatic Acoustic Management feature set
           *    48-bit Address feature set
           *    Device Configuration Overlay feature set
           *    Mandatory FLUSH_CACHE
           *    FLUSH_CACHE_EXT
           *    SMART error logging
           *    SMART self-test
           *    General Purpose Logging feature set
           *    WRITE_{DMA|MULTIPLE}_FUA_EXT
           *    Gen1 signaling speed (1.5Gb/s)
           *    Native Command Queueing (NCQ)
           *    Host-initiated interface power management
                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
        Master password revision code = 65534
        not     enabled
        not     locked
        not     frozen
        not     expired: security count
        not     supported: enhanced erase
        44min for SECURITY ERASE UNIT.
Checksum: correct
Posts: 5
Joined: Sat May 11, 2013 2:53 pm
by obcd » Tue May 14, 2013 9:20 am
Basically, the automatic spindown is a feature in the harddisk itself. Some manufactures provide a separate configuration tool that can be used to enable or disable that feature, and normally, once set, the harddisk should remember that setting. I have no idea if this setting can be changed on the fly and if the method to enable or disable it is the same for different brand of harddisks.
How does your harddisk behave if you connect it to a pc?
You could try a linux livecd distribution if you intend to experiment with it's parameters.
Posts: 908
Joined: Sun Jul 29, 2012 9:06 pm
by CaptainFabulous » Tue May 14, 2013 12:37 pm
Yeah, at this point I've pretty much given up. It might be the drive, it might be the USB bridge, I dunno, and I've invested way too much time into this and gotten no where. So let 'er spin. At the end of the day it's just not that big a deal. It bugs me, but I'm not going to waste any more time on it.
Posts: 5
Joined: Sat May 11, 2013 2:53 pm