Difference between revisions of "Hard Drive Active Protection System"

From ArchWiki
Jump to: navigation, search
(hdapsd)
(gnome-hdaps-applet: remove discontinued utility)
 
(30 intermediate revisions by 14 users not shown)
Line 1: Line 1:
[[Category:File systems]]
+
[[Category:Laptops]]
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.
+
[[ja:Hard Drive Active Protection System]]
 +
[[zh-CN:Hard Drive Active Protection System]]
 +
'''H'''ard '''D'''rive '''A'''ctive '''P'''rotection '''S'''ystem ('''HDAPS''') protects 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.}}
+
{{Note|[[SSD]] drives do not need HDAPS as they lack any mechanical components.}}
  
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 or greater to follow this guide.
+
== Shock detection ==
  
==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.
 
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 ===
 +
 
 
[[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).   
 
[[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 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.
+
Install tp_smapi from the community repository. 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.  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.
 
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.
Line 18: Line 20:
 
{{Note|According to [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=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.}}
 
{{Note|According to [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=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 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}}:
 
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
 
  options hdaps invert=1
  
Line 31: Line 34:
 
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 [http://www.thinkwiki.org/wiki/Tp_smapi this table] under the column labelled "HDAPS axis orientation".
 
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 [http://www.thinkwiki.org/wiki/Tp_smapi this table] under the column labelled "HDAPS axis orientation".
  
==Shock Protection==
+
As an alternative to reloading the {{ic|hdaps}} module, the {{ic|invert}} value can also be written directly to {{ic|/sys/devices/platform/hdaps/invert}}.
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===
+
== Shock protection ==
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 {{ic|community/hdapsd}} with pacman. Be sure to review {{ic|/etc/conf.d/hdapsd}} to ensure that it is protecting the correct hard drive.
+
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.
  
====Method #1: systemd====
+
=== hdapsd ===
When using systemd all you need to to is to enable and start the hdapsd daemon.
+
  
$ systemctl enable 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.
$ systemctl start hdapsd
+
  
====Method #2: /etc/rc.local====
+
You should check your "Load cycle count" in [[SMART]] when setting up hdaps, if it is too sensitive the head would park too often and load cycle count would rise too rapidly.
  
Because we have to load the hdaps module in {{ic|rc.local}}, which executes after the DAEMONS array is loaded, we have to put hdapsd in rc.local instead of in DAEMONS like usual.  Modify {{ic|/etc/rc.local}} again, putting this line after the insmod added above:
+
[[Install]] {{Pkg|hdapsd}}. You can [[start]] the hdapsd daemon with {{ic|hdapsd@device.service}}, however you don't need to enable it.
  
  # /etc/rc.d/hdapsd start
+
The package installs udev rules. Udev will start one hdapsd instance for each rotational, non-removable disk it finds.
 +
For more information, see the [https://github.com/evgeni/hdapsd#systemd-and-udev-integration:Link hdapsd github page]
  
====Method #3: /etc/rc.conf====
+
You can adjust the parameters, with which hdapsd is run by providing your own unit file as explained in the [[Systemd#Editing provided units|systemd article]], for example the following file will adjust sensitivity and logging behaviour of the hdaps daemon:
  
The following constitutes the preferred startup method:
+
{{hc|/etc/systemd/system/hdapsd.service.d/sensitivity.conf|<nowiki>
 +
[Service]
 +
ExecStart=
 +
ExecStart=/usr/bin/hdapsd --sensitivity=40 -blp
 +
</nowiki>}}
  
* Place {{ic|thinkpad_ec}} in the MODULES=() section of {{ic|/etc/rc.conf}}
+
And reload the configuration.
  
{{Note|{{Ic|thinkpad_ec}} may no longer require MODULES array listing {{Ic|/etc/rc.conf}}.}}
+
== GUI Utilities ==
  
* Start {{Ic|hdapsd}} as a normal daemon in the DAEMONS=() section of {{ic|/etc/rc.conf}}
+
{{Poor writing|Use Template:App}}
  
  MODULES=(thinkpad_acpi thinkpad_ec acpi-cpufreq)
+
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.
DAEMONS=(hal hdapsd @network @alsa)
+
  
After following one of the methods either reboot or start the daemon manually with:
+
=== kdeplasma-applets-hdaps-monitor ===
  
  # /etc/rc.d/hdapsd start
+
For KDE4 there is a plasmoid for HDAPS monitoring [http://kde-look.org/content/show.php/HDAPS+monitor?content=103481 HDAPS monitor]. The package {{AUR|kdeplasma-applets-hdaps-monitor}} is available in [[AUR]].
  
Now, your computer will monitor the joystick devices and park your disk heads to protect it against shocks. If you find that the HDAPS protection is too sensitive, please edit the file {{Ic|/etc/conf.d/hdapsd}} and adjust the sensitivity line. The default value is ''15''. The larger the number, the less sensitive HDAPS protection gets. The value ''35'' might be a good starting point. <br>
+
=== xfce4-hdaps ===
After changing the values in this file you need to restart the hdapsd daemon:
+
 
+
  # /etc/rc.d/hdapsd restart
+
 
+
You can check if HDAPS is working with:
+
 
+
  $ sudo tail -f /var/log/messages.log
+
 
+
If you jiggle your laptop and HDAPS is active, you should see ''parking''/''un-parking'' messages. (You may also be able to hear the hard drive park. Do not do this too much! {{ic|:)}}
+
 
+
==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 Xfce4 panel applet that can represents the current status of your hard drive. Available in [[AUR]]: {{AUR|xfce4-hdaps}}. After install, add this applet to a panel.
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.
+
  
===khdapsmonitor===
+
=== HDAPSicon ===
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).
+
HDAPSicon, formerly thinkhdaps, is a standalone GTK applet for HDAPS disk protection status. While running will show applet icon in the notification area. Available in AUR: {{AUR|hdapsicon-git}}.
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===
+
=== hdaps-gl ===
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===
+
Simple OpenGL application showing the 3D animation of your Thinkpad. Similar to the apllication Lenovo distributes with Windows. {{AUR|hdaps-gl}} is 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===
+
== See also ==
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==
+
* [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]
+

Latest revision as of 21:15, 20 October 2016

Hard Drive Active Protection System (HDAPS) protects 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: SSD drives do not need HDAPS as they lack any mechanical components.

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 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".

As an alternative to reloading the hdaps module, the invert value can also be written directly to /sys/devices/platform/hdaps/invert.

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.

You should check your "Load cycle count" in SMART when setting up hdaps, if it is too sensitive the head would park too often and load cycle count would rise too rapidly.

Install hdapsd. You can start the hdapsd daemon with hdapsd@device.service, however you don't need to enable it.

The package installs udev rules. Udev will start one hdapsd instance for each rotational, non-removable disk it finds. For more information, see the hdapsd github page

You can adjust the parameters, with which hdapsd is run by providing your own unit file as explained in the systemd article, for example the following file will adjust sensitivity and logging behaviour of the hdaps daemon:

/etc/systemd/system/hdapsd.service.d/sensitivity.conf
[Service]
ExecStart=
ExecStart=/usr/bin/hdapsd --sensitivity=40 -blp

And reload the configuration.

GUI Utilities

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements.Tango-edit-clear.png

Reason: Use Template:App (Discuss in Talk:Hard Drive Active Protection System#)

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.

kdeplasma-applets-hdaps-monitor

For KDE4 there is a plasmoid for HDAPS monitoring HDAPS monitor. The package kdeplasma-applets-hdaps-monitorAUR is available in AUR.

xfce4-hdaps

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

HDAPSicon

HDAPSicon, formerly thinkhdaps, is a standalone GTK applet for HDAPS disk protection status. While running will show applet icon in the notification area. Available in AUR: hdapsicon-gitAUR.

hdaps-gl

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

See also