# Hdparm problems with laptop

## ultraslinky

Hello fellow gentoo users!

I am having problems with Hdparm. I thought it would have been a good idea to emerge it. However, after emerging it, when my laptop is unplugged and running on battery, the hard disk gets turned off after just 2-3 seconds of inactivity. As you guessed, the system is on the verge of being unusable, and it isn't that good for the hard disk either... Unmerging Hdparm solves the problem, that is, the hard disk never turns off anymore after unmerging.

However, it would be nice to have the hard disk turn off every so often, or if i could assign a keyboard shortcut to shut it down. I have no idea how to control the rate at which my hard disk is turned off. I haven't found any entries about that in hdparm's manual about the rate, just the raw command to shut it down. So there must be some kind of OS daemon using hdparm to shut the hard disk down, at least, that's my hypothesis...

I am using XFCE 4.8, and in its power manager the option to turn off the disk is disabled.

The question is: how can i control the rate at which my hard disk is getting turned off? 

Thanks to everyone in advance  :Smile: 

----------

## Kaso_da_Zmok

try to use this.

```
emerge app-laptop/laptop-mode-tools
```

```
~ # /etc/init.d/laptop_mode start

```

after this the driver will stop spinning and spin up  when needed.

----------

## ultraslinky

Thanks Kaso_da_Zmok  :Smile:  I've tried laptop-mode-tools... It installs Hdparm again. However, i have set the timeout time in /etc/laptop-mode/laptop-mode.conf to 7200, both for battery on and AC power. That should be 2 hours before the disk turns off. Of course i have started the service. No avail, the disk keeps spinning down every 5 seconds and spinning back up again immediately. This is very annoying and it's using up my battery as well! It seems like something else is using hdparm. And it also seems like whatever is spinning it down doesn't even look if the hard disk is in use, even if i'm doing reads/writes the hard disk spins down and i have 2-3 seconds of lag.

Is there some kind of override i can specify to stop this crazy spinning down? (except unmerging hdparm...)

Thanks  :Smile: 

----------

## Kaso_da_Zmok

actually , i have the same behaviour you describe on my laptop. hmm also agree is annoying.

Did you try to set this to 0 ?

```
/etc/laptop-mode/laptop-mode.conf 
```

```

#

# If this is enabled, laptop mode tools will assume that SCSI drives are

# really SATA drives that only _look_ like SCSI drives, and will use hdparm

# to control them. Set this to 0 if you have /dev/sd devices and you want

# laptop mode tools to use the "sdparm" command to control them. 

#

ASSUME_SCSI_IS_SATA=1

```

----------

## ultraslinky

 *Kaso_da_Zmok wrote:*   

> actually , i have the same behaviour you describe on my laptop. hmm also agree is annoying.
> 
> Did you try to set this to 0 ?
> 
> ```
> ...

 

Uhmmm well i thought that everything on Linux uses that SCSI layer now... However, sdparm seems more like a CD/DVD utility to me, hdparm seems much more complete and useful.

But maybe i got it. Now i was reading all the hdparm features and i think i solved this.

So, "hdparm -B /dev/sda" gives the power management features, and it gave me a level of "1"... That is supposed to be the lowest power setting available. Is that the default setting? How the hell did it get so low? I tried setting it to 255 ("off") and the disk spun up and stayed there  :Smile:  So that's what is stopping our disks. Reading the manual i have noticed that any level above 127 doesn't spin the disk down, but still enables some power savings. I think i can still hear some "ticking" every so often from the HD, maybe it's resting the heads or something. So now i have it set at 128, I'll test lower values later on. I think I prefer to use a little bit more battery than to have a fried hard disk. And plus, at least on my netbook, the battery life actually decreased with the hard disk spinning up and down like that.

I think i won't use laptop-tools, most of the settings it modifies i have already modified in scripts (and some, like Intel HD audio, go to standby automatically in the kernel).

Anyhow thanks for your suggestions Kaso_da_Zmok! I hope you solve your spinning down problems too  :Smile: 

----------

## Kaso_da_Zmok

i just changed the timeout from 20 to 900 seconds and looks like it does the job.

```
LM_AC_HD_IDLE_TIMEOUT_SECONDS=900

LM_BATT_HD_IDLE_TIMEOUT_SECONDS=900

NOLM_HD_IDLE_TIMEOUT_SECONDS=7200

```

----------

## ultraslinky

Bah... So now i noticed that every time i'm on battery, something resets the power management to 1 and makes my disk spindown again... And if i use laptop-mode it's fighting against that setting but it doesn't win. I have to "hdparm -B 128 /dev/sda" every time. 

What could be doing this? I have XFCE 4.8 and most power utilities installed, including udisks, XFCE power manager, acpid of course... 

Anybody got a hint? Thanks  :Smile: 

----------

## Kaso_da_Zmok

hi, you are right, there is some problem with the laptop tools. i kept noticing my drive was spinning down all the time.

my wild guess is that the values are not in seconds. But whatever values hdparm -S takes.

values from 1 to 240 specify multiples of 5 seconds, yielding timeouts from 5 seconds to 20 minutes. Values from 241 to 251 specify from 1 to 11 units of 30 minutes, yielding timeouts from 30 minutes to 5.5 hours. A value of 252 signifies a timeout of 21 minutes. A value of 253 sets a vendor-defined timeout period between 8 and 12 hours, and the value 254 is reserved. 255 is interpreted as 21 minutes plus 15 seconds.

```
#

# Should laptop mode tools control the hard drive idle timeout settings?

#

CONTROL_HD_IDLE_TIMEOUT=1

#

# Idle timeout values. (hdparm -S)

# Default is 2 hours on AC (NOLM_HD_IDLE_TIMEOUT_SECONDS=7200) and 20 seconds

# for battery and for AC with laptop mode on.

#

LM_AC_HD_IDLE_TIMEOUT_SECONDS=251

LM_BATT_HD_IDLE_TIMEOUT_SECONDS=251

NOLM_HD_IDLE_TIMEOUT_SECONDS=251

```

my theory does not fit exactly yet, because if i set it to 11 i expect it to spin down after 55 seconds but it spins down in 11 seconds.

But if i set it to 100 or anything upto 251 it seems to work and the drive is not spinning down like crazy.

----------

## ultraslinky

OK i changed it to 254 and I'm going fine now. What's spinning down my disk is actually the hdparm -B value... Every time i startup my hdparm -B value is 1. If i unplug / plug the AC laptop_mode takes control and it goes to 128 / 254... I guess this is XFCE messing with it this time, maybe the option "Prefer power savings over performance"? Anyhow, i am getting closer to abandoning XFCE and going back to LXDE or similar, and learning how to use acpid rules myself  :Smile: 

----------

## Kaso_da_Zmok

try disabling tickless kernel. i just did for something else and noticed the drive is not spinning down like crazy as a side effect.

----------

