Page 1 of 2

Spinning down HDD?

Posted: Thu May 17, 2012 10:08 pm
by FollowingGhosts
I've hunted around on various forums but everything seems distro specific.
I'm running the latest debian image from a USB Laptop HDD and want it to spin down when idle for a period of time so the drive doesn't end up dying on me.
I've tried HDParam on it but get SG_IO bad/missing sense data.
Any input is appreciated

Re: Spinning down HDD?

Posted: Thu May 17, 2012 10:59 pm
by AndrewS
Lots of useful info at http://www.nslu2-linux.org/wiki/FAQ/Spi ... BHarddisks
I think the ability to spin down depends on both the HDD, and the USB<->HDD interface controller.

Re: Spinning down HDD?

Posted: Thu May 17, 2012 11:05 pm
by SN
when you get the answer let me know - this was another roadblock on my previous SLUG centred attempt on a silent, low power, near-zero-moving-part home server....

Re: Spinning down HDD?

Posted: Fri May 18, 2012 10:34 am
by summers
Yes hdparm is he way to do this. Can make things a tad unstable, when the OS tries to access the hard disk, and it needs to spin up first, things time out.

There are various flags you can pass, -y -Y -s -S, read the man page.

Not all hard drive take all options - but you might as well try. Usually some work.

Re: Spinning down HDD?

Posted: Fri May 18, 2012 12:15 pm
by FollowingGhosts
I tried all night last night, but HDParm kept giving me errors, so I'm tempted to try it in an old USB/SATA bridge from a TrekStor caddy that behaved quite well, in terms of spinning itself down...

Re: Spinning down HDD?

Posted: Fri May 18, 2012 12:26 pm
by dom
Have you tried sdparm?
[moderator removed outdated link]

Re: Spinning down HDD?

Posted: Fri May 18, 2012 12:28 pm
by FollowingGhosts
Yep, it didn't have the standby command listed unfortunately

Re: Spinning down HDD?

Posted: Fri May 18, 2012 6:25 pm
by summers
FollowingGhosts wrote:I tried all night last night, but HDParm kept giving me errors ...
what errors out of interest

I've usually found errors are bcause the HDD doesn't support some options ...

Re: Spinning down HDD?

Posted: Fri May 18, 2012 6:29 pm
by FollowingGhosts
SG_IO errors, considering it's a laptop HDD, I'd expect it to work with sleep...

Re: Spinning down HDD?

Posted: Wed Jun 06, 2012 10:06 pm
by davepi
Hi
Just been playing around to get my pi set up as a simple NAS and will be syncing files daily for backup. I'm completely new to Linux so it's taken a bit of time to get it working (lot's of reading!), but have managed to get my external HDD to spin down (which never used to even with my Windows machine I use everyday).

At boot I'm running sudo /sbin/hdparm -S120 /dev/sda1 . This shuts down the drive after 10 minutes. When I try to open a folder on the mapped drive, it spins up and allows me to access my files. No errors so far!

For me, this project has proved the value of the Pi - in that it has reignited my enjoyment with playing around with computers - rather than just using them!

Re: Spinning down HDD?

Posted: Tue Oct 02, 2012 9:32 pm
by Canasta
I was trying to get my WD My Passport 500GB drive to spin down after 10minutes in Openelec.

I tried various hdparm commands, and found that while I could read various settings from the drive, I could not write any settings back to the drive.

I wanted the drive to power down after 10 idle minutes, in the end the easiest way for me to set this was to connect the drive to a Windows PC, load up the WD Smartware software, and from there set the sleep timer to 10mins.

It worked, when I connected the drive back onto my raspberry pi, it spun down properly after 10 idle minutes.

Re: Spinning down HDD?

Posted: Tue Oct 02, 2012 10:04 pm
by malakai
I have no idea what the following post is fully about but it seems to have something in it I hope this is helpful if not sorry.

http://www.raspberrypi.org/phpBB3/viewt ... 26&t=18626

Re: Spinning down HDD?

Posted: Wed Oct 03, 2012 2:30 am
by stevech
Solid State Disks are getting cheap. $50 or less now for 64GB. $80 or so for 128GB

In my case, the RPi just uses SMB to access shares on my small NAS via the LAN or WiFi LAN.

Re: Spinning down HDD?

Posted: Sat Oct 06, 2012 10:51 pm
by Dweeber
All of the media my RPi accesses is via a NAS using the WiFi (no LAN) with a mounted partition(s).

Re: Spinning down HDD?

Posted: Thu Oct 25, 2012 11:28 am
by Helaas
I am using an old (7 years?) WD 320 GB Drive with an ICIDU USB3.0 enclosure I picked up at the store yesterday. Gave it a shot.

The persist through reset flags give a bunch of errors:

Code: Select all

sudo hdparm -k1 -K1 -S120 /dev/sda
/dev/sda:
 setting keep_settings to 1 (on)
 HDIO_SET_KEEPSETTINGS failed: Invalid argument
 setting drive keep features to 1 (on)
 HDIO_DRIVE_CMD(keepsettings) failed: Input/output error
 setting standby to 120 (10 minutes)
 HDIO_GET_KEEPSETTINGS failed: Invalid argument
Running the command without additional flags works fine however:

Code: Select all

pi@raspberrypi ~ $ sudo hdparm  -S120 /dev/sda

/dev/sda:
 setting standby to 120 (10 minutes)
I can hear it spin down after 10 minutes now.

To set this setting every time the pi boots, I have edited /etc/hdparm.conf:

Code: Select all

/dev/sda {
        spindown_time = 120
}
This is untested as my pi has a few things running and can't just be rebooted. Should work in theory though.

Re: Spinning down HDD?

Posted: Thu Jul 11, 2013 8:29 pm
by jago25_98
To save the sanity of anyone who found this thread...
sometimes the USB controller doesn't support telling the HDD to spindown... thus (if you haven't broken your HDD through overheating already) you need to buy a new USB HDD controller that supports spinning down...

the only question is.... how do you find a cheap USB controller for a 2.5" drive that supports the spindown command?

Re: Spinning down HDD?

Posted: Fri Jul 12, 2013 8:56 am
by rpdom
jago25_98 wrote:how do you find a cheap USB controller for a 2.5" drive that supports the spindown command?
I use a USB to 3.5"PATA/2.5"PATA/SATA adaptor with a Jmicron chip. They are very common and cheap on ebay from china (around 2 quid).

I just tested to see if it supports the spindown settings, and, although hdparm did give a "failed: Invalid argument" message, the setting did work.

Code: Select all

debian:~# hdparm -S5 /dev/sdb

/dev/sdb:
 setting standby to 5 (25 seconds)
 HDIO_DRIVE_CMD(setidle) failed: Invalid argument
(I tried this on my Debian laptop, as my Pi is busy doing other things)

Re: Spinning down HDD?

Posted: Mon Jul 15, 2013 9:19 pm
by mcgyver83
I'm trying to do achive the external usb hdd spin down.
Each hdparm command always return "SG_IO: bad/missing sense data, sb[]: "

Code: Select all

sudo hdparm -S5 /dev/sda
/dev/sda:
 setting standby to 5 (25 seconds)
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
Someone is able to suggest me how to spin down my external usb hdd?

I found out that the "error" message is something normal :D

I tried

Code: Select all

sudo hdparm -Y /dev/sda

/dev/sda:
 issuing sleep command
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

sudo hdparm -C /dev/sda

/dev/sda:
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
 drive state is:  standby
but the drive still turn :(

Another edit:
with

Code: Select all

sudo sg_start --stop /dev/sda
or

Code: Select all

sudo sdparm --command=stop /dev/sda
the drive immediatly stop turning and wake up when need..
Now I have to understand how to configure a delay to run this command and how to run it :D

Re: Spinning down HDD?

Posted: Mon Jul 15, 2013 10:16 pm
by jago25_98
Great to be getting somewhere on this:

Code: Select all

sudo sg_start --stop /dev/hdc
does spin down the drive for me but then it spins straight up again. The drive isn't mounted so I can't see anything trying to access it...

Re: Spinning down HDD?

Posted: Tue Jul 16, 2013 8:50 pm
by mcgyver83
My usb hdd is mounted through fstab, my problem is that it only spindown when the command is run and not after x seconds :(

Re: Spinning down HDD?

Posted: Sat Aug 24, 2013 4:05 pm
by permaband
mcgyver83 wrote:My usb hdd is mounted through fstab, my problem is that it only spindown when the command is run and not after x seconds :(
Check this out: http://www.botcyb.org/2009/04/making-in ... -down.html

Re: Spinning down HDD?

Posted: Tue Aug 27, 2013 7:16 am
by mcgyver83
Great!
I'm going to try this as soon as possible!
Thanks!

Re: Spinning down HDD?

Posted: Wed Jan 08, 2014 11:16 pm
by mcgyver83
I had to restart from scratch and now I'm not able to install sdparm from apt-get (raspbian jessie).
Any hints?

Re: Spinning down HDD?

Posted: Wed Jan 08, 2014 11:27 pm
by DougieLawson
mcgyver83 wrote:I had to restart from scratch and now I'm not able to install sdparm from apt-get (raspbian jessie).
Any hints?
I reckon you're going to have to pull the source code and compile it.

Re: Spinning down HDD?

Posted: Wed Jan 08, 2014 11:36 pm
by mcgyver83
Can I move sorces.list back to wheezy and install sdparm with apt-get?


Compilation done :D
Usb external HD now is silent :D