Follow Us

We use cookies to provide you with a better experience. If you continue to use this site, we'll assume you're happy with this. Alternatively, click here to find out how to manage these cookies

hide cookie message

Get SMART!

How can you use a hard drive’s diagnostic facilities?

Article comments

What is SMART?
No, not a 60's TV series, but a self-test and diagnostic facility – Self-Monitoring, Analysis and Reporting Technology to be exact – that you may not even know you have, built into each and every hard disk unit on your network. See the TechWorld RTFM article on SMART technology for more information.

What Does It Do?
In essence, the drive firmware monitors a range of possibly diagnostic drive parameters, things like the number of seek errors and the disk spin-up time (exactly what is monitored varies from drive to drive – the manufacturer will only implement those diagnostics that are meaningful for the particular drive's architecture). If these parameters degrade over time it may indicate the unit is heading for a breakdown.

Do My Disks Have It?
Yes. Unless you're running DOS applications on an original PC fitted with a 20MByte house-brick, every disk unit on your network has SMART-enabled firmware. SMART has been in the public domain since 1995 and more or less universal since the late 90s. That includes all modern ATA/IDE, SCSI, FC and even SSA hard drive units.

Do I need it?
Yes. The disk manufacturers estimate that about 70% of all drive failures can be predicted by SMART monitoring. With a few days warning of an impending disk failure you'll have a chance to move the files and/or replace the unit before you lose any data. Without it, the first you'll know of a problem will be when you try to print the report you spent all morning drafting and get a message saying "Disk error: Abort, Retry, Fail?".

OK I'm sold – how do I use it?
SMART-enabled disks collect data passively. If you want to monitor them you'll need software that queries the disks at regular intervals. The options are to buy a commercial product, adapt a public domain application or add SMART monitoring to an existing program.

There are plenty of commercial products. Writing an application to retrieve SMART status information from a drive is, as we shall see, easy and any number of small software vendors have seen it as a good niche.

Examples include:

(a) HD Workbench from Dutch-based DIY DataRecovery, priced at $20 per computer, runs on Windows 2000 and XP. It has a neat, clean user interface and includes a number of data-recovery features beyond simply monitoring SMART reports, such as disk cloning, bad sector remapping and a raw disk copy.

(b) ActiveSMART from Ariolic Software runs on Windows and is priced at $25 for a single licence for home use and $40 for a single-computer corporate licence. What you get for the extra $15 isn't clear. The GUI is neat and easy-to-use. The standard product is restricted to ATA/IDE disks; a SCSI version costs $40.

(c) SANtools offers the GUI-based SMARTMon for Windows and a command-line version, SMARTMon-UX, for Unix and Linux, priced at $90 per computer. A cut-down version for personal use is available for $20. Read TechWorld's review for more.

I have a Unix/Linux system – can I do-it-myself?
Yes. In fact it's astonishingly easy. The truth is Unix systems programming is nowhere near as difficult as most people believe. On the whole, writing a decent GUI is far harder.

To get an idea how easy querying a SMART-enabled disk is under Unix and Linux, download the source of SMARTsuite (try www.linux-ide.org). This neat little utility does everything you'd want by way of monitoring both ATA/IDE and SCSI disks, in just a couple of thousand lines of uncomplicated 'C'. It's written for Linux but porting it to most Unix flavours shouldn't involve much more than changing a few #define's in the header files.

Digging into the code, ultimately everything's done through Unix ioctl() system calls. If you haven't already encountered ioctls you're in for a pleasant surprise – they provide a simple and flexible mechanism to allow applications programs access to hardware-specific capabilities and are amongst the most powerful and useful of Unix/Linux system programming services. If you really want to understand Unix I/O a few hours browsing the ioctl man pages and reading the header file sys/ioctl.h (usually in /usr/include) will be time well-spent.

SMARTsuite is distributed under the GNU Public License, so feel free to borrow or adapt its ideas in order to add SMART monitoring and reporting to existing utilities.

I have a Windows system – can I do-it-myself too?
Ah… I had hoped you wouldn't ask that. Yes, you can but it's not quite as straightforward. Those nice folk in Redmond don't want to encourage people to think programming is easy.

Windows also uses the term IOCTL but it means something different; here an IOCTL is a control code – in essence, a number identifying an operation. There are three SMART IOCTLs defined in the WINIOCTL.H header file:-

SMART_GET_VERSION to check the SMART driver version number
SMART_RCV_DRIVE_DATA to receive data from a SMART-enabled drive
SMART_SEND_DRIVE_COMMAND to send data to it

Communication with the device driver goes through a cumbersome function, DeviceIoControl(). The following code illustrates its use.

#include
#include
#include
#include

int main (int argc, char **argv)
{
HANDLE disk0;
DWORD retCount;
GETVERSIONINPARAMS versionInfo;

/* get a handle for physical disk 0 (the C: drive) */
if ((disk0 = CreateFile (
"\\\\.\\PHYSICALDRIVE0",
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_DELETE | FILE_SHARE_READ |
FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL)) == INVALID_HANDLE_VALUE)
{
printf ("Unable to open physical device 0\n");
exit (EXIT_FAILURE);
}

/* query the drive for the SMART version it supports */
if (! (DeviceIoControl (disk0,
SMART_GET_VERSION,
NULL,
0,
&versionInfo,
sizeof (GETVERSIONINPARAMS),
&retCount,
NULL))
{
printf ("DeviceIoControl() call failed\n");
exit (EXIT_FAILURE);
}
printf ("Driver version... %1d\n"
"Revision......... %1d\n"
"Device map....... 0x%02x\n"
"Capabilities......0x%02x\n",
versionInfo.bVersion,
versionInfo.bRevision,
versionInfo.bIDEDeviceMap,
versionInfo.fCapabilities);

/* close everything & go home */
CloseHandle (disk0);
exit (EXIT_SUCCESS);
}

So there you are, everything you need to know to get S.M.A.R.T. – good hunting!


Share:

More from Techworld

More relevant IT news

Comments



Send to a friend

Email this article to a friend or colleague:

PLEASE NOTE: Your name is used only to let the recipient know who sent the story, and in case of transmission error. Both your name and the recipient's name and address will not be used for any other purpose.

Techworld White Papers

Choose – and Choose Wisely – the Right MSP for Your SMB

End users need a technology partner that provides transparency, enables productivity, delivers...

Download Whitepaper

10 Effective Habits of Indispensable IT Departments

It’s no secret that responsibilities are growing while budgets continue to shrink. Download this...

Download Whitepaper

Gartner Magic Quadrant for Enterprise Information Archiving

Enterprise information archiving is contributing to organisational needs for e-discovery and...

Download Whitepaper

Advancing the state of virtualised backups

Dell Software’s vRanger is a veteran of the virtualisation specific backup market. It was the...

Download Whitepaper

Techworld UK - Technology - Business

Innovation, productivity, agility and profit

Watch this on demand webinar which explores IT innovation, managed print services and business agility.

Techworld Mobile Site

Access Techworld's content on the move

Get the latest news, product reviews and downloads on your mobile device with Techworld's mobile site.

Find out more...

From Wow to How : Making mobile and cloud work for you

On demand Biztech Briefing - Learn how to effectively deliver mobile work styles and cloud services together.

Watch now...

Site Map

* *