Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Howto spin down HD when idle?
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
finr
Tux's lil' helper
Tux's lil' helper


Joined: 24 Feb 2004
Posts: 126

PostPosted: Wed Mar 17, 2004 2:54 pm    Post subject: Howto spin down HD when idle? Reply with quote

Hi all!

My PC is pretty much running all day long, even when I'm not working on it. So I figured my HDs would have a longer life if they were spinned down after eg 30 minutes of inactivity.
The problem is that I don't really know where to start configuring things. I know that hdparm -S should do the job, but I've read a few things in here and most pointed to things like APM and ACPI. ACPI is supported on my machine, and even powering the PC off after shutdown mostly works, but I couldn't figure out how to configure acpid to spin down my HDs, and I even don't know if this is acpid's duty or if hdparm -S should be sufficient...

I'd be grateful if someone could give me a quick explanation as for which tool is the right one to use, and even better, how to use it ;)

BTW: I'm running the gentoo-dev-sources (2.6.3) here...

TIA!
finr
Back to top
View user's profile Send private message
adaptr
Watchman
Watchman


Joined: 06 Oct 2002
Posts: 6730
Location: Rotterdam, Netherlands

PostPosted: Wed Mar 17, 2004 3:05 pm    Post subject: Reply with quote

You can't normally shut down a drive that runs Linux, since the loggers write to it every so often - about once a minute I think.
So not only would you have to configure the HD spindown, but you would have to tweak things so the log files don't get written to more than say once per every few hours.

On a production system this is really not feasible, on a server it is suicide.

Why would you want to do this ?
If the system is truly idle, why not turn it off ?

The average HD doesn't consume much power - in the range of 5-8 Watts max.
And its life may actually be prolonged by not switching it on and off more than you have to.
_________________
>>> emerge (3 of 7) mcse/70-293 to /
Essential tools: gentoolkit eix profuse screen
Back to top
View user's profile Send private message
finr
Tux's lil' helper
Tux's lil' helper


Joined: 24 Feb 2004
Posts: 126

PostPosted: Wed Mar 17, 2004 3:49 pm    Post subject: Reply with quote

adaptr wrote:
Why would you want to do this ?
If the system is truly idle, why not turn it off ?

Well, it's more or less idle. It's in my room on campus and most of the time I don't need it, but from time to time I need to access it remotly, so I keep it running.

adaptr wrote:
And its life may actually be prolonged by not switching it on and off more than you have to.

Hm... I didn't think of that... Kinda makes sense, though ;)
Back to top
View user's profile Send private message
primero.gentoo
Guru
Guru


Joined: 23 Dec 2003
Posts: 402

PostPosted: Wed Mar 17, 2004 4:02 pm    Post subject: Reply with quote

adaptr wrote:
have to tweak things so the log files don't get written to more than say once per every few hours.



This is exactly what i need... i'm using syslog-ng now, do you know how can i do this???

Bye
Primero
Back to top
View user's profile Send private message
adaptr
Watchman
Watchman


Joined: 06 Oct 2002
Posts: 6730
Location: Rotterdam, Netherlands

PostPosted: Wed Mar 17, 2004 7:00 pm    Post subject: Reply with quote

If you Google for it you'll get plenty of pointers.
IIRC it does involve some advanced tweaking to make sure the kernel doesn't log critical or incidental stuff - which you can't normally stop (for very good reasons!)
_________________
>>> emerge (3 of 7) mcse/70-293 to /
Essential tools: gentoolkit eix profuse screen
Back to top
View user's profile Send private message
davidblewett
Apprentice
Apprentice


Joined: 15 Feb 2004
Posts: 274
Location: Indiana

PostPosted: Wed Mar 17, 2004 8:54 pm    Post subject: Reply with quote

Try using hdparm. You can use it to set a hard drive to power off after a certain period of time. I have it set on my 2nd hard drive, that contains my backups and mp3s. Since it's only accessed intermittently, it made sense for me to do that... I'm not sure of the exact switch, try man hdparm.
Back to top
View user's profile Send private message
SIR
n00b
n00b


Joined: 12 Jun 2003
Posts: 71
Location: DMCA and RIAA Land

PostPosted: Wed Mar 17, 2004 9:31 pm    Post subject: Reply with quote

davidblewett wrote:
Try using hdparm. You can use it to set a hard drive to power off after a certain period of time. I have it set on my 2nd hard drive, that contains my backups and mp3s. Since it's only accessed intermittently, it made sense for me to do that... I'm not sure of the exact switch, try man hdparm.


I think the flag is -S.
_________________
K6-2 333 160MB
gentoo-dev-sources 2.6.8-r3
Back to top
View user's profile Send private message
Rainmaker
Veteran
Veteran


Joined: 12 Feb 2004
Posts: 1650
Location: /home/NL/ehv/

PostPosted: Wed Mar 17, 2004 9:55 pm    Post subject: Reply with quote

Why not just use the BIOS settings?

as long as you've configured you're kernel with APM support, this should work
Back to top
View user's profile Send private message
lightvhawk0
Guru
Guru


Joined: 07 Nov 2003
Posts: 388

PostPosted: Wed Mar 17, 2004 11:11 pm    Post subject: Reply with quote

write a script that checks to see if login is running and if its not it would do a hdparm -y /dev/hdXX. and you could use a cron job to make it run every hour.

This would make it so that every hour it sees if you or root is logged in. if your not it will shut down your hdd
_________________
If God has made us in his image, we have returned him the favor. - Voltaire
Back to top
View user's profile Send private message
adaptr
Watchman
Watchman


Joined: 06 Oct 2002
Posts: 6730
Location: Rotterdam, Netherlands

PostPosted: Thu Mar 18, 2004 8:36 am    Post subject: Reply with quote

davidblewett wrote:
Try using hdparm. You can use it to set a hard drive to power off after a certain period of time. I have it set on my 2nd hard drive, that contains my backups and mp3s. Since it's only accessed intermittently, it made sense for me to do that... I'm not sure of the exact switch, try man hdparm.

And this is exactly what doesn't work.
The loggers write to the disk every so often, which is not under your direct control - certainly not under the control of hdparm.
All you can achieve with that is to make it spin down temporarily - and have the system spin it up as soon as it wants to write 3 bytes to a log file...
_________________
>>> emerge (3 of 7) mcse/70-293 to /
Essential tools: gentoolkit eix profuse screen
Back to top
View user's profile Send private message
daemonknight
n00b
n00b


Joined: 19 Nov 2003
Posts: 16
Location: London

PostPosted: Thu Mar 18, 2004 1:14 pm    Post subject: DR Note Reply with quote

Hi there,

I work at a Data Recovery company, just to note that it is not always the best thing to shutdown your drive the whole time to extend it's life....the most stress that the drive can go through is when you power it up...if you are needing to have a machine on most of the day then I would definatly advise you to keep it spinning.

Thanks
_________________
This is linux Country......on a quiet night you can hear windows reboot!
Back to top
View user's profile Send private message
steima
n00b
n00b


Joined: 27 Sep 2003
Posts: 18
Location: Austria

PostPosted: Thu Mar 18, 2004 3:05 pm    Post subject: noflushd is the clue Reply with quote

OK ... the lifetime of a harddisc would be much higher if it would spin all day and all night.

but fast harddiscs are noisy!

I had the same problem with my little server in my flat. My flat is quite small an especially at night I don't want to hear the hard disc.

So noflushd (eventually in combination with hdparm -S) is the clue. noflushd prevents the flushdeamon to flush every write to disc.
You have to know that systemloggers and so on usually only WRITE to the disc but not read it.

noflushd allows those processes to write to disc but it flushes only if really necessary. If there is a process which reads data from the disc it is spun up and also all unflushed buffers get flushed to disc and of course if the buffer is full the disc is also spun up and everything is flushed to disc.

an emerge noflushd .. installed my noflushd

and you can configure it in /etc/conf.d/noflushd .. as I can remember.

Sometimes noflushd does not spin down the discs ... so you have to set the timeout value for spindown "manualy" with hdparm -S.

I've set the timeoutvalue from hdparm 1 minute higher than from noflushd.
So after 15 mins noflushd prevents funny writting to disc and after 16 mins the harddics is acutally spun down.

As systemlogger I use metalog. It supports buffered writing of the log files anyway so I specified 25 records to be buffered before writing them to disc.

So if I don't use my server a whole day my harddiscs only spin up for doing a backup.
_________________
www.steinbauer.org is a LAMP server ;-)
Back to top
View user's profile Send private message
steima
n00b
n00b


Joined: 27 Sep 2003
Posts: 18
Location: Austria

PostPosted: Fri Mar 19, 2004 7:21 am    Post subject: what I have forgotten Reply with quote

DO NOT USE NOFLUSHD WITH JOURNALING FILE SYSTEMS

ext2 would do the job

on the one hand a journaling filesystem is prevented to write journal logs ... this is usually a very very bad thing.
on the other hand your harddisc would spin up an down all the time because there are always some blocks read from disc when updating the journal.

and I've read somewhere .. that with one of the journaling fs noflushd doesnt work at all.

matthias
_________________
www.steinbauer.org is a LAMP server ;-)
Back to top
View user's profile Send private message
mlybarger
Guru
Guru


Joined: 04 Sep 2002
Posts: 480

PostPosted: Wed Mar 31, 2004 2:51 am    Post subject: Reply with quote

so what's the conclusion here on how to spin down a non use hdd? (can't the system itself in general be put to sleep, ie, cache all ram to hdd, and sleep the main system?) how? maybe a guide somewhere... humm....
Back to top
View user's profile Send private message
steima
n00b
n00b


Joined: 27 Sep 2003
Posts: 18
Location: Austria

PostPosted: Wed Mar 31, 2004 6:40 am    Post subject: suspend to ram Reply with quote

as far as i know suspend to ram works quite well with kernel 2.6 systems.

but ... the system is available faster if you just spin down the harddisc. especially for servers it is highly recommended to keep them running ;-)
_________________
www.steinbauer.org is a LAMP server ;-)
Back to top
View user's profile Send private message
mlybarger
Guru
Guru


Joined: 04 Sep 2002
Posts: 480

PostPosted: Wed Mar 31, 2004 10:35 am    Post subject: Reply with quote

do you know where to find a good doc on how to set this up and what is required? i assume if the system is suspended, then things like cron jobs just don't get executed? how about if remote system suddenly tries to access the nfs mount? does system wake up? maybe this is why my NIC's have a wol connector?

really, i'm at work all day long most days and the systems sit here on doing nothing. heck, most nights they do nothing ;). it would be nice if they could suspend w/o having to actually boot up. sure it'll take some time to wake up, but w/o the boot process.
Back to top
View user's profile Send private message
steima
n00b
n00b


Joined: 27 Sep 2003
Posts: 18
Location: Austria

PostPosted: Wed Mar 31, 2004 11:55 am    Post subject: Reply with quote

i did never try suspend to ram functionality but im sure that features like wake on lan would work too.

cron jobs could eventually get executet with the mechanism of acpi alarms. as far as i know these alarms are programmed to a timer component of the acpi subsystem. acpi should wake your computer if a alarm occures ... but dont ask me if that really works!
_________________
www.steinbauer.org is a LAMP server ;-)
Back to top
View user's profile Send private message
odegard
Guru
Guru


Joined: 08 Mar 2003
Posts: 324
Location: Trondheim, NO

PostPosted: Wed Mar 31, 2004 1:12 pm    Post subject: Reply with quote

Use the B flag.

Code:

hdparm -B0 /dev/hda
hdparm -B255 /dev/hda


First one is the most aggressive setting turning the drive off almost immediately after access, 255 is the least aggressive. I use this on my old laptop as the drive is very very noisy. It does *not* power up every minute to write to some log.
Back to top
View user's profile Send private message
Bob P
Advocate
Advocate


Joined: 20 Oct 2004
Posts: 3374
Location: USA

PostPosted: Mon Jan 31, 2005 5:16 pm    Post subject: Reply with quote

you can use the "hdparm -Sxxx" parameter to control the elapsed time between drive inactivity and spindown.
Back to top
View user's profile Send private message
Jerem
Apprentice
Apprentice


Joined: 11 Jun 2004
Posts: 177

PostPosted: Mon Jan 31, 2005 6:22 pm    Post subject: Reply with quote

Code:
emerge cpudyn


Cpudyn is an alternative to speedfreq or cpufreqd, with the advantage of being able to manage HD spin speeds.
Back to top
View user's profile Send private message
darklegion
Guru
Guru


Joined: 14 Nov 2004
Posts: 468

PostPosted: Tue Feb 01, 2005 3:20 am    Post subject: Reply with quote

Couldn't you just use tmpfs to redirect logging direclty to ram instead of a hdd,thus eliminating the hdd to spin up every few minutes but still keeping possible critical logs visible?
Back to top
View user's profile Send private message
Bojan
Tux's lil' helper
Tux's lil' helper


Joined: 18 Oct 2004
Posts: 145
Location: € Matrix

PostPosted: Tue Feb 01, 2005 11:44 am    Post subject: Re: Howto spin down HD when idle? Reply with quote

finr wrote:
So I figured my HDs would have a longer life if they were spinned down after eg 30 minutes of inactivity.


You can go through lots of trouble and finally make hdparm to spin down the hdd for more than a few minutes (until some logging wakes it again) but I don't thing this will prolong the life of your hard disk – just the opposite holds true: this will make it die sooner.
Spinning it up constantly will give it much more stress !!!!!
Back to top
View user's profile Send private message
vonhelmet
l33t
l33t


Joined: 06 Apr 2004
Posts: 770
Location: Somewhere in a school

PostPosted: Tue Feb 01, 2005 11:51 am    Post subject: Reply with quote

The greatest stress on the disk will be during large changes in momentum. It's like cars taking a fair whack of petrol to stop and start again. It takes a lot of energy to get things ticking over in the first place. In the case of a hard disk it will take quite a wedge of energy to get it from 0 to 7200 rpm or whatever in a short time, and that puts a strain on the disk.

Leave it running, or turn the PC off if you're looking to save energy.
_________________
My blog
nvtuner software - enhance your AGP Geforce 6800 or 6200!
Back to top
View user's profile Send private message
Bojan
Tux's lil' helper
Tux's lil' helper


Joined: 18 Oct 2004
Posts: 145
Location: € Matrix

PostPosted: Tue Feb 01, 2005 12:29 pm    Post subject: Reply with quote

I couldn't agree more. Besides – HDD cooling just might be a good idea if you wish to prolong its life.
Back to top
View user's profile Send private message
Sachankara
l33t
l33t


Joined: 11 Jun 2004
Posts: 696
Location: Stockholm, Sweden

PostPosted: Tue Feb 01, 2005 2:51 pm    Post subject: Reply with quote

echo 1 > /proc/sys/vm/laptop_mode

Lowers the amount of filesystem journal log-writes so the harddrive has time to spin down...

echo 20 > /proc/sys/vm/swappiness

Forces the kernel to use most of the physical RAM before resorting to using the swap...

Both of these two will reduce the disk access...
_________________
Gentoo Hardened Linux 2.6.21 + svorak (Swedish dvorak)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum