本文修复load/unload cycle count部分参考了同考网的文章《Ubuntu中Load/Unload Cycle Count问题及解决》。
本文监控load/unload cycle count部分是自个写的。
写本文的目的是记录自己如何解决该问题,为以后可能出现的重装ubuntu提供一个指引,备忘而已。
Ubuntu版本:10.04 lucid lynx
- 查看硬盘设备的路径。替换后面3个disk脚本中的设备路径。比如有两个硬盘的话,使用"/dev/sda /dev/sdb"替换"/dev/sda"。
sudo fdisk -l
- 新建文件/etc/pm/config.d/disk,并赋予可执行权限。文件内容如下:
# Configure disk power management settings to ensure both # long disk life and good power management. # # Space delimited list of disk devices this affects. # DEVICES_DISK_PM_NAMES="/dev/sda" # # # Power management modes # # Powersave mode off # Set APM as 255 ## Set spin-down for 30 minutes # DEVICES_DISK_PM_POWERSAVE_OFF="hdparm -q -B 255" # # Powersave mode on ## Enable APM to conservative 192 and set spin-down for 21 minutes # DEVICES_DISK_PM_POWERSAVE_ON="hdparm -q -B 254"
- 新建文件/etc/pm/power.d/disk,并赋予可执行权限。文件内容如下:
#!/bin/bash #在power.d中加入Hook脚本,作用是在使用电池和AC电源的时候可以自动切换省电模式 ./usr/lib/pm-utils/functions ./etc/pm/config.d/disk if test -z "${DEVICES_DISK_PM_NAMES}"; then exit 1 fi case "$1" in true) echo "**enabled pm for harddisk" for DISK_NAME in `echo ${DEVICES_DISK_PM_NAMES}`; do ${DEVICES_DISK_PM_POWERSAVE_ON} ${DISK_NAME} done ;; false) echo "**disabled pm for harddisk" for DISK_NAME in `echo ${DEVICES_DISK_PM_NAMES}`; do ${DEVICES_DISK_PM_POWERSAVE_OFF} ${DISK_NAME} done ;; esac
- 新建文件/etc/pm/sleep.d/disk,并赋予可执行权限。文件内容如下:
#!/bin/bash #在sleep.d中加入脚本,目的是在休眠/待机之后唤醒的时候重新设定hdparm的参数 ./usr/lib/pm-utils/functions ./etc/pm/config.d/disk if test -z ${DEVICES_DISK_PM_NAMES}; then exit 1 fi case "$1" in thaw|resume) /usr/bin/on_ac_power; if [ "$?" -eq 0 ]; then echo "**disabled PM for harddisk" for DISK_NAME in `echo ${DEVICES_DISK_PM_NAMES}`; do ${DEVICES_DISK_PM_POWERSAVE_OFF} ${DISK_NAME} done elif [ "$?" -eq 1 ]; then echo "**enabled PM for harddisk" for DISK_NAME in `echo ${DEVICES_DISK_PM_NAMES}`; do ${DEVICES_DISK_PM_POWERSAVE_ON} ${DISK_NAME} done fi ;; esac
- 确保laptop-mode是禁用的(默认就是禁用的)。查看文件/etc/default/acpi-support,看文件中是否有这一行:
ENABLE_LAPTOP_MODE=true
如果有这一行,表明laptop-mode是启用的,那么一定要设置为false!
- 安装smartmontools。
sudo apt-get install smartmontools
- 在家目录下新建文件AskPassProg.sh,并赋予可执行权限。文件内容如下:
#!/bin/bash # this file serves as sudo ask program, you must not delete this file. # if user 'bruce' 's password is changed, modify this file please. # 请修改字符串为你用户的登录密码! echo "11111111"
- 在家目录下新建文件monlcc.sh,并赋予可执行权限。文件内容如下:
#!/bin/sh export SUDO_ASKPASS=~/AskPassProg.sh while true; do cur_date=`date`; lcc=`sudo -A smartctl -a /dev/sda | grep 193`; echo $cur_date : $lcc; echo $cur_date : $lcc >> monlcc.log; sleep 300; done; export SUDO_ASKPASS=""
gnome-terminal --geometry +0+30 -e ~/monlcc.sh
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于