Welcome
 

WordPress-2.7 upgrade

Tuesday, December 16th, 2008 Write a comment

everything goes fine :)

 

[Linux] 使用 smartmontools 修正壞軌

Friday, November 7th, 2008 Write a Comment

第一階段 檢查硬碟
1) 首先對要測試的硬碟做完整測試
ls:~# smartctl -t long /dev/hda
Home page is http://smartmontools.sourceforge.net/
=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Execute SMART Extended self-test routine immediately in off-line mode".
Drive command "Execute SMART Extended self-test routine immediately in off-line mode" successful.
Testing has begun.
Please wait 96 minutes for test to complete.
Test will complete after Thu Nov 6 18:26:57 2008
Use smartctl -X to abort test.

2) 完成之後,用 -l 參數查看硬碟檢查狀況
ls:~# smartctl -l selftest /dev/hda
smartctl version 5.36 [mipsel-unknown-linux-gnu] Copyright (C) 2002-6 Bruce Allen
Home page is http://smartmontools.sourceforge.net/
=== START OF READ SMART DATA SECTION ===
SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Extended offline Completed: read failure 90% 7877 2086648
# 2 Extended offline Completed: read failure 90% 7455 2086648

從檢查結果中可以看到,硬碟有讀取錯誤的問題。 (Completed: read failure)

3) 利用 -A 參數檢查硬碟的 smart 屬性看有沒有錯誤
ls:~# smartctl -A /dev/ad0
=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
...
197 Current_Pending_Sector 0x0022 100 100 000 Old_age Always - 1
198 Offline_Uncorrectable 0x0008 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x000a 200 200 000 Old_age Always - 0

屬性 197,Current_Pending_Sector 的值為 1,表示硬碟的確有問題。

第二階段 修正壞軌
1) 首先先用 fdisk 檢查問題硬碟的 block
ls:~# fdisk -lu /dev/hda
Disk /dev/hda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Device Boot Start End Blocks Id System
/dev/hda1 63 787184 393561 83 Linux
/dev/hda2 787185 1799279 506047+ 82 Linux swap / Solaris
/dev/hda3 1799280 625137344 311669032+ 83 Linux

根據我們剛剛用 selftest 找出來的數據,得知在 LBA 2086648 處有問題
2086648 – 1799280 = 287368, 在 /dev/hda3 的 LBA 287368

2) 利用 tune2fs 找出該 partition 的 block size
ls:~# tune2fs -l /dev/hda1 |grep -i block
Block count: 77917258
Block size: 4096

3) 接著,算出 LBA 所在的位置。
公式的規則為:b = (int)((L-S)*512/B)
b = 檔案系統的 block number
B = 檔案系統的 block size (in byte)
L = 壞軌的 LBA
S = fdisk -lu 顯示的 Partition Starting Sector
int => 取整數部份

所以我們會算出:
b = (int)(287368*512/4096) = (int)(35921.0) = 35921

3) 用 debugfs 找出有問題的檔案
ls:~# debugfs
debugfs 1.40-WIP (14-Nov-2006)
debugfs: open /dev/hda1
debugfs: icheck 35921
Block Inode number
35921 28966966
debugfs: ncheck 28966966
Inode Pathname
28966966 /var/log/cpu-usage-exec.log

找出檔案為 cpu-usage-exec.log

4) 再用 dd 去將該 block 填零
ls:~# dd if=/dev/zero of=/dev/hda1 bs=4096 count=1 seek=35921
4096 bytes (4.1 kB) copied,0.000452 秒,9.1 MB/s
ls:~# sync

第三階段 重新檢查
1) 利用 smartctl -A 檢查原本有問題的 smart attribute
ls:~# smartctl -A /dev/hda
197 Current_Pending_Sector 0x0022 100 100 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0008 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x000a 200 200 000 Old_age Always - 0

smart attribute 197 變為 0,回復正常

2) 再做一次完整掃瞄檢查
ls:~# smartctl -t long /dev/hda
....Wait for test complete....
ls:~# smartctl -l /dev/hda
=== START OF READ SMART DATA SECTION ===
SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Extended offline Completed without error 00% 7896 -
# 2 Extended offline Completed: read failure 90% 7877 2086648
# 3 Extended offline Completed: read failure 90% 7455 2086648

#1, complete without error, problem solved.

後記
1) debugfs 很慢
2) 這篇單純只是翻譯以及實做而已…原始資料在 SmartMonToolBadBlockHowTo 裡有
3) 對實際壞軌我想應該還是沒用…吧

[AIX] vim 的 color syntax 設定

Tuesday, September 30th, 2008 Write a Comment

在 .vimrc 中加入下面字串:
if has("terminfo")
set t_Co=16
set t_AB=Esc[%?%p1%{8}%< %t%p1%{40}%+%e%p1%{92}%+%;%dm
set t_AF=Esc[%?%p1%{8}%< %t%p1%{30}%+%e%p1%{82}%+%;%dm
else
set t_Co=16
set t_Sf=Esc[3%dm
set t_Sb=Esc[4%dm
endif
" Where Esc is actual Ctrl-v + Esc

這設定我找了好久才找到 orz

看來我對 google 的 keyword search 還得多下點功夫

Ref:

The easiest way to get vim color in AIX

Speaking UNIX: The new and improved Vim editor

[Unix] color-wrapper 彩色你的黑白

Thursday, September 11th, 2008 3 Comments

逛網路時意外找到這個小工具

運用色彩點綴 UNIX 環境

color wapper

安裝也很簡單,configure 後再下個 make installlocal

將 path export 進去就 ok 了

真是個不錯的小工具 :)

[Wordpress] 再昇一次

Tuesday, September 9th, 2008 Write a Comment

才剛升級完就出 SQL Truncation 的問題,

官方建議是更新或者是關閉註冊功能以避免此問題
WordPress 2.6.2 SQL Truncation
這大概是我更新最快的一次了…

[Wordpress] 升級

Friday, September 5th, 2008 Write a Comment

to WP 2.6.1

everything goes fine… :-)

[Linux] 在 Debian 下面建置 C/C++ 環境

Tuesday, June 3rd, 2008 1 Comment

基本上,這篇只是個筆記而已。

apt-get install make
apt-get install gcc
apt-get install g++
apt-get install manpages-dev

[humor] apt-get install

Saturday, May 24th, 2008 2 Comments

apt-get install wife

it’s really troublesome XD

links from:
Humor: apt-get wife

[Lighttpd] 開啟壓縮功能

Thursday, May 22nd, 2008 Write a Comment

啟動壓縮功能後,對於單純文字網頁的大小,理論上可以減少 60%~70% 的大小
如此一來對於頻寬小如我家的網路不無小補…

環境:FreeBSD 7.0 Release + Lighttpd 1.4.19

1) 修改 /usr/local/etc/lighttpd.conf,uncomment “mod_compress”
2) 設定 compress.cache-dir=”the-path-you-want-to-put-cache”
3) 指定 compress.filetype= (”text/plain”,”text/css”, “text/xml”, “text/javascript” )
4) 修改 /usr/local/etc/php.ini,將zlib.out_compression 及 zlib.outpout_handler 皆設為 ON
5) 存檔,restart lighttpd

參考資料:
mod_compress: Lighttpd Gzip Compression To Improve Download and Browsing Speed

[Windows] 徹底關閉Windows隨插即用功能

Wednesday, May 21st, 2008 Write a Comment

Windows 的隨插即用功能,很容易淪為病毒逞兇的捷徑
一般都是從 Windows 裡面關閉自動播放,但其實沒什麼用
建議從修改 Register Key 裡面下手:

1) regedit, HKEY_CURRENT_USER\Software\microsoft\Windows\CurrentVersion\Explorer\MountPoints2
2) 點選此機碼,右鍵選「使用權限」
3) 新增「Everyone」使用者
4) 將 Everyone 的權限「完全控制」設定為「拒絕」即可

這是比較直接的方法,還有利用 GroupPolicy 及 CommandLine 修改的方式
細節可以參考這個地方:
Link:小心病毒就在USB中

Next Page »