Ubuntu Hard Drive Explosions
For starters, let me just say WOW! I’m completely overwhelmed at the responses my last article article has gotten. As I type this it’s rapidly approaching 1000 diggs, which is something I never even envisioned. When I sat down to write this article, three things were true:
1. It was 3am.
2. I actually was writing the article more on the basis that I had read a trouble ticket that I didn’t understand a piece of lingo in (hard drive load/unload cycles)
3. I was in my underwear.
So imagine my surprise when I finished the article, in which the main goal was to make me tired enough to sleep so I wouldn’t be completely useless at work the next day, and posted it that the digs started coming in almost immediately. I saw that I had 8 before I went to bed, and didn’t think anything about it until the next night, when I checked and saw over 400. Insanity. At any rate, to make it short, let me say Thank You to all of you (even the trolls!) if for nothing else participating in a lively discussion. Enough mushy community group hug crap. Let’s get down to work.
Of all the responses that were posted in response to my first article, this one was far and away the most relevant. (Especially when you consider the fact that after some research I realized the guy was a lead Ubuntu developer!)
“The situation is somewhat less clear than you might think from the article, but the basic takeaway message is that Ubuntu doesn't touch your hard drive power management settings by default. In almost all cases, it's more likely to be your BIOS or the firmware on your hard drive.
The script that's executed when you plug or unplug your laptop is /etc/acpi/power.sh. The relevant sections are:
function laptop_mode_enable {
...
$HDPARM -S $SPINDOWN_TIME /dev/$drive 2>/dev/null
$HDPARM -B 1 /dev/$drive 2>/dev/null
}
That is, when the laptop_mode_enable function is called, we set the drive power parameters. Now, by default laptop_mode_enable isn't called:
if [ x$ENABLE_LAPTOP_MODE = xtrue ]; then
(sleep 5 && laptop_mode_enable)&
fi
because ENABLE_LAPTOP_MODE is false in the default install (check /etc/default/acpi-support). This means that, by default, we do not alter the hard drive power settings. In other words, the APM settings that your drive is using in Ubuntu are the ones that your BIOS programmed into it when the computer started. This is supported by the fact that people see this issue after resuming from suspend. We don't touch the hard drive settings at that point, so the only way it can occur is if your BIOS or drive default to this behaviour.
If you enable laptop mode, then we will enable aggressive power management on the drive and that may lead to some reduction in hard drive lifespan. That's a fairly inevitable consequence of laptop mode, since it only makes sense if the laptop enages in aggressive power management. But, as I said, that's not the default behaviour of Ubuntu.
There's certainly an argument that we should work around BIOSes, but in general our assumption has been that your hardware manufacturer has a better idea what your computer is capable of than we do. If a laptop manufacturer configures your drive to save power at the cost of life expectancy, then that's probably something you should ask your laptop manufacturer about”
So let me put this out there in capital letters, because I NEVER wanted any semblance of bad publicity for Ubuntu. UBUNTU DOES NOT OVERWORK YOUR HARD DRIVE UNLESS IT IS IN LAPTOP MODE.
How can you tell if your machine is in laptop mode? Easy.
root@linux-hero.com:/ grep ENABLE_LAPTOP_MODE /etc/default/acpi-support
If the returned value is true, your machine is in laptop mode and you may wish to alter your power management settings accordingly. I have not tested this, however I imagine you can choose a less aggressive number in the aforementioned script /etc/acpi/power.sh at the line that reads:
<code>$HDPARM -B 1 /dev/$drive 2>/dev/null</code>
When doing so, keep in mind that 255 completely disables power management, and 1 is the most aggressive setting. Find a happy medium that works for your laptop if you’re interested in striking a balance between battery life and hard drive longevity.
If it comes back false, you’re fine. It should also be noted per the developer that laptop mode is off by default. I’m imagining though, that many people when going through the install see the advanced power management stuff in the list of packages and turn it on without thinking about it. Perhaps a small warning, even in the /etc/default/acpi-support file is in order?
I’m going to close with the statement that I truly love Ubuntu, and it is in my opinion the best distro available right now, and I never wanted bad publicity for them. This article was originally just an excuse for me to do some research and learn about hard drive load/unload cycles. All the rest of this is just 17,000 hits of side effects. (Gentoo users, I like that one a lot too… I swear. No flame wars please.)

Technorati Tags:
This has not worked for me
I love kubuntu, and am not insinuating this is an ubuntu/kubuntu problem. I have emailed my problem to the developers of smartmontools to see if there is a chance their utility is incorrectly reporting load cycles.
As you can see in the output below, I am still seeing higher load cycles (16 in ~5 minutes). For some of us, this is still a problem.
I have disabled power management in the bios, and manually disabled powermanagement with -B255 and disabled standby with -S0 (under hdparm commands). The output below clearly shows that power management is disabled for me.
***OUTPUT STRING****
tferero@ubuntu:~$ date
Sun Oct 28 12:50:53 EDT 2007
tferero@ubuntu:~$ sudo smartctl -d ata -a /dev/sda1 | grep Load_Cycle_Count
225 Load_Cycle_Count 0x0012 095 095 000 Old_age Always - 57363
tferero@ubuntu:~$ sudo grep ENABLE_LAPTOP_MODE /etc/default/acpi-support
ENABLE_LAPTOP_MODE=false
tferero@ubuntu:~$ date
Sun Oct 28 12:55:46 EDT 2007
tferero@ubuntu:~$ sudo smartctl -d ata -a /dev/sda1 | grep Load_Cycle_Count
225 Load_Cycle_Count 0x0012 095 095 000 Old_age Always - 57379
tferero@ubuntu:~$
254 is better then 255
Some harddrives still have increasing Load_Cycle_Count if you turn off power management because the hard drive ignores the setting.
Try using hdparm -B254 rather then hdparm -B255.
That is what I needed to do on my laptop.
254 works
Thanks! Yes, 255 didn't work for me either. 254 works for my FUJITSU MHV2060B Version: 892C.
It hurts to know that 80511 load cycles have passed on a not very laptop though. It used to increase by one every minute even though I had LAPTOP MODE disabled.
-B254 setting
Yes, this worked for me. I was told, via response from Bruce Allen of Smartmontools that 255 is actually a reserved value on most harddrives, and in many cases is ignored. He also felt that the man pages (which suggest -B255) are not correct; perhaps a typo.