FollowingGhosts
Posts: 29
Joined: Sun Feb 05, 2012 5:55 pm

Spinning down HDD?

Thu May 17, 2012 10:08 pm

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

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: Spinning down HDD?

Thu May 17, 2012 10:59 pm

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.

User avatar
SN
Posts: 1014
Joined: Mon Feb 13, 2012 8:06 pm
Location: Romiley, UK
Contact: Website

Re: Spinning down HDD?

Thu May 17, 2012 11:05 pm

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....
Steve N – binatone mk4->intellivision->zx81->spectrum->cbm64->cpc6128->520stfm->pc->raspi ?

summers
Posts: 63
Joined: Mon Jan 30, 2012 4:27 pm

Re: Spinning down HDD?

Fri May 18, 2012 10:34 am

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.

FollowingGhosts
Posts: 29
Joined: Sun Feb 05, 2012 5:55 pm

Re: Spinning down HDD?

Fri May 18, 2012 12:15 pm

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...

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5341
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Spinning down HDD?

Fri May 18, 2012 12:26 pm

Have you tried sdparm?
[moderator removed outdated link]

FollowingGhosts
Posts: 29
Joined: Sun Feb 05, 2012 5:55 pm

Re: Spinning down HDD?

Fri May 18, 2012 12:28 pm

Yep, it didn't have the standby command listed unfortunately

summers
Posts: 63
Joined: Mon Jan 30, 2012 4:27 pm

Re: Spinning down HDD?

Fri May 18, 2012 6:25 pm

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 ...

FollowingGhosts
Posts: 29
Joined: Sun Feb 05, 2012 5:55 pm

Re: Spinning down HDD?

Fri May 18, 2012 6:29 pm

SG_IO errors, considering it's a laptop HDD, I'd expect it to work with sleep...

davepi
Posts: 1
Joined: Wed Jun 06, 2012 10:01 pm

Re: Spinning down HDD?

Wed Jun 06, 2012 10:06 pm

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!

Canasta
Posts: 3
Joined: Mon Oct 01, 2012 12:46 pm

Re: Spinning down HDD?

Tue Oct 02, 2012 9:32 pm

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.

User avatar
malakai
Posts: 1382
Joined: Sat Sep 15, 2012 10:35 am
Contact: Website

Re: Spinning down HDD?

Tue Oct 02, 2012 10:04 pm

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
http://www.raspians.com - always looking for content feel free to ask to have it posted. Or sign up and message me to become a contributor to the site. Raspians is not affiliated with the Raspberry Pi Foundation. (RPi's + You = Raspians)

stevech
Posts: 144
Joined: Sun Jul 15, 2012 11:53 pm

Re: Spinning down HDD?

Wed Oct 03, 2012 2:30 am

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.

User avatar
Dweeber
Posts: 606
Joined: Fri Aug 17, 2012 3:35 am
Location: Mesa, AZ
Contact: Website

Re: Spinning down HDD?

Sat Oct 06, 2012 10:51 pm

All of the media my RPi accesses is via a NAS using the WiFi (no LAN) with a mounted partition(s).
Dweeber A.K.A. Kevin...
My RPI Info Pages including Current Setup - http://rpi.tnet.com

Helaas
Posts: 6
Joined: Mon Jul 02, 2012 7:07 pm

Re: Spinning down HDD?

Thu Oct 25, 2012 11:28 am

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.

jago25_98
Posts: 25
Joined: Wed Aug 22, 2012 6:05 pm

Re: Spinning down HDD?

Thu Jul 11, 2013 8:29 pm

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?

User avatar
rpdom
Posts: 15426
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Spinning down HDD?

Fri Jul 12, 2013 8:56 am

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)

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: Spinning down HDD?

Mon Jul 15, 2013 9:19 pm

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

jago25_98
Posts: 25
Joined: Wed Aug 22, 2012 6:05 pm

Re: Spinning down HDD?

Mon Jul 15, 2013 10:16 pm

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...

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: Spinning down HDD?

Tue Jul 16, 2013 8:50 pm

My usb hdd is mounted through fstab, my problem is that it only spindown when the command is run and not after x seconds :(

permaband
Posts: 62
Joined: Wed Aug 01, 2012 2:14 pm
Location: uk
Contact: Website

Re: Spinning down HDD?

Sat Aug 24, 2013 4:05 pm

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

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: Spinning down HDD?

Tue Aug 27, 2013 7:16 am

Great!
I'm going to try this as soon as possible!
Thanks!

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: Spinning down HDD?

Wed Jan 08, 2014 11:16 pm

I had to restart from scratch and now I'm not able to install sdparm from apt-get (raspbian jessie).
Any hints?

User avatar
DougieLawson
Posts: 36322
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Spinning down HDD?

Wed Jan 08, 2014 11:27 pm

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.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: Spinning down HDD?

Wed Jan 08, 2014 11:36 pm

Can I move sorces.list back to wheezy and install sdparm with apt-get?


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

Return to “General discussion”