Difference between revisions of "Hard Drive Active Protection System"

From ArchWiki
Jump to: navigation, search
m (thinkhdaps A standalone GTK applet)
(Remove initscripts method and old kernel info.)
(39 intermediate revisions by 16 users not shown)
Line 1: Line 1:
[[Category:File systems (English)]]
+
[[Category:File systems]]
This page describes how to install HDAPS on your Arch Linux installation.  HDAPS stands for "Hard Drive Active Protection System."  Its purpose is to protect your hard drive from sudden shocks (such as dropping or banging your laptop on a desk).  It does this by parking the disk heads, so that shocks don't cause them to crash into the drive's platters.  Hopefully, this will prevent catastrophic failure.
+
This page describes how to install HDAPS on your Arch Linux installation.  HDAPS stands for "Hard Drive Active Protection System."  Its purpose is to protect your hard drive from sudden shocks (such as dropping or banging your laptop on a desk).  It does this by parking the disk heads, so that shocks do not cause them to crash into the drive's platters.  Hopefully, this will prevent catastrophic failure.
  
As of Linux 2.6.28, the kernel has the ability to park disk heads on demand.  Previously, this had to be patched into the kernel.  Thanks to the kernel devs' hard work, we no longer have to rebuild our kernel to use this feature. Obviously, this means you need to be running 2.6.28 to follow this guide.
+
{{Note|Obviously this only makes sense for hard drives that have mechanical parts. If you are using a Solid State Disk (SSD) you do not need HDAPS.}}
  
 
==Shock Detection==
 
==Shock Detection==
Line 8: Line 8:
  
 
===tp_smapi===
 
===tp_smapi===
[[tp_smapi]] is a set of drivers for ThinkPad laptops.  It is highly recommended if you have a ThinkPad, even if you don't plan to use HDAPS.  Among a plethora of other useful things, tp_smapi represents the accelerometer output as joystick devices <code>/dev/input/js#</code> (Note! This could interfere with other joystick devices on your system).   
+
[[tp_smapi]] is a set of drivers for many ThinkPad laptops.  It is highly recommended if you have a supported ThinkPad, even if you do not plan to use HDAPS.  Among a plethora of other useful things, tp_smapi represents the accelerometer output as joystick devices {{ic|/dev/input/js#}} (Note! This could interfere with other joystick devices on your system).   
  
Install [http://aur.archlinux.org/packages.php?ID=3985 tp_smapi] from AUR.  After installing, add <code>tp_smapi</code> to your <code>MODULES</code> array.  After a reboot, this will activate most of the drivers, represented through the <code>/sys/devices/platform/smapi</code> filesystem.
+
Install tp_smapi from the community repository.  After installing, add {{ic|tp_smapi}} to a file {{ic|/etc/modules-load.d/tp_smapi.conf}}, assuming you are using systemd.  After a reboot, this will activate most of the drivers, represented through the {{ic|/sys/devices/platform/smapi}} filesystem.
  
The kernel provides its own HDAPS drivers.  For this reason, the HDAPS part of tp_smapi is built separately.  Attempting to add <code>hdaps</code> to your <code>MODULES</code> array will result in the default drivers being loaded.  This is not what we want, as we have our special ThinkPad HDAPS drivers. Instead, modify your /etc/rc.local to include the following line:
+
The kernel provides its own HDAPS drivers.  Previously, it was necessary to manually {{ic|insmod}} the module via {{ic|/etc/rc.local}} to prevent the default drivers from being loaded.  The [[tp_smapi]] package from community now installs {{ic|hdaps.ko}} to [http://www.mail-archive.com/arch-dev-public@archlinux.org/msg01995.html /lib/modules/$(uname -r)/updates], which will let it supercede the built-in module.  Thus, you can simply add {{ic|hdaps}} to your {{ic|MODULES}} array.
<code>insmod /lib/modules/$(uname -r)/extra/hdaps.ko </code>
+
  
This will load the ThinkPad HDAPS module at the end of the initialization sequence.
+
{{Note|According to [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug&#61;628829 this bug report], certain ThinkPad laptops use different firmware which tp_smapi does not support and is unlikely to support in the near future. This includes the following series: Edge, SL, L, X1xxe. Only one of these is listed in the "unsupported hardware" page for the project, however, and that listing suggests that the x121e should mostly work. I get the same error with the x121e listed at the bottom of the bug report as a different and more fundamental problem, though, so it may be that some models of the x121e are mostly supported and others are entirely unsupported.}}
  
 
=== invert module parameter ===
 
=== invert module parameter ===
  
For some thinpad, the invert module parameter is needed in order to handle the X and Y rotation axes correctly. In that case, you can simply add the option to the insmod command, e.g.:
+
For some ThinkPads, the invert module parameter is needed in order to handle the X and Y rotation axes correctly. In that case, you can add the option in {{ic|/etc/modprobe.d/modprobe.conf}}:
 +
options hdaps invert=1
  
insmod /lib/modules/$(uname -r)/extra/hdaps.ko invert=5
+
{{ic|1=invert=1}} is an example value used for a ThinkPad T410. The invert option takes the following values:
 
+
for a ThinkPad X200. The invert option takes the following values:
+
  
 
* invert=1 invert both X and Y axes;
 
* invert=1 invert both X and Y axes;
Line 37: Line 35:
 
hdapsd monitors the output of the HDAPS joystick devices to determine if a shock is about to occur, then tells the kernel to park the disk heads.
 
hdapsd monitors the output of the HDAPS joystick devices to determine if a shock is about to occur, then tells the kernel to park the disk heads.
  
Install [http://aur.archlinux.org/packages.php?ID=5401 hdapsd] from AUR.  Be sure to review <code>/etc/conf.d/hdapsd</code> to ensure that it's protecting the correct hard drive.
+
Install {{Pkg|hdapsd}} with pacman.  Be sure to review {{ic|/etc/conf.d/hdapsd}} to ensure that it is protecting the correct hard drive.
  
Because we have to load the hdaps module in <code>rc.local</code>, which executes after the DAEMONS array is loaded, we have to put hdapsd in rc.local instead of in DAEMONS like usual.  Modify <code>/etc/rc.local</code> again, putting this line after the insmod added above:
+
When using systemd all you need to to is to enable and start the hdapsd daemon.
/etc/rc.d/hdapsd start
+
After a reboot, your computer will now monitor the joystick devices and park your disk heads to protect it against shocks.
+
  
Reboot your computer at this point. After init, if you jiggle your laptop, you should be able to hear the hard drive park. Don't do this too much <code>:)</code>
+
  # systemctl enable hdapsd
 +
  # systemctl start hdapsd
  
 
==GUI Utilities==
 
==GUI Utilities==
Utilities exist to monitor hdapsd's status so you know what's going on while you're using your laptop.  These are entirely optional, but very handy.
+
Utilities exist to monitor hdapsd's status so you know what is going on while you are using your laptop.  These are entirely optional, but very handy.
  
 
===gnome-hdaps-applet===
 
===gnome-hdaps-applet===
This is a GNOME panel applet (Note: XFCE can use GNOME panel applets) that represents the current status of your hard drive. If the disk heads are parked by hdapsd, this applet will reflect that.  Unfortunately, the AUR project for gnome-hdaps-applet is very out of date and does not work any longer.  This should be fixed, but for now, here's how to do it manually.  Note that pacman '''will not''' manage these files.  If you update this applet later, you'll have to manually remove and replace these files.
+
This is a GNOME panel applet (Note: XFCE can use GNOME panel applets) that represents the current status of your hard drive. There is already a PKGBUILD in AUR ([https://aur.archlinux.org/packages.php?ID=11772 see here]). If you do not want to monitor sda or hda by default, edit the PKGBUILD before compiling.
 
+
First, grab the latest gnome-hdaps-applet sources from the [http://www.zen24593.zen.co.uk/hdaps/ this HDAPS mirror]. As of this writing, this is version <code>20081204</code>.  Inflate these files, and follow the instructions in <code>INSTALL</code>.  It's very straight-forward.  When you're done, keep the <code>INSTALL</code> file around for future reference if you have to update or uninstall the applet later.  Again, remember that pacman will not manage these files for you in any way.
+
  
 
===khdapsmonitor===
 
===khdapsmonitor===
A KDE version exists as well.  [http://aur.archlinux.org/packages.php?ID=12679 khdapsmonitor] in AUR (This project was abandoned and it is for KDE3).
+
A KDE version exists as well.  [https://aur.archlinux.org/packages.php?ID=12679 khdapsmonitor] in AUR (This project was abandoned and it is for KDE3).
For KDE4 there is a version of plasmoid for HDAPS monitoring [http://www.kde-look.org/content/show.php/Applet+HDAPS?content=78387 HDAPS applet]. [http://aur.archlinux.org/packages.php?ID=25965 HDAPS-Monitor plasmoid] is available in AUR.
+
For KDE4 there is a version of plasmoid for HDAPS monitoring [http://www.kde-look.org/content/show.php/Applet+HDAPS?content=78387 HDAPS applet]. [https://aur.archlinux.org/packages.php?ID=25965 HDAPS-Monitor plasmoid] is available in AUR.
  
 
===xfce4-hdaps applet===
 
===xfce4-hdaps applet===
 
This is a Xfce4 panel applet that can represents the current status of your hard drive. Available in AUR. After install, add this applet to a panel.
 
This is a Xfce4 panel applet that can represents the current status of your hard drive. Available in AUR. After install, add this applet to a panel.
  
===thinkhdaps A standalone GTK applet===  
+
===thinkhdaps A standalone GTK applet===
 
A standalone GTK applet for HDAPS disk protection status. While running will show applet icon in the notification area. Available in AUR.
 
A standalone GTK applet for HDAPS disk protection status. While running will show applet icon in the notification area. Available in AUR.
  
 
===hdaps-gl===
 
===hdaps-gl===
Simple OpenGL application showing the 3D animation of your Thinkpad. Similar to the apllication Lenovo distibutes with Windows. [http://aur.archlinux.org/packages.php?ID=23485 hdaps-gl] is available in AUR.
+
Simple OpenGL application showing the 3D animation of your Thinkpad. Similar to the apllication Lenovo distributes with Windows. [https://aur.archlinux.org/packages.php?ID=23485 hdaps-gl] is available in AUR.
  
 
==See Also==
 
==See Also==
 
*[http://www.thinkwiki.org/wiki/How_to_protect_the_harddisk_through_APS How to protect the harddisk through APS at ThinkWiki]
 
*[http://www.thinkwiki.org/wiki/How_to_protect_the_harddisk_through_APS How to protect the harddisk through APS at ThinkWiki]
 
*[http://www.thinkwiki.org/wiki/HDAPS HDAPS at ThinkWiki]
 
*[http://www.thinkwiki.org/wiki/HDAPS HDAPS at ThinkWiki]

Revision as of 06:47, 17 April 2013

This page describes how to install HDAPS on your Arch Linux installation. HDAPS stands for "Hard Drive Active Protection System." Its purpose is to protect your hard drive from sudden shocks (such as dropping or banging your laptop on a desk). It does this by parking the disk heads, so that shocks do not cause them to crash into the drive's platters. Hopefully, this will prevent catastrophic failure.

Note: Obviously this only makes sense for hard drives that have mechanical parts. If you are using a Solid State Disk (SSD) you do not need HDAPS.

Shock Detection

Your hardware needs to support some kind of shock detection. This is usually in the form of an accelerometer built into your laptop's motherboard. If you have the hardware, you also need a way to communicate what the hardware is detecting to your operating system. This section describes drivers to communicate the accelerometer's state to the OS so it can detect and protect against shocks.

tp_smapi

tp_smapi is a set of drivers for many ThinkPad laptops. It is highly recommended if you have a supported ThinkPad, even if you do not plan to use HDAPS. Among a plethora of other useful things, tp_smapi represents the accelerometer output as joystick devices /dev/input/js# (Note! This could interfere with other joystick devices on your system).

Install tp_smapi from the community repository. After installing, add tp_smapi to a file /etc/modules-load.d/tp_smapi.conf, assuming you are using systemd. After a reboot, this will activate most of the drivers, represented through the /sys/devices/platform/smapi filesystem.

The kernel provides its own HDAPS drivers. Previously, it was necessary to manually insmod the module via /etc/rc.local to prevent the default drivers from being loaded. The tp_smapi package from community now installs hdaps.ko to /lib/modules/$(uname -r)/updates, which will let it supercede the built-in module. Thus, you can simply add hdaps to your MODULES array.

Note: According to this bug report, certain ThinkPad laptops use different firmware which tp_smapi does not support and is unlikely to support in the near future. This includes the following series: Edge, SL, L, X1xxe. Only one of these is listed in the "unsupported hardware" page for the project, however, and that listing suggests that the x121e should mostly work. I get the same error with the x121e listed at the bottom of the bug report as a different and more fundamental problem, though, so it may be that some models of the x121e are mostly supported and others are entirely unsupported.

invert module parameter

For some ThinkPads, the invert module parameter is needed in order to handle the X and Y rotation axes correctly. In that case, you can add the option in /etc/modprobe.d/modprobe.conf:

options hdaps invert=1

invert=1 is an example value used for a ThinkPad T410. The invert option takes the following values:

  • invert=1 invert both X and Y axes;
  • invert=2 invert the X axes (uninvert if already both axes inverted)
  • invert=4 swap X and Y (takes place before inverting)

Note that options can be summed. For instance, invert=5 swaps the axes and inverts them. The maximum value of invert is obviously 7. If you do not know which option is correct for you, just try them out with hdaps-gl or some other GUI (see below). Alternatively, you can determine the exact value for your thinkpad model from this table under the column labelled "HDAPS axis orientation".

Shock Protection

Now that your hardware is reporting its shock detection to the OS, we need to do something with this data. This section describes software utilities to transform the sensor output into shock protection.

hdapsd

hdapsd monitors the output of the HDAPS joystick devices to determine if a shock is about to occur, then tells the kernel to park the disk heads.

Install hdapsd with pacman. Be sure to review /etc/conf.d/hdapsd to ensure that it is protecting the correct hard drive.

When using systemd all you need to to is to enable and start the hdapsd daemon.

# systemctl enable hdapsd
# systemctl start hdapsd

GUI Utilities

Utilities exist to monitor hdapsd's status so you know what is going on while you are using your laptop. These are entirely optional, but very handy.

gnome-hdaps-applet

This is a GNOME panel applet (Note: XFCE can use GNOME panel applets) that represents the current status of your hard drive. There is already a PKGBUILD in AUR (see here). If you do not want to monitor sda or hda by default, edit the PKGBUILD before compiling.

khdapsmonitor

A KDE version exists as well. khdapsmonitor in AUR (This project was abandoned and it is for KDE3). For KDE4 there is a version of plasmoid for HDAPS monitoring HDAPS applet. HDAPS-Monitor plasmoid is available in AUR.

xfce4-hdaps applet

This is a Xfce4 panel applet that can represents the current status of your hard drive. Available in AUR. After install, add this applet to a panel.

thinkhdaps A standalone GTK applet

A standalone GTK applet for HDAPS disk protection status. While running will show applet icon in the notification area. Available in AUR.

hdaps-gl

Simple OpenGL application showing the 3D animation of your Thinkpad. Similar to the apllication Lenovo distributes with Windows. hdaps-gl is available in AUR.

See Also