Difference between revisions of "How to protect the harddisk through APS"

From ThinkWiki
Jump to: navigation, search
(Ubuntu)
m (Verifying hdapsd is working)
 
(9 intermediate revisions by 9 users not shown)
Line 11: Line 11:
 
APS in Linux consists of four components on the software side:
 
APS in Linux consists of four components on the software side:
 
* The [[HDAPS]] driver (included in recent kernels). It exports a sysfs interface providing the acceleration values.
 
* The [[HDAPS]] driver (included in recent kernels). It exports a sysfs interface providing the acceleration values.
* The [http://www.dresco.co.uk/hdaps/ <tt>hdaps_protect</tt>] disk protection kernel patch, which exports a sysfs interface that enables an ide or sata disk to be protected by a userspace process.
+
* The <tt>hdaps_protect</tt> disk protection kernel patch, which exports a sysfs interface that enables an ide or sata disk to be protected by a userspace process. You should get the patch appropriate to your kernel version from [http://news.gmane.org/group/gmane.linux.drivers.hdaps.devel/last=/force_load=t gmane.linux.drivers.hdaps.devel].
* The [http://www.dresco.co.uk/hdaps/ <tt>hdapsd</tt>] disk protection userspace daemon. It 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.
+
** '''NOTE''': Starting with kernel 2.6.28 a generic disc protection feature is built into the libata driver
* Optional: the [http://roy.marples.name/node/269 <tt>khdapsmonitor KDE System Tray applet</tt>] or the [http://www.dresco.co.uk/hdaps/ <tt>gnome-hdaps-applet</tt>]. These applets provide a visual indication of the disk protection status and also a graphical interface for adjusting configuration options for <tt>hdapsd</tt>.
+
* The [http://sourceforge.net/projects/hdaps/ <tt>hdapsd</tt>] disk protection userspace daemon. It 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.
 +
* Optional: the [http://roy.marples.name/projects/khdaps/wiki <tt>khdapsmonitor KDE System Tray applet</tt>] or the [http://www.dresco.co.uk/hdaps/ <tt>gnome-hdaps-applet</tt>]. These applets provide a visual indication of the disk protection status and also a graphical interface for adjusting configuration options for <tt>hdapsd</tt>.
 
|}
 
|}
  
Line 31: Line 32:
 
|
 
|
 
See [[HDAPS#Disk_head_parking|HDAPS - Disk head parking]]
 
See [[HDAPS#Disk_head_parking|HDAPS - Disk head parking]]
 +
|-
 +
! {{Slackware}}
 +
|
 +
*<tt>hdapsd</tt> SlackBuild: http://slackbuilds.org/repository/12.2/system/hdapsd/
 
|-
 
|-
 
! {{Debian}}
 
! {{Debian}}
Line 57: Line 62:
 
:{{cmdroot|make}}
 
:{{cmdroot|make}}
 
:{{cmdroot|make modules_install}}
 
:{{cmdroot|make modules_install}}
 +
 +
==== Zen-Sources patched kernel ====
 +
Another way to achieve this is using zen-sources kernel.
 +
It has hdaps patches applied. Additional it supports many other IBM futures like tp_smapi and newest thinkpad_acpi.
 +
 +
Download page for this kind of kernel is http://zen-sources.org/
 +
 +
After downloading a kernel image unpack it to ''/usr/src/linux'' with
 +
:{{cmdroot|tar jxf zen-sources-2.6-version-zen0.tar.bz2 }}
 +
 +
Installation is similar to previous one.
 +
 +
As root, do:
 +
:{{cmdroot|make oldconfig}}
 +
:{{cmdroot|make clean}}
 +
:{{cmdroot|make}}
 +
:{{cmdroot|make modules_install}}
 +
 +
'''make oldconfig''' command will ask you for some information. It's required to tap '''m''' or '''y''' on "HDAPS" functionality, and on some other things connected with Thinkpad.
  
 
=== Installing hdapsd ===
 
=== Installing hdapsd ===
Line 66: Line 90:
  
 
==== Gentoo ====
 
==== Gentoo ====
{{NOTE|1=hdapsd was added to the official portage tree on the 26th June 2006.}}
+
{{NOTE|1=hdapsd was added to the official portage tree on the 26th June 2006. However the version in portage is to be considered outdated. (20060409)}}
{{Gentoo}} users can try the ebuild attached to [http://bugs.gentoo.org/show_bug.cgi?id=119845 gentoo bug 119845].
+
{{Gentoo}} users can try the ebuild attached to [http://bugs.gentoo.org/show_bug.cgi?id=166166 gentoo bug 166166].
 
*Add hdapsd support in your kernel: device drivers -> hardware monitoring -> ... (you need it as a module if you want to use tp_smapi and hdaps, see [[Tp_smapi]])
 
*Add hdapsd support in your kernel: device drivers -> hardware monitoring -> ... (you need it as a module if you want to use tp_smapi and hdaps, see [[Tp_smapi]])
 
*Download the ebuild, use same ebuild date as the kernel-patch.
 
*Download the ebuild, use same ebuild date as the kernel-patch.
Line 86: Line 110:
  
 
==== Ubuntu ====
 
==== Ubuntu ====
hdapsd is available via synaptic for Hardy Heron.
+
hdapsd is available via synaptic for Hardy Heron (9.04) and newer versions.
  
 
=== Building an applet ===
 
=== Building an applet ===
Line 95: Line 119:
 
*{{cmdroot|make}}
 
*{{cmdroot|make}}
 
*Start the applet: {{cmdroot|./hdaps-gl}}
 
*Start the applet: {{cmdroot|./hdaps-gl}}
 +
 +
==Verifying hdapsd is working==
 +
According to instructions from the [http://sourceforge.net/mailarchive/message.php?msg_name=h5r1f4%246s8%241%40ger.gmane.org hdaps-devel mailing list]:
 +
 +
Start {{cmdroot|find /}} in a terminal and move your laptop.  The output should stop while moving (while the heads are parked). When you do this, make sure you do not have any external usb drives. If so it could look like it is not parking the drive while you do this (i.e. it wont park the external and since find is run over the external too, it can continue the find command there).
 +
 +
Alternatively, run {{cmdroot|while true; do cat /sys/block/sda/device/unload_heads; done}} (replacing <tt>sda</tt> with your device) and move the laptop.  When the value is greater than zero the heads are parked.
  
 
==Troubleshooting==
 
==Troubleshooting==

Latest revision as of 18:56, 1 May 2011

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.

Specific instructions for Fedora can be found here.

For Debian (Etch) have a look at this.

How APS works in Linux

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

  • The HDAPS driver (included in recent kernels). It exports a sysfs interface providing the acceleration values.
  • The hdaps_protect disk protection kernel patch, which exports a sysfs interface that enables an ide or sata disk to be protected by a userspace process. You should get the patch appropriate to your kernel version from gmane.linux.drivers.hdaps.devel.
    • NOTE: Starting with kernel 2.6.28 a generic disc protection feature is built into the libata driver
  • The hdapsd disk protection userspace daemon. It 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.
  • Optional: the khdapsmonitor KDE System Tray applet or the gnome-hdaps-applet. These applets provide a visual indication of the disk protection status and also a graphical interface for adjusting configuration options for hdapsd.

Installation

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.

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

Latest Sources

See HDAPS - Disk head parking

Slackware
Debian
Fedora see instructions here
Gentoo

Adding kernel support

A kernel patch is required for disk head parking and queue freezing.

Manually patching and compiling a kernel

As root, do:

# cd /usr/src/linux
# patch -p1 < ~/hdaps_protect.20060409.patch
# make clean
# make
# make modules_install

Zen-Sources patched kernel

Another way to achieve this is using zen-sources kernel. It has hdaps patches applied. Additional it supports many other IBM futures like tp_smapi and newest thinkpad_acpi.

Download page for this kind of kernel is http://zen-sources.org/

After downloading a kernel image unpack it to /usr/src/linux with

# tar jxf zen-sources-2.6-version-zen0.tar.bz2

Installation is similar to previous one.

As root, do:

# make oldconfig
# make clean
# make
# make modules_install

make oldconfig command will ask you for some information. It's required to tap m or y on "HDAPS" functionality, and on some other things connected with Thinkpad.

Installing hdapsd

Manual compilation from source

NOTE!
There has been a new release of hdapsd which doesn't use sysfs anymore and therefore reduces timer interrupts. You need tp_smapi 0.32 for this. See also: http://article.gmane.org/gmane.linux.drivers.hdaps.devel/1040 .
  • Download the hdapsd sources (see above)
  • Compile using # gcc -o hdapsd hdapsd-*.c
  • Run # ./hdapsd -d sda -s 12 -a (replace sda with your hard disk device; run # ./hdapsd without arguments for help)

Gentoo

NOTE!
hdapsd was added to the official portage tree on the 26th June 2006. However the version in portage is to be considered outdated. (20060409)

Gentoo users can try the ebuild attached to gentoo bug 166166.

  • Add hdapsd support in your kernel: device drivers -> hardware monitoring -> ... (you need it as a module if you want to use tp_smapi and hdaps, see Tp_smapi)
  • Download the ebuild, use same ebuild date as the kernel-patch.
  • Make known the portage an extern ebuild path and add the following line to /etc/make.conf:
PORTDIR_OVERLAY="/usr/local/portage/" (or any other location)
  • Create directory /usr/local/portage and /usr/local/portage/app-laptop/
  • Copy the downloaded ebuild to /usr/local/portage/app-laptop (/usr/local/portage/app-laptop/hdapsd should now exists)
  • Make portage known the new ebuild and creat digist with:
# ebuild /usr/local/portage/app-laptop/hdapsd/hdapsd-20060326.ebuild digest
  • Optional: Copy source file to portage distfiles (if no internet connection is available):
# cp hdapsd-20060326.c /usr/portage/distfiles
  • Accept the x86 keyword for this package: # echo "app-laptop/hdapsd ~x86" >> /etc/portage/package.keywords
  • Install hdapsd with: # emerge hdapsd.
  • Edit /etc/conf.d/hdapsd (change your harddrive if neccessary: mine is sda, and change the value from 5, 5 is to sensitive, 12 is a good value in my opinion).
  • start deamon with: # /etc/init.d/hdapsd start
  • Optional: add to default runlevel: # rc-update add hdapsd default, rc-update add hdapsd battery

Write an eMail to abartel[äd]htwm.de, if you want to get my hdapsd-20060326.ebuild and please upload it.

Ubuntu

hdapsd is available via synaptic for Hardy Heron (9.04) and newer versions.

Building an applet

hdaps-gl

  • Make sure you have installed hdaps [and loaded] and ?opengl?
  • Download hdaps-gl-0.0.5 from the web.
  • Extract files to /opt/hdaps-gl.
  • # make
  • Start the applet: # ./hdaps-gl

Verifying hdapsd is working

According to instructions from the hdaps-devel mailing list:

Start # find / in a terminal and move your laptop. The output should stop while moving (while the heads are parked). When you do this, make sure you do not have any external usb drives. If so it could look like it is not parking the drive while you do this (i.e. it wont park the external and since find is run over the external too, it can continue the find command there).

Alternatively, run # while true; do cat /sys/block/sda/device/unload_heads; done (replacing sda with your device) and move the laptop. When the value is greater than zero the heads are parked.

Troubleshooting

See the Problem with APS harddisk parking page for troubleshooting APS issues.

NOTE!
If you use tp_smapi, remember to include the option HDAPS=1 when installing tp_smapi. Also, you might need to build the hdaps driver as module.

Further Information

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