/ 中存储网

告诉你Ubuntu下安装Thinkpad T400硬盘保护APS的方法及命令

2015-02-03 00:00:00 来源:中存储网

今天终于把这个问题搞定,记录下,网上那些文章说得不全,主要是给的网址下不了文件。在XP下安装APS很简单,直接安装就好。

在Ubuntu下就比较麻烦了,一直以来就想解决这个问题,在网上也搜了一些资料看,试着做了下,都不成功。

今天下了决心一定要把这个问题解决,就完全按照资料的顺序全部重新做一遍,一直到使用

$ sudo hdapsd -d sda -s 15 -a -v -y

来显示数据都是成功的,下一步

$ wget http://www.unet.univie.ac.at/~a0604095/hdapsd

这里就下载不了hdapsd这个文件,就通过下deb包,把hdapsd分离出来,并且需要两个不同的hdapsd文件,一个位于/etc/init.d/,另一个位于/etc/default/(末尾附这两个  文件代码),然后,必须要执行$sudo /etc/init.d/hdapsd restart才能正常工作,不可能每次开机都去输入这条命令吧。

于是要使它开机自己运行,要把它放在/etc/rc2.d/接下来,做一个软链接

$sudo ln -s /etc/init.d/hdapsd /etc/rc2.d/S99hdapsd

问题全部解决,开机自动工作,保护硬盘。

附:

/etc/default/hdapsd:

# hdapsd default file

# start hdapsd at boottime?

START="yes"

# the name of the disk device that hdapsd should monitor.

#

# usually this is 'hda' for the primary IDE master or 'sda'

# for the primary S-ATA drive

DISK="sda"

# sensitivity

SENSITIVITY=15

# other options to pass to hdapsd.

# the -d $DISK, -s $SENSITIVITY, -b and -p $PIDFILE options are always passed.

OPTIONS=""

# The new interface in kernels >=2.6.28 sometimes wrongly detects HDAPS-capable

# drives as not supported. Set this to "yes" to force-enable the feature.

# Please be carefull with this setting!

FORCEENABLE="no"

/etc/init.d/hdapsd

#! /bin/sh

### BEGIN INIT INFO

# Provides: hdapsd

# Required-Start: $local_fs $remote_fs

# Required-Stop: $local_fs $remote_fs

# Default-Start: 2 3 4 5

# Default-Stop: 0 1 6

# Short-Description: initscript to start hdapsd

# Description: This file starts the hdapsd daemon

### END INIT INFO

# Author: Evgeni Golov <sargentd@die-welt.net>

# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script

PATH=/sbin:/usr/sbin:/bin:/usr/bin

DESC="IBM公司 Hard Disk Active Protection System (HDAPS) daemon"

NAME=hdapsd

DAEMON=/usr/sbin/$NAME

DAEMON_ARGS=""

PIDFILE=/var/run/$NAME.pid

SCRIPTNAME=/etc/init.d/$NAME

START="no"

DISK="sda"

SENSITIVITY=15

OPTIONS=""

FORCEENABLE="no"

# Exit if the package is not installed

[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present

[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Do we really want to start the daemon?

[ "$START" = "yes" ] || exit 0

# Load the VERBOSE setting and other rcS variables

. /lib/init/vars.sh

# Define LSB log_* functions.

# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.

. /lib/lsb/init-functions

DAEMON_ARGS="-p$PIDFILE -d $DISK -s $SENSITIVITY -b $OPTIONS"

if [ "$FORCEENABLE" = "yes" ]; then

DAEMON_ARGS="$DAEMON_ARGS -f"

fi

#

# Function that checks if /sys/block/$DISK/queue/protect

# or /sys/block/$DISK/device/unload_heads exist

#

do_checkprotect()

{

if [ ! -f /sys/block/$DISK/queue/protect -a ! -f /sys/block/$DISK/device/unload_heads ]; then

log_warning_msg "Not starting $NAME: neither /sys/block/$DISK/queue/protect nor /sys/block/$DISK/device/unload_heads do exist, please read /usr/share/doc/hdapsd/README.Debian"

exit 0

fi

}

#

# Function that starts the daemon/service

#

do_start()

{

# Return

# 0 if daemon has been started

# 1 if daemon was already running

# 2 if daemon could not be started

start-stop-daemon --start --quiet --exec $DAEMON --test > /dev/null || return 1

start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_ARGS || return 2

# Add code here, if necessary, that waits for the process to be ready

# to handle requests from services started subsequently which depend

# on this one. As a last resort, sleep for some time.

}

#

# Function that stops the daemon/service

#

do_stop()

{

# Return

# 0 if daemon has been stopped

# 1 if daemon was already stopped

# 2 if daemon could not be stopped

# other if a failure occurred

start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME

RETVAL="$?"

[ "$RETVAL" = 2 ] && return 2

# Wait for children to finish too if this is a daemon that forks

# and if the daemon is only ever run from this initscript.

# If the above conditions are not satisfied then add some other code

# that waits for the process to drop all resources that could be

# needed by services started subsequently. A last resort is to

# sleep for some time.

start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON

[ "$?" = 2 ] && return 2

# Many daemons don't delete their pidfiles when they exit.

rm -f $PIDFILE

return "$RETVAL"

}

#

# Function that sends a SIGUSR1 to the daemon/service

#

do_pause() {

start-stop-daemon --stop --signal 10 --quiet --pidfile $PIDFILE --name $NAME

return 0

}

case "$1" in

start)

do_checkprotect

[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"

do_start

case "$?" in

0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;

2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;

esac

;;

stop)

[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"

do_stop

case "$?" in

0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;

2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;

esac

;;

pause)

[ "$VERBOSE" != no ] && log_daemon_msg "Pauseing (8sec) $DESC" "$NAME"

do_pause

;;

restart|force-reload)

#

# If the "reload" option is implemented then remove the

# 'force-reload' alias

#

log_daemon_msg "Restarting $DESC" "$NAME"

do_stop

case "$?" in

0|1)

do_start

case "$?" in

0) log_end_msg 0 ;;

1) log_end_msg 1 ;; # Old process is still running

*) log_end_msg 1 ;; # Failed to start

esac

;;

*)

# Failed to stop

log_end_msg 1

;;

esac

;;

*)

echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|pause}" >&2

exit 3

;;

esac

:

开始安装显卡驱动

官方闭源驱动下载地址:http://support.amd.com/us/gpudownload/Pages/index.aspx

我的是:ThinkPad T400 2767R84

对应的显卡驱动是 Linux > [任选一个,因为貌似是一样的] > Radeon > ATI Radeon HD 3xxx Series

安装需要Root权限

$ sudo ./ati-driver-installer-9-11-x86.x86_64.run

(一旦不能执行,只需要修改它的执行权限后,再执行就可以了)

修复静音按钮

在我的ThinkPad上静音按钮可以静音可是却没有状态显示,要修复这个问题必须编辑grub配置相关文件,在其中添加一个配置项 acpi_osi=”Linux”

具体方法如下:

打开配置相关文件:

$ sudo gedit /etc/default/grub

找到 GRUB_CMDLINE_LINUX=”" 这行

在这行的后面加上一行 : GRUB_CMDLINE_LINUX=”acpi_osi=”Linux”"

保存,退出

在终端中输入

$ sudo update-grub

重启就可以了!

修复中键滚动

ThinkPad上的小红点+中键在Win下是可以滚动的,可到了接下来就失效了,但还是有办法修复的。

具体方法如下:

首先,创建一个fdi文件 

$ sudo gedit /etc/hal/fdi/policy/mouse-wheel.fdi

内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<match key="info.product" string="TPPS/2 IBM公司 TrackPoint">
<merge key="input.x11_options.EmulateWheel" type="string">true</merge>
<merge key="input.x11_options.EmulateWheelButton" type="string">2</merge>
<merge key="input.x11_options.XAxisMapping" type="string">6 7</merge>
<merge key="input.x11_options.YAxisMapping" type="string">4 5</merge>
<merge key="input.x11_options.ZAxsisMapping" type="string">4 5</merge>
<merge key="input.x11_options.Emulate3Buttons" type="string">true</merge>
</match>

保存后,重启系统或重启hal和gdm。

修复 Fn+F8

此方法貌似已经无效了,锁住后只要有一点键盘操作就会恢复。

与修复中键滚动一样需要创建一个fdi文件

$ sudo gedit /etc/hal/fdi/policy/shmconfig.fdi

内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<deviceinfo version="0.2">
<device>
<match key="input.x11_driver" string="synaptics">
<merge key="input.x11_options.SHMConfig" type="string">True</merge>
</match>
</device>
</deviceinfo>

保存后必须重启,单是重启hal没有任何帮助。

安装APS驱动

照ThinkWiki.org上的说明安装所需包

$ sudo apt-get install tp-smapi-source hdapsd hdaps-utils

晕~~~写这wiki的人真能找到这些包吗?反正我是不能,回到9.04版中的方法

下载以下三个文件:

tp_smapi-0.4 from here: http://sourceforge.net/project/showfiles.php?group_id=1212&package_id=171579
hdapsd-20090401.tar.gz from here: http://sourceforge.net/project/showfiles.php?group_id=138242&package_id=308030
gnome-hdaps-applet-20081204.tar.gz from here: http://www.zen24593.zen.co.uk/hdaps/

解压缩文件:

$ tar xvfz hdapsd-20090401.tar.gz
$ tar xvfz tp_smapi-0.40.tgz
$ tar xvfz gnome-hdaps-applet-20081204.tar.gz
<pre>
 
先装tp_snmapi
<pre lang="bash" line="1">
$ cd [你解压的位置]/tp_smapi-0.40
$ make load HDAPS=1 FORCE_IO=1
$ make install HDAPS=1 FORCE_IO=1

$ sudo gedit /etc/modules

在内容最后加入
thinkpad_ec
tp_smapi
hdaps

$ sudo gedit /etc/modprobe.d/local.conf

将以下内容写入此文件中
# enable thinkpad_ec
options thinkpad_ec force_io=1

# option to correctly set tilting through hdaps sensor
options hdaps invert=1

执行 $ lsmod | grep hdaps 看看有没有错误,无误的话应该是你在/etc/modules中写入的内容

确认无误继续,有误则检查上述步骤

$ sudo modprobe thinkpad_ec tp_smapi hdaps

再装hdapsd

$ cd Desktop/hdapsd-20090401/
$ ./configure --prefix=/usr/
$ make
$ sudo make install

一旦提示安装成功继续,若失败有可能是因为没有安装编译环境,请先安装gcc编译环境

$ sudo hdapsd -d sda -s 15 -a -v -y

输入后试着移动一下你的,一旦数值动了就说明装好了。ctrl+c退出,应该都知道的吧

$ wget http://www.unet.univie.ac.at/~a0604095/hdapsd
$ sudo chmod 733 hdapsd
$ sudo cp hdapsd /etc/init.d/

让hdapsd自动启动,现在你可以输入 $ sudo /etc/init.d/hdapsd start 启动它了

PS: gnome-hdaps-applet可以不用装,反正我装后我就后悔了。