Instead of introducing
Becoming a relatively happy owner of a
Lenovo ThinkPad T410 laptop, my first
a political decision was the change of state arrangement - the installation of a convenient Linux for me
as the primary operating system. The Debian Testing (Squeeze) distribution kit was chosen as the messenger carrying good and light.
Agree that it makes little sense to buy a business class laptop and not to use at least all its possibilities.
HDAPS
Among the many not only the most interesting and useful buns provided by ThinkPads there is one about which will be discussed below. Her name is
HDAPS (Hard Drive Active Protection System; active hard disk protection system). The principle of its operation is similar to car airbags, triggered in an accident. On the motherboard of the laptop there is a microchip that controls the sudden acceleration of the computer case. For example, the fall of the laptop. When such a situation arises, the system instantly blocks the head of the hard disk. When the system returns to its former, quieter state, the hard drive starts up in normal mode.
')
The ability to respond to such events allows you to avoid hard disk crashes when falling or just shaking. But the most important thing, of course, is preventing data loss.
HDAPS is not a unique solution of Lenovo (IBM) in the market of computing equipment. Similar or even more advanced buns are provided by other major laptop manufacturers. For example, SMS (Sudden Motion Senser) from Apple or FFS (Free Fall Sensor) from Dell
[0] .
There are no problems in Linux either.
HDAPS works in Windows that is out of the box. In Linux, the situation is somewhat different: our bun will work there too. But according to the time-tested tradition, only after a couple of harmless and weak blows with a file.
There is an incredibly beautiful and useful website on the Web, which is just a wealth of information on how to tweak a ThinkPad in Linux -
ThinkWiki [1] . If a question arises on the ThinkPad, then with a probability of ~ 85%, the most relevant answer to it can be found on ThinkWiki. There is also a wonderful article
“How to protect the harddisk through APS” [2] , which tells in detail what is required to be done in order for HDAPS to work in Linux: compile a couple of modules and install a magic demon. After that, the HDD protection system will start working. Anytime and anywhere.
We make it even wiser
But we are rational people. Why does such a useful system work even when the computer is not only standing on the table, but also still connected to the power supply? It makes sense to include HDAPS only when the laptop begins to use in its basic quality - a mobile computer; transferring in the included from place to place state. Then, when the risk of dropping a laptop from any height is high enough. In other cases, you can simply turn off our subsystem.
Step 1: Determine the Power Supply
In order to perform an action when the power supply of the laptop changes, it is necessary to use the features of the pm-utils package, which is installed by default in most Linux distributions. To do this, put in /etc/pm/power.d the following hdaps
file with the right of execution (
chmod + x /etc/pm/power.d/hdaps ):
- #! / bin / sh
- HDAPS_MODULES = "thinkpad_ec tp_smapi hdaps"
- HDAPSD_INIT_SCRIPT = / etc / init.d / hdapsd
- MODPROBE = / sbin / modprobe
- RMMOD = / sbin / rmmod
- case "$ 1" in
- ### CASE: Work on battery
- true )
- echo "Enabling HDAPS"
- for module in $ HDAPS_MODULES ; do
- $ MODPROBE $ module
- done
- $ HDAPSD_INIT_SCRIPT start
- ;;
- ### CASE: Work on AC-adapter
- false )
- echo "Disabling HDAPS"
- $ HDAPSD_INIT_SCRIPT stop
- ### NOTE: modules should be unloaded in the reverse order
- for module in echo $ HDAPS_MODULES | tac -s '' ` ; do
- $ RMMOD $ module
- done
- ;;
- esac
When the power source (battery or adapter) changes, the scripts located in
/etc/pm/power.d are called in
turn . So the turn reaches and our code. Each script is called with one argument:
true or
false . If true, then our ThinkPad switched to battery mode; therefore we need to activate HDAPS. To do this, we use modprobe to load the modules required for the subsystem (aka “drivers” without which nothing will take off) and the hdapsd daemon starts. If the computer is powered by an adapter, our hdaps script gets false as an argument. In this case, all previous steps must be repeated in the reverse order to pause HDAPS.
Step 2: Disable HDAPS autoloading
Since the scripts from /etc/pm/power.d are always called when you turn on / wake up your laptop, it makes no sense to unconditionally download HDAPS every time, in just a few seconds to disable it using our script. To disable autoloading enough:
1. Remove from / etc / modules the list of dependent modules (
thinkpad_ec, tp_smapi, hdaps );
2. Disable hdapsd daemon autostart:
update-rc.d -f hdapsd remove .
Result
HDAPS now only works when you really need it. For a "clean" check, just restart the computer and try disconnecting the adapter from the laptop: the list of loaded modules (
lsmod + grep ) should change and the list of running processes (
ps -aux + grep )
should be updated .
UPD: Naturally, this instruction is by no means mandatory for all ThinkPad owners with Linux on board. If there is a rather big risk that the laptop can make a swift flight towards the floor while being connected to the adapter, it makes sense to leave the HDAPS settings “as is”.
Literature
- [0] Active Hard Drive Protection, en.wikipedia.org/wiki/Active_hard_drive_protection
- [1] ThinkWiki, thinkwiki.org
- [2] How to enable HDAPS, www.thinkwiki.org/wiki/How_to_protect_the_harddisk_through_APS