Hard disk temperature monitoring on Linux

Your hard disk is where your data lives, so it is prudent to monitor its temperature as an indicator of health.

We will do this in three parts. First, we gather needed information on our hard disk. Second, we install and configure backend utilities to do the actual monitoring. Finally, we install and configure a frontend application to display the captured data. This article discusses the first two points, and ends with a link to a discussion of data display.

First we need to identify your hard disk. The command line tool lshw (run as root) or the graphical tool hardinfo often tell you all you need to know. Otherwise, just open the case and peek inside. For example, on my current box lshw could tell me many things about my hard disk but not the model number. Once you know your hard disk’s make and model, it’s a simple task to find online the manufacturer’s thermal recommendations for your disk.

Usually a manufacturer will specify minimum and maximum temperatures but not a recommended temperature. Curiously, I have found few formal studies addressing this, and like this one they examine datacenters rather than workstations and so ignore the stresses of thermal cycling and drive spinup/spindown. Lacking objective data, I must grudgingly settle for the anecdotal advice floating around, which is that the warmer your disk runs, the shorter its expected life, even if well below the drive’s rated maximum operating temperature. The most common recommended temperature is 45°C or less.

Install hddtemp. Then run hddtemp /dev/sda to test, replacing sda with your device name. Depending upon the packager’s preferences, you may be able to run this as user, or you may have to run it as root. In any case you should see something like this:

$ hddtemp /dev/sda
/dev/sda: ExcelStor Technology J8106 S: 33°C

At this point hddtemp should be working, but in fact every installation I’ve done has required some troubleshooting.

Confirm that the hddtemp service is configured to start on boot.

If your hard disk is not recognized, you will have to add your hard disk to /etc/hddtemp.db as root with a line similar to this, including the quotation marks:

"ExcelStor Technology J8106" 194 C "ExcelStor Technology J8106 (164 GB)"

After adding your drive to the database, run hddtemp /dev/sda again to make sure your drive is now recognized.

Every installation I’ve done has needed edits to the hddtemp configuration file. Different packagers and distros place it in different locations and even give it different names; to find yours, consult hddtemp’s init script at /etc/init.d/hddtemp. For example, the hddtemp that comes with Linux Mint Debian Edition has the lines:

# Reads config file (will override defaults above)
[ -r /etc/default/hddtemp ] && . /etc/default/hddtemp

…so the configuration file in this case is /etc/default/hddtemp.

Whatever it’s called and wherever it is, review it and edit as needed. Changes I’ve had to make have included:

  • Change RUN_DAEMON=”false” to “true”. Before changing this on an installation of Linux Mint Debian Edition, the hddtemp init script silently failed to start the daemon on boot.
  • Explicitly list the devices you want to use with hddtemp, uncommenting the example and changing as needed. Before doing so on an installation of Mandriva 2009.0, gkrellm was unable to see hddtemp data.

On some installations, userspace monitoring applications and scripts run as user cannot see hard disk temperatures unless /usr/sbin/hddtemp (not to be confused with /usr/bin/hddtemp) has been made suid root. This can be done as root with chmod u+s /usr/sbin/hddtemp. This has security implications, so don’t do this heedlessly. One monitor that needs this is xfce4-sensors-plugin.

Now that you are monitoring your hard disk’s temperature, you will want to display the data and act on alarms.

Monitoring your hard disk’s temperature is just one part of hardware monitoring in general.

Some packages have two binaries, /usr/sbin/hddtemp and /usr/bin/hddtemp. Other packages have only the former.

Monitor hard disk temperature with hddtemp
hddtemp project page. Notice that the project is clearly marked as unmaintained, so reader suggestions for alternatives are most welcome. Having noted that, it’s always worked for me.


About Warren Post

So far: Customer support guy, jungle guide, IT consultant, beach bum, entrepreneur, teacher, diplomat, over-enthusiastic cyclist. Tomorrow: who knows?
This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s