Linux: Monitor Hard Disks Temperature With hddtemp

by Vivek Gite on October 8, 2007 · 26 comments

There is a nice utility to monitor hard drive temperature. Most modern x86 computer hard disk comes with S.M.A.R.T (Self-Monitoring, Analysis, and Reporting Technology). It is a monitoring system for computer hard disks to detect and report on various indicators of reliability, in the hope of anticipating failures.

=> hddtemp utility will give you the temperature of your hard drive by reading data from S.M.A.R.T. on drives that support this feature. Only modern hard drives have a temperature sensor. hddtemp supports reading S.M.A.R.T. information from SCSI drives too. hddtemp can work as simple command line tool or as a daemon to get information from all servers.

Install hddtemp

To install hddtemp under Debian / Ubuntu Linux, enter:
$ sudo apt-get install hddtemp
You can also perform source code installation. Download the source code tar ball here.
$ wget http://download.savannah.nongnu.org/releases/hddtemp/hddtemp-0.3-beta15.tar.bz2
Untar and install hddtemp:
$ tar -jxvf hddtemp-0.3-beta15.tar.bz2
$ cd hddtemp-0.3-beta15
$ ./configure
$ make
$ sudo make install

Install hard disk temperature database at /usr/share/misc or /etc directory:
$ cd /usr/share/misc
# wget http://download.savannah.nongnu.org/releases/hddtemp/hddtemp.db

How do I monitor hard disk temperature?

To see temperature for /dev/sda, enter the following command:
# hddtemp /dev/sda
Output:

/dev/sda: WDC WD2500YS-01SHB1:  25°C

Above output indicate that my hard disk temperature is 25°C. If temperature is higher than 60°С , consider cooling options immediately.

How Do I Find Out Remote Server HDD Temperature?

By default hddtemp bind to TCP/IP port 7634. You need to run hddtemp in daemon mode. Login on remote box and start it as follows to monitor /dev/sda, /dev/sdb, /dev/sdc, and /dev/sdd:
# hddtemp -d /dev/sd[abcd]
Use telnet or nc / netcat command to to get a temperature from a remote box:
$ telnet remotebox 7634
OR
$ nc 192.168.1.100 7634

Shutdown Linux Computer If Temperature >= 55

To power off / shutdown computer, run following command via cron tab (cron job) file:
[ $(hddtemp /dev/sda | awk '{ print $4}' | awk -F '°' '{ print $1}') -ge 55 ] && /sbin/shutdown -h 0 || :
Sample shell script to shutdown box if temperature >= 55°C (download link):

#!/bin/bash
HDDS="/dev/sda /dev/sdb /dev/sdc"
HDT=/usr/sbin/hddtemp
LOG=/usr/bin/logger
DOWN=/sbin/shutdown
ALERT_LEVEL=55
for disk in $HDDS
do
  if [ -b $disk ]; then
	HDTEMP=$($HDT $disk | awk '{ print $4}' | awk -F '°' '{ print $1}')
        if [ $HDTEMP -ge $ALERT_LEVEL ]; then
           $LOG "System going down as hard disk : $disk temperature $HDTEMP°C crossed its limit"
           sync;sync
           $DOWN -h 0
        fi
  fi
done

smartctl Utility

If you have smartctl utility installed, try it as follows to get temperature data:
# smartctl -d ata -A /dev/sda | grep -i temperature
Output:

194 Temperature_Celsius     0x0022   122   095   000    Old_age   Always       -       28

Set ALERT_LEVEL as per your requirements. Please refer to your hard disk manual for working temperature guideline. Here is general temperature guideline (extracted from Seagate SV35.2 Series Hard Drives Web Page):

Operating 0 to 60 degrees C
Nonoperating -40 to 70 degrees C
Maximum operating temperature change 20 degrees C per hour
Maximum nonoperating temperature change 30 degrees C per hour
Maximum operating case temperature69 degrees C

A note for Windows XP / Vista / Server Users

hddtemp is UNIX / Linux only program. You can download hddtemp trial version here.

Further readings

Updated for accuracy!

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

We're here to help you make the most of sysadmin work. So, subscribe!

{ 26 comments… read them below or add one }

1 Mace Moneta October 9, 2007

35C is a little premature to be shutting down the system, or even to get additional cooling. Most manufacturers specify a maximum operating temperature of 60C as being fully within specifications. Check your drive manufacturer’s web site for the specifications for your particular drive. During periods of high activity (e.g., backups, RAID sync), a drive can easily exceed 50C. Shutting down every time that happens is not productive.

Reply

2 vivek October 9, 2007

Mace,

I agree with you. 35C is just for example. You can set ALERT_LEVEL as per your requirements or just send an email. The post has been updated to reflect your views.

Appreciate your post!

Reply

3 the polarizer October 9, 2007

Neat little howto. Instant success

box@ubuntu:~$ sudo hddtemp /dev/sda
/dev/sda: SAMSUNG SPXXXX: 33°C
box@ubuntu:~$ sudo hddtemp /dev/sdb
/dev/sdb: SAMSUNG SPXXXX: 32°C

Here on my striped raid.

I would welcome a warning instead of immediate box shutdown w/o named reason. Some speaker beeps would fulfill that approach.

the polarizer

PS: Have to check whether the sda drive which is more hot is on the top.

Reply

4 Sweta October 10, 2007

Vivek,

Nice program. I’m gonna try out hddtemp for windows xp sp2.

Cheers,

STT

Reply

5 marxjo October 11, 2007

For example. Seagate disks work normally even at 50C, but if such temp will last longer, Seagate drives will start to squel, but if you have a server room…

Reply

6 I_LOVE_Missouri October 13, 2007

I personally think that you are the best Linux blogger that I’ve ever seen. I read your blog all the time and I think it’s so well done. My browser home page set to cyberciti.biz!

Reply

7 vivek October 13, 2007

Thanks for the feedback! You made my day :D

Reply

8 Pragadeshv November 20, 2007

Its Really use full for me. Thanks vivek.

Reply

9 pete January 9, 2008

this program has an error with my version of hddtemp.
$4 should read $3
‘ should read ‘
so the line should be:
HDTEMP=$($HDT $disk | awk ‘{ print $3}’ | awk -F ‘°’ ‘{ print $1}’)

additionally, if a shutdown is to occur, and there is more than one hard drive, the shutdown command will be executed for the number of hard drives that exceed the temperature. i am a linux newbie and don’t know if this is relevant.
P.

Reply

10 Erwin September 11, 2008

Check hddtemp-0.3-beta15/src/hddtemp.c
on line 227, the hddtemp tool can also print out just the temperature value. No need to parse the output and fetch the value from a formatted string.
Just issue this command:

/usr/local/sbin/hddtemp /dev/hdc --numeric

Reply

11 Erwin Kooi September 11, 2008

This is my cron script using the –numeric arg:

#!/bin/bash
HDDS="/dev/hdc"
HDT=/usr/sbin/hddtemp
LOG=/usr/bin/logger
DOWN=/sbin/shutdown
ALERT_LEVEL=55
args="--numeric"
for disk in $HDDS
do
if [ -b $disk ]; then
HDTEMP=$($HDT $disk $args)
$LOG "HDTEMP for $disk is $HDTEMP"
if [ $HDTEMP -ge $ALERT_LEVEL ]; then
$LOG "System going down as hard disk : $disk temperature $HDTEMP exceeded its limit"
sync;sync
$DOWN -h 0
fi
fi
done

Reply

12 andrew November 15, 2008

My Drive is named: SAMSUNG HD400LJ
and behaves normally, 194 is allright :)
Thanks for this great software!

Reply

13 Brian February 15, 2009

Thank you, just what i need fore my server in my closet :)

But i think i will make it beep fist and if the temperature raises further then shutdown.

Reply

14 JAY May 31, 2009

HDT=”/usr/sbin/hddtemp -n”

Reply

15 JAY May 31, 2009
WARN_LEVEL=40
ALERT_LEVEL=63
for disk in $HDDS
do
  if [ -b $disk ]; then
	HDTEMP=$($HDT $disk)
        if [ $HDTEMP -ge $ALERT_LEVEL ]; then
		date >> ~/Desktop/ERRORS.TXT
           	echo "System going down as hard disk : $disk temperature is $HDTEMP°C" >> ~/Desktop/ERRORS.TXT
           sync;sync
		$DOWN -h 0
	else
		echo $disk - $HDTEMP
        fi
	if [ $HDTEMP -ge $WARN_LEVEL ]; then
		date >> ~/Desktop/ERRORS.TXT
           	echo "hard disk : $disk temperature is $HDTEMP°C" >> ~/Desktop/ERRORS.TXT
		/usr/bin/notify-send -u critical -c device.error -i /usr/share/icons/Human/32x32/status/dialog-warning.png -t 900 "HDD TEMP" "$disk temperature $HDTEMP°C"
		zenity --info --text "hard disk : $disk temperature $HDTEMP°C"
           sync;sync
        fi
  fi
done
exit 0

Reply

16 steveh July 22, 2009

To see temperature for /dev/sda, enter the following command:
# hddtemp /dev/sda
Output:

/dev/sdb: WDC WD2500YS-01SHB1: 25°C

The output should also be /dev/sda not sdb.

Reply

17 Philippe Petrinko July 7, 2010

Hi Vivek,

SteveH is right there is a typo (should be the same device ! sda )

And Andrey ask a useful question: Is it possible to get any SMART HDD info using a HDD-USB drive ?

TIA!

Reply

18 Vivek Gite July 7, 2010

Philippe,

I’ve updated the post. And yes, it works with hdd info using a USB drive directly connected to system or via docking station.

HTH

Reply

19 Andrey March 28, 2010

Hi!
Thanks for your blog!
Tell me please, will it work for me if I use the SATA Docking Station, so the hard drive is connected to my computer via usb?
What am I supposed to do?

Reply

20 Vivek Gite July 7, 2010

Yes, it works with laptop docking station connected via USB.

hddtemp sata:/dev/sdc

Reply

21 Luc July 13, 2010

Hi,

First off, thanks for the great tutorial and information.

I have a question. How does this work with RAID drives, or can it? For example, all of my servers are running either RAID-0,2,6, etc and usually all the drives show up as one in linux (ex: /dev/sda).

I have not tried this method yet, but I’m wondering if and how this would work with RAID (where a raid controller connects the drives to the system).

Thanks,
Luc

Reply

22 Vivek Gite July 13, 2010

Most modern RAID controller expose themself to you via different device name under Linux. See this FAQ. Also cli tools provided by RAID controller can be used to obtain the same info. It all depends upon your RAID card. However, hddtemp may not work for RAID based hard disk, use smartctl command:

smartctl -d scsi --all /dev/sg1  | grep -i temp
Temperature Warning Disabled or Not Supported
Current Drive Temperature:     23 C
Drive Trip Temperature:        65 C

This is from Adaptec 5405 SAS running FUJITSU hard disks.

Reply

23 Aario November 23, 2010

Hi,
Mine is 59C! It’s too hot. You said cooling options, please someone tell me how can I cool down my hard drive?
Laptop: Acer Aspire 5536
Linux: Ubuntu 10.04
Here’s the output of hddtemp command:
sudo hddtemp /dev/sda
/dev/sda: WDC WD3200BEVT-22ZCT0: 59°C
Thanks in advance.

Reply

24 Erik December 26, 2010

You can put a small fan in front of the drives ( in the front of your comp-case ). this well draw fresh (cool) air in and blow it over the Harddisk and cooling it. Also, place your computer on the floor ( the air is cooler on the floor )

I am having this problem : I use hddtemp (daemon) in combination with conky. My 4 internal drives report just fine, but my 2 external sata-drives connected with usb don’t report the temperature ( -> N/A in conky ). The internal and external drives are all Samsung model 103SJ / SI or UJ. ( i tried putting sata: in front of the device name in the conky config file. When i try hddtemp in terminal ‘hddtemp /dev/sbb’ i get ‘/dev/sdb: SAMSUNG HD103SI: S.M.A.R.T. not available’, when i try ‘hddtemp sata:/dev/sdb’ i get a several lines of weird characters and the correct temperature behind them)
Any suggestions how to fix this ?

Reply

25 pr7vinas January 27, 2011

I do not recommend hddtemp. My application fails because of it.
I run it about 30 times and in the middle, it fails. It causes an error on the bus. I’m looking for something better.

Reply

26 mark September 26, 2011

Not working on USB drives

hddtemp /dev/sde
/dev/sde: WD Ext HDD 1021: S.M.A.R.T. not available

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">




Previous post:

Next post: