How to protect the harddisk through APS

From ThinkWiki
Revision as of 08:24, 23 March 2006 by Whoopie (Talk | contribs)

Jump to: navigation, search

This page tells you how to make the Active Protection System work under Linux to protect your harddrive from damage in case of a notebook drop or other kind of impact while it is running.

How APS works in Linux

APS in Linux consists of four components on the software side:

The HDAPS driver exports a sysfs interface providing the acceleration values.

The hdaps_protect kernel patch xports a sysfs interface that enables an ide or sata disk to be protected by a userspace process.

The hdapsd userspace daemon monitors the acceleration values through the HDAPS interface and automatically initiates disk protection through the hdaps_protect interface - given that the movement exceeds a user specified threshold.

Finally the applets are providing a visual indication of the disk protection status and provide a graphical interface for adjusting configuration options for hdapsd.


As mentioned above, the hdaps kernel driver found in recent kernels is only responsible for reading the accelerometer data and exporting it through the sysfs interface.

If you use tp_smapi, remember to include the option HDAPS=1 when installing tp_smapi.

In order to use this information to protect the disk, some additional steps are required.

  • Download and build the latest hdaps_protect disk protection kernel patches.
  • Enable the drivers in the kernel (requires kernel rebuild).
  • Download, build and configure the hdapsd userspace daemon.
  • Download and build one of the applets to get a real-time representation of the disk protection status.

Getting the files

The latest versions of hdaps_protect, hdapsd and the gnome-hdaps-applet can be downloaded from

khdapsmon can befound here.

Debian source and sid binary packages for hdapsd and the hdaps_protect patches (kernel-patch format) are available via APT access:

deb ./
deb-src ./

Patching the kernel and enabling the drivers

As root go to /usr/src/linux

# patch -p1 < ~/hdaps_protect.20060118.patch

tell about how to patch the kernel and what needs to be enabled afterwards

Problem with unload capabilities check

After installation, you may get the following kernel message when the disk is protected (e.g., via # echo 1 > /sys/block/sda/queue/protect):

ata_scsi_issue_protect_fn(): unload support NOT reported..
scsi_protect_queue(): head park not requested, used standby!..


idedisk_issue_protect_fn(): unload support NOT reported..
ide_protect_queue(): head park not requested, used standby!..
Using HDAPS in the above state may cause frequent drive spin downs, thereby wearing out your hard disk.

If you see this, and you are sure that your drive actually does support unloading (all original drives sold with HDAPS-equipped ThinkPads do), then add the following patch on top of the above patch:

diff -u linux-2.6.15.hdaps/drivers/ide/ide-disk.c linux-2.6.15.hdaps/drivers/ide/ide-disk.c
--- linux-2.6.15.hdaps/drivers/ide/ide-disk.c	2006-01-18 07:11:54.000000000 +0000
+++ linux-2.6.15.hdaps/drivers/ide/ide-disk.c	2006-01-18 07:11:54.000000000 +0000
@@ -869,7 +869,7 @@
 		printk(KERN_DEBUG "idedisk_issue_protect_fn(): unload support NOT reported..\n");
-	return ide_protect_queue(q, (drive->id->cfsse & (1 << 13)) ? 1: 0);
+	return ide_protect_queue(q, 1);
 int idedisk_issue_unprotect_fn(request_queue_t *q)
diff -u linux-2.6.15.hdaps/drivers/scsi/libata-scsi.c linux-2.6.15.hdaps/drivers/scsi/libata-scsi.c
--- linux-2.6.15.hdaps/drivers/scsi/libata-scsi.c	2006-01-18 07:15:31.000000000 +0000
+++ linux-2.6.15.hdaps/drivers/scsi/libata-scsi.c	2006-01-18 07:15:31.000000000 +0000
@@ -661,7 +661,7 @@
 		printk(KERN_DEBUG "ata_scsi_issue_protect_fn(): unload support NOT reported..\n");
 	/* call scsi_protect_queue, requesting either unload or standby */
-	return scsi_protect_queue(q, ata_id_has_unload(dev->id) ? 1 : 0);
+	return scsi_protect_queue(q, 1);
 static int ata_scsi_issue_unprotect_fn(request_queue_t *q)

Drives on which the capabilities check patch is needed

  • Hitachi HTS726060M9AT00 (7K60) on ThinkPad T43

Installing hdapsd

tell how to build hdapsd

Configuring hdapsd

tell how to configure hdapsd

Building an applet

Building khdapsmon

tell people what to do

Building gnome-hdaps-applet

tell people what to do

Further Information

  • Additonal information and support is available through the hdaps-devel mailinglist and its archive.