By Jake Edge
November 7, 2007
Laptop hard disk failures are horrible to contemplate; they always come
at the worst possible time, far from home or office, while managing to lose a huge amount of important data. This explains the loud outcry when it appeared
that Ubuntu was causing premature failures in laptop hard disks, as was
reported in many places last week. The problem is not really
Ubuntu-specific, nor as widespread as was feared, but before the dust
settled it certainly looked like it might give Ubuntu a very public black
eye.
Laptop manufacturers want to reduce the power consumption of their devices; one way to do that is to spin down the hard disk when it
hasn't been accessed for a time. Some hard disks then move the heads away
from the platters, called "parking the heads", in order to prevent damage
to the drive under a sudden deceleration; hitting the floor for
example. Depending on the drive, head parking or spinning down will
increment a count, the load/unload cycle (or just load cycle) count, which
can then be queried using
the smartctl command:
[root@anhinga jake]# smartctl -A /dev/sda | grep Load_Cycle
193 Load_Cycle_Count [...] 359618
The number at the end of the line is the count.
Drive manufacturers typically rate their laptop drives for 600,000
load cycles, so when people started noticing counts around half that
number on their relatively new Ubuntu laptops, they got worried. Bugs were
were filed in
Ubuntu's Launchpad, various blogs started reporting it, and the story
was picked up by Slashdot, running under
the headline "Ubuntu
May Be Killing Your Laptop's Hard Drive". At that point, muttering
about tar and feathers could be heard in various quarters, but it is
difficult to put the blame solely on Ubuntu.
The default power saving settings for a particular laptop are set by the
manufacturer. Unless "laptop mode" is enabled – it is off by
default, but would seem a reasonable thing to enable on a laptop –
Ubuntu does not change those settings. In order to get the best battery
life, laptop makers are setting very aggressive power saving modes that
will spin down the disk and park the heads after a short period of idle time
(typically 15-60 seconds). If the disk is accessed after that happens, the
process is reversed and the counter gets incremented again. For some
laptops, this happens regardless of whether it is running from battery or not.
Default Ubuntu installs, not unlike many other distributions, tend to
access the disk frequently – for logging, atime updates, or other
reasons. If
the time between accesses is larger than the time between spin downs, a
high load cycle count can result. The load cycle count is an indicator of
the wear and tear on the drive, for both the motors and the parking
mechanism and the drive rating is only an estimate of what can be
expected. Users are reporting drive problems with only one-third of the
expected load cycles; which may or may not be related, of course.
In some ways, Ubuntu is being victimized by its own success; this problem
is getting pinned on Ubuntu, in part, because it is so popular. Users of
other distributions are starting to chime in with similar problems. As
might be guessed, the problem is not Linux-specific either, with both Mac
OS X and Windows laptop users reporting high load cycle counts as well. It
is a hard problem to completely get a handle on because it is very
hardware-specific, with software settings and usage patterns playing a role
as well.
It is hard to claim that any distribution should be changing default power
management settings without request by the user – the hardware manufacturers
should be responsible for setting reasonable defaults. It will be
very difficult for a distribution to know what settings to make, so the
laptop vendors need to be held accountable to choose defaults that won't
harm the hardware under normal use. It could be
argued that a user who enabled laptop mode on Ubuntu made it reasonable for the OS to
set the hard disk to its most aggressive power management setting, but that
may have worsened the problem for some. Various fixes have been
gathered on the Ubuntu wiki page,
but the basic idea is to change the power savings setting for the hard disk using
hdparm -B 254 /dev/hda (or /dev/sda). The 254 value sets
the least aggressive power savings mode; some users are reporting that 255
will disable power management completely, while others say it has no effect.
The biggest change
distributions can make to help alleviate this problem is to reduce the number of writes, especially
nearly useless writes, to the disk. One of the culprits reported for
Ubuntu is the acpid power management daemon writing battery status
to a logfile every 15 seconds,
which seems like a good way to ensure the battery life reduces more quickly
than it should. Some logging could be deferred or disabled when
running from battery.
Using the relatime
option when mounting filesystems is another, fairly simple, change that
could be made to significantly reduce disk writes that are likely to be
pointless. Fedora 8 enables that option by default for all systems,
battery powered or not, for the disk performance increase that it gives.
People running older kernels, before 2.6.20 added the relatime
option, may want to consider disabling atime updates altogether using the
noatime mount option.
There is still plenty of work to be done to produce the most power
efficient Linux systems, but we are making lots of progress.
The ongoing work to reduce the power consumption of both the kernel
and, more importantly, user space programs, has made amazing strides in a
fairly short period of time. This panic over Ubuntu the Mighty Disk Eater
might have been overblown, but it will serve to help us get better systems
in the long run; yet another step on the path to world domination.
(Note that the Load_Cycle_Count number above in the smartctl
example is correct for the author's Fedora 7 laptop with a less than
one year old disk. It was increasing at several thousand per day until the
hdparm change was made.)
(
Log in to post comments)