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

From ThinkWiki
Jump to: navigation, search
(khdapsmon)
Line 3: Line 3:
 
|style="vertical-align:top" |
 
|style="vertical-align:top" |
 
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.
 
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 ==
 
== How APS works in Linux ==
 
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). (As a modul if you want to use tp_smapi (Gentoo-Linux))
+
* The [[HDAPS]] driver (included in recent kernels). It exports a sysfs interface providing the acceleration values.
* The <tt>hdaps_protect</tt> disk protection kernel patch (available [http://www.dresco.co.uk/hdaps/hdaps_protect.20060118.patch for kernel 2.6.15] and [http://www.dresco.co.uk/hdaps/hdaps_protect.20060409.patch for kernel 2.6.16]; see [[HDAPS#Disk_head_parking|here]] for other versions)
+
* 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 [http://www.dresco.co.uk/hdaps/hdapsd-20060409.c <tt>hdapsd</tt>] disk protection userspace daemon
+
* 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.
* Optional: the [http://www.oakcourt.dyndns.org/projects/khdapsmon/ <tt>khdapsmon</tt> KDE System Tray applet] or the [http://www.dresco.co.uk/hdaps/gnome-hdaps-applet-20060120.tar.gz <tt>gnome-hdaps-applet</tt>].
+
* Optional: the [http://www.oakcourt.dyndns.org/projects/khdapsmon/ <tt>khdapsmon</tt> KDE System Tray applet] 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 [[HDAPS|HDAPS driver]] exports a sysfs interface providing the acceleration values.
+
 
+
The <tt>hdaps_protect</tt> kernel patch exports a sysfs interface that enables an ide or sata disk to be protected by a userspace process.
+
 
+
The <tt>hdapsd</tt> 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.
+
 
+
The optional KDE/GNOME applets provide a visual indication of the disk protection status and also a graphical interface for adjusting configuration options for <tt>hdapsd</tt>.
+
  
 
==Installation==
 
==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.  
 
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.  
{{NOTE|1=If you use [[tp_smapi]], remember to include the option <tt>HDAPS=1</tt> when [[Tp_smapi#Installation|installing tp_smapi]].}}
+
{{NOTE|1=If you use [[tp_smapi]], remember to include the option <tt>HDAPS=1</tt> when [[Tp_smapi#Installation|installing tp_smapi]]. Also, you might need to build the hdaps driver as module.}}
 
In order to use this information to protect the disk, some additional steps are required.
 
In order to use this information to protect the disk, some additional steps are required.
  

Revision as of 03:58, 17 April 2006

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 (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.
  • 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 khdapsmon 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.

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.

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
Debian
  • hdapsd, hdaps_protect, khdapsmon, gnome-hdaps-applet:
# deb http://www.oakcourt.dyndns.org/debian/ ./
# deb-src http://www.oakcourt.dyndns.org/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

Installing hdapsd

Manual compilation from source

  • 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)

Fedora Core

Fedora users can try the instructions here

Gentoo

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

  • Add hdapsd support in your kernel: device drivers -> hardware monitoring -> ... (you need it as modul if you want to use tp_smapi and hdaps, see tp_smapi topic)
  • 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: my 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.

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
Fedora Core

Fedora users can try the instructions here

khdapsmon

This application uses GNU autotools, so building it is the same as any other autotooled program:

  • extract the source somewhere and change to that directory,
  • run # ./configure && make && make install.

See above for Debian packages and a Gentoo ebuild.

gnome-hdaps-applet

Fedora Core

Fedora users can try the instructions here

Debian/Ubuntu

Packages available at site listed above (with source packages that can do the building for you)

Troubleshooting

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

Further Information

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