1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SATA disk spins down too soon

Discussion in 'Tomato Firmware' started by streppuiu, Oct 1, 2012.

  1. streppuiu

    streppuiu Networkin' Nut Member

    I am using a 500gb WD scorpio blue notebook hdd attached to my e3000 through an sata-to-usb bridge. After accessing the disk (read a file) or even while downloading at slow speed on transmission, the disk spins down immediately causing the next access to be slow and causing a "clank" sound. With transmission, it continuously spins down and up when the download speed is slow.

    How could I prevent this ? Thank you.
     
  2. leandroong

    leandroong Addicted to LI Member

    In my opinion, harddisk are not good for router usage, too many issues. That is why I replace it using CF card. Now running 2 CF card, one for swap and optware, 2nd CF card for transmission FAT32 download. Perfect match with router, no problem whatsoever, using it for 6 months and very stable I would say plus low power consumption. Checkout ebay for CF card adaptor, IDE to usb.
    Note: don't buy single CF card adaptor support, has problem with remounting. Get CF adaptor that support 2 CF cards, this is what I'm using and no problem with mount/unmount issue.
     
  3. streppuiu

    streppuiu Networkin' Nut Member

    Well, CFs are very good but they are too small and too expensive. Are there any 500gb CFs out there? I haven't seen any.

    I also have an ide harddisk attached to the router and tried another external seagate drive. No mount issues with any of them. The ide does very well spin down and up when needed but the external seagate would not spin down and this WD sata drive spins down by itself too often.

    I believe the sata drive has some power saving system that spins it down too soon. Does anyone know anything about this? And if yes, is there a way to tweak the timeout until spindown?
     
  4. PBandJ

    PBandJ Networkin' Nut Member

    You "should" read about LCC (load cycle count). I had a similar problem with a WD Green HDD. At the time, I used a tool called widdle3 to fix it.
     
  5. koitsu

    koitsu Network Guru Member

    streppuiu, what you're describing is the firmware in the WD Scorpio Blue drive itself choosing to park the heads after a few seconds of idle time (the default based on my tests seems to be 8 seconds). During the next I/O request the drive has to un-park the heads. This issue repeats indefinitely. Western Digital drives track this in SMART attribute 193 (0xC1), or Load_Cycle_Count (often called "LCC" by Internet people).

    The WD Scorpio Blue drives are 2.5" drives intended to be used in laptops, so it is safe to say that the firmware of this drive is responsible; it is not something TomatoUSB (specifically the Linux kernel or libata) is doing.

    Do not use the IDLE3 utility on this drive. It is not sanctioned by Western Digital for use on that model, and there are known reports of people using it to "solve this problem" then finding their drive performance is catastrophically bad (keep reading / see my blog post, there's reference material in there showing this issue).

    The "LCC problem" happens on a lot of WD drives, but is mainly limited to 1) the Green drives, 2) any drive ending in -GP (stands for Green Power), and 3) any laptop/2.5" drive.

    I should also note it also happens on present-day Seagate disks (such as the ST3000DM001, ST2000DM001, etc.), except they don't bother to track the attribute in SMART, so all you end up hearing is screech/clonk over and over. Seagate has been avoiding discussing this issue despite hundreds of people on their forums complaining about it.

    All that said: I've written extensively about this problem. On the WD Scorpio Blue you might be able to disable APM to work around the "LCC problem", but on other drive models APM is not toggleable (read my blog post slowly and in full, do not skim it, to understand). You would need a build of the utility called hdparm for Linux to be able to try toggling APM on the drive.

    Overall I have been recommending people purchase WD Red drives (WD10EFRX / WD20EFRX / WD30EFRX) which do not suffer from this behaviour. I've also written extensively about those drives and how they behave/perform properly like a drive should.
     
  6. PBandJ

    PBandJ Networkin' Nut Member

    I used wdidle3 on a couple of WD10EARS drives without a problem two years ago. I didn't disable it, just increased the time-out to 5 minutes.
    And it was a pain to use.
     
  7. koitsu

    koitsu Network Guru Member

    To clarify: even if a person used IDLE3 on drives "without problems", there are already confirmed problems where it can/does destroy performance on a drive. Secondly, and as I said, Western Digital does not state the utility can be used on those models of drives. This is why I do not advocate use of the utility. If WD's documentation is wrong regarding which drives IDLE3 is compatible with, then someone needs to contact WD Support and bring this issue to their attention -- but I'm of the opinion that all the users on WD's forums complaining about the problem would have warranted WD Support to update their FAQ by now (this issue has existed for many years). So I'm inclined to believe that the utility should not be used on drives other than those WD blesses it safe to be used on.
     
  8. streppuiu

    streppuiu Networkin' Nut Member

    Thanks all of you for your snswers. My disk is WD5000LPVT.

    Koitsu, I have a few new questions:

    1. I had a look at your blog and read that article you wrote but I couldn't figure out what command you used to get the screen that lits all those drive properties and capabilities (including if apm is supported).I would like to know if my disk supports apm.

    2. What is the connection between LCCs and APM. The fist is about head parking while the second is about power management, 2 different things I think.

    2. I have hdparm for tomatousb and am ready to use it but I am not sure about what value should I associate to its -B switch (should be between 0 and 255 as I understood). I wouldn't want to disable the capability of tomatoUSB to spin down the drive when idle for a longer time.

    3. If I use hdparm, will I have to put the command in a startup script to run it every time the router starts up?

    3. I also found a few cases where they used wdidle3 to disable lcc on different drives that those recommended by wd and had problems. How about only increasing the timeout to its maximum of 5 minutes? Would it also create problems? I know there is a risk involved here because my disk is not in wd's blessing for this application but what should I do if nothing else works?


    PS: nevermind about #2, I found the answer: head parking reduces power consumption.
     
  9. koitsu

    koitsu Network Guru Member

    1. smartctl, which comes with smartmontools. You won't find this command natively available in any embedded firmware release (DD-WRT, Tomato/TomatoUSB, OpenWRT). Entware does offer this, but it's a very, VERY old version (in fact, so old that I wouldn't even recommend using it).

    2. Sadly they are not two different things. On earlier models of drives, you can inhibit the repeated parking-of-heads (which is the "LCC issue") by disabling APM. This is because WD chose to implement said feature as a subset of the T13-defined APM standard. So even though the "concepts" are two different things, by disabling one you can have an effect on the other. Make more sense?

    3. You want a value of 255 which disables APM. This is documented in the hdparm man page.

    4. Yes you will, and you should be very careful in doing so. There may be times where you reboot your router without the drive attached. Write your shell script intelligently.

    5. I have no comment for this, other than the very last part: "what should I do if nothing else works?" Simple: purchase a model of hard disk that doesn't behave this way. Please re-read comment #5 slowly/in full to get an idea of what you should/should not buy.

    Good luck.
     
  10. koitsu

    koitsu Network Guru Member

    BTW, something I should note about smartmontools when working with disks attached via a USB-SATA bridge: the support is not very great. Many bridges do not support SMART command pass-through (the bridge itself blocks the ATA CDB of that type), while others (such as very specific JMicron bridges) work because smartmontools contains code to work around the nuances. So I make no guarantees that smartmontools will even work with a USB-attached disk; YMMV. You may need to use the -d usbjmicron flag.
     
  11. streppuiu

    streppuiu Networkin' Nut Member

    1. smartmontools for tomatousb optware contains smartctl and I already used it to list Load_Cycle_Count and the other attributes values. I used the -auto option. My lcc showed a value around 9000. But I need to see the list that in your blog post begins with "protocol ATA/ATAPI-8 SATA 3.x". I do not understand what this means: "Per the ATA specification IDENTIFY command". This list shows the capabilities of the hdd. What is the exact command line (including parameters) for smatctl in order to get that screen?

    2. Yes, I understand now.

    3. But if I disable APM (by setting the value to 255) will tomatousb be able to spin the disk down after an idle period ? I think tomatousb uses scsi-stop in order to do this.

    4. OK, I will

    5. OK, thanks
     
  12. koitsu

    koitsu Network Guru Member

    1. Ah, that, yes sorry. That comes from FreeBSD's camcontrol (or if you're using the older ATA driver, atacontrol) utility. The only utility I know of which can compare to this on Linux is hdparm. All of the information returned is taken from the ATA protocol IDENTIFY command; it's nothing "FreeBSD-specific". I believe what you want is hdparm -i, but the output is in no way formatted as elegantly as FreeBSDs, and I'm fairly sure it outputs significantly less information when it comes to drive features.

    3. With APM disabled the drive should still support standard PM features such as disk standby when initiated by the OS -- that includes such commands as ATA STANDBY (this is what you're likely referring to) and ATA SLEEP (this puts the disk to sleep permanently and usually requires a power-cycle). I've found random pieces of documentation online talking about "scsi-stop" as well as something called "scsi_stop" (note underscore), but the details of what it actually does protocol-wise are little to none. I did find mention of a command called sg_start which issues a SCSI START STOP DEVICE CDB to the drive; what the Linux kernel's SCSI emulation layer translates this to, ATA-wise (meaning if it chooses ATA STANDBY or ATA SLEEP) is unknown to me. You will need to experiment.
     
    streppuiu likes this.
  13. streppuiu

    streppuiu Networkin' Nut Member

    Thank you very much, koitsu for all explanations. I will try it out and let you know.
     
  14. streppuiu

    streppuiu Networkin' Nut Member

    OK, here is what I got the first time I ran hdparm:

    hdparm -B 255 /dev/sdc

    /dev/sdc:
    setting Advanced Power Management level to disabled
    SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    APM_level = 43

    And then, I ran again the same command and here is what I got:

    hdparm -B 255 /dev/sdc

    /dev/sdc:
    setting Advanced Power Management level to disabled
    SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    APM_level = not supported

    And the disk behaves just like before. Is there something else I could try?
     
  15. koitsu

    koitsu Network Guru Member

    Have you confirmed that the drive and/or its enclosure (since there is a USB-to-SATA bridge involved) actually allow for the toggling of APM? The drive may, but the enclosure may not permit/pass those CDBs down to the drive. If the drive doesn't allow it, then it will either return an ATA CDB error result when told to disable APM, or it will silently ignore it. Confirming the ability to adjust APM should have been the first step.

    I'm not sure what to make of the errors being shown there. I'm guessing it's SCSI sense data (SK/ASC/ASCQ), and because of the SCSI-to-ATA translation layer in Linux (either SAT or libata; don't know which), makes seeing the actual ATA result difficult. Meaning I can't tell if the kernel is rejecting the CDB, if the drive or enclosure is rejecting the CDB, or if it's just like "hehehehe I like snakes". I really can't tell. It's not enough information (thanks, Linux).

    The ATA CDB to toggle APM is command 0xEF (SET FEATURES). There are two subcommands that can be used: either subcommand 0x05 (set APM level, where level 0xFF is considered "reserved" but some drives use this to disable APM), or subcommand 0x85 (officially "disable APM" per spec). You can read the ATA8-ACS specification yourself (see section 7.47) to get an understanding.

    What I'm saying is that the SCSI-to-ATA translation layer may be getting in the way (kernel bug, missing feature in the kernel, etc.), or the USB-to-SATA bridge may be rejecting whatever the real ATA CDB is. I really don't know.

    Two other things you could try, and if neither of these work, I cannot help past this point:

    1. Try using hdparm -Z instead. This is mainly for Seagate disks but it won't hurt anything if you try it.
    2. Try hdparm --prefer-ata12 -B 255 instead. I strongly doubt this will have any effect; I understand what the flag does, but it's unlikely it has any relevancy given that most drives and enclosures today advocate 48-bit addressing, not 28.
     

Share This Page