Wednesday, 7 May 2008

Laptop hard drive issues in Linux

Since I switched to using Fedora 9 Preview release as my primary operating system, I noticed some excessive amount of disk activity even while the computer was idle. After digging around the net for a while, I discovered that this problem has been known for quite some time - specially within the Ubuntu community.

As it turns out, the Linux kernel does not explicitly apply ACPI power saving settings on hard drives. Instead, the settings for the hard drive are taken from the BIOS, which is quite logical since who knows the system better than the system manufacturer itself ? The problem is that most laptop BIOS's are set to manage the hard drive for optimal battery usage and mobility. Since sudden bumps can cause head crashes, the disk heads are parked frequently while not in use. Therefore when a new disk request comes in, the heads need to be unparked again to service it. Although in the short term this reduces the number of unpleasant disk crashes, the constant parking and unparking of the heads cause wear and tear on the drive mechanism - reducing the lifespan of the drive.

In SMART enabled hard drives, the parameter Load_Cycle_Count keeps track of the number of head parkings. Typically during the life time of a hard drive it can handle about 600,000 load cycles, after which it becomes less reliable. To check how many Load_Cycle_Counts are clocked on your machine, run the following command. (Assuming your hard drive is /dev/sda)
sudo /usr/sbin/smartctl -a /dev/sda | grep Load_Cycle_Count

I monitored my Load_Cycle_Count for a period of two hours and discovered that during that time the counter increased by 7, which is certainly not good. I followed the instructions found at http://ubuntuforums.org/showpost.php?p=3675960&postcount=26 to set the hard drive power saving mode manually as follows:
sudo hdparm -B 254 /dev/sda

That was it ! My Load_Cycle_Count froze in place and the frequent hard drive chatter vanished.

A word of warning : Don't set the power saving mode manually unless the laptop is stationary and is running on AC power. The default settings are meant to protect the hard drive from any accidental damage and prolong battery life.

No comments: