linux硬碟偵查工具

來源:互聯網
上載者:User

From : http://hi.baidu.com/dog_freedom/blog/item/94744f1337026c59f819b843.html

Smartmontools for SCSI硬碟: http://smartmontools.sourceforge.net/smartmontools_scsi.html

smartctl命令參數列表:

The following options are currently available for SCSI disks and tape drives unless otherwise noted:

  • -a | --all : equivalent to the combination -i -H -A -l error -l selftest options invoked in that order.

  • -A | --attributes : outputs the current device temperature, trip temperature, the number of elements in the grown defect list (GLIST) and data from the start-stop log page. Outputs some vendor specific information if available.

  • -C | --captive : used in conjunction with -t short or -t long options to do short or long self tests in the foreground. [Has no effect on tape drives.]

  • -d TYPE | --device=TYPE where TYPE is "ata", "scsi", "sat", "marvell", "3ware,N", "hpt,L/N[,M]" or "cciss,N". Overrides utility's guess about the class of the device which is based on the form of the nominated device's name.

  • -h | --help : outputs lengthy usage message and exits without any other action.

  • -H | --health : outputs single device health metric determined by the device manufacturer. This will be "OK" or a failure message.

  • -i | --info : outputs device identification information (derived from a SCSI INQUIRY command) and whether the device supports SMART (and temperature warnings) and if those facilities are currently enabled. The type of transport (e.g. FC or SAS) is also reported, if available. Some users have reported disks that report the wrong transport.

  • -l TYPE | --log=TYPE where TYPE is either "background", "selftest" or "error". Decodes are outputs the requested log. Note that --all does not include --log=background .

  • -q TYPE | --quietmode=TYPE where TYPE is either "silent" or "errorsonly". When the type is silent then nothing is output to the console but the exit status is set (so it is suitable for scripts). For "errorsonly" only errors are output to the console. The exit status is always set. [See the smartctl man page.]

  • -r TYPE | --report=TYPE where TYPE is either "ioctl[,<n>]" or "scsiioctl[,<n>]". Turns on low level debugging of issued commands and responses. These commands are issued through a system command called an "ioctl" in Unix. The debug can be for all issued commands (i.e. "ioctl") or only SCSI commands ("scsiioctl"). Optionally the TYPE can have a comma and a number post pended to increase the volume of debug. See this section for more details.

  • -s VALUE | --smart=VALUE where VALUE is either "on" or "off". Enables or disables SMART monitoring (and temperature warnings).

  • -S VALUE | --saveauto=VALUE where VALUE is either "on" or "off". Controls whether the error log values are preserved across device power cycles.

  • -t TEST | --test=TEST where TEST is either "offline", "short" or "long". Despite its name "offline" is a short foreground test that all SCSI devices should support. A "short" self test is typically 2 minutes or less. A "long" self test will be considerably longer than 2 minutes, depending on the size of the media. The estimated time that a "long" self test will take is printed after the "selftest" log (i.e. with '-l selftest' or '-a')

  • -V | --version : outputs the smartctl version number (including the cvs version of all its source files) and build information then exits without any other action.

  • -X | --abort : will terminate a background short or long self test. Usually the self test log notes that a self test has been aborted. [Has no effect on tape drives.]

簡單用法:
1、smartctl -a <device>          檢查該裝置是否已經開啟SMART技術。
2、smartctl -s on <device>    如果沒有開啟SMART技術,使用該命令開啟SMART技術。
3、smartctl -t short <device>     後台檢測硬碟,消耗時間短;
      smartctl -t long <device>      後台檢測硬碟,消耗時間長;
      smartctl -C -t short <device> 前台檢測硬碟,消耗時間短;
      smartctl -C -t long <device> 前台檢測硬碟,消耗時間長。
其實就是利用硬碟SMART的自檢程式。
4、smartctl -X <device> 中斷後台檢測硬碟。
5、smartctl -l selftest <device> 顯示硬碟檢測日誌。
6、smartctl -l error <device> 顯示硬碟錯誤匯總。

 

 

讓S.M.A.R.T為電腦硬碟站崗放哨

看了“Monitoring Hard Drive Health on Linux with smartmontools”一文(中文意思“在 linux用smartmontools監視硬碟驅動健康”),總算知道了一點有關S.M.A.R.T的皮毛。原文出處:http://blog.shadypixel.com/monit ... with-smartmontools/,英文,有理解欠妥或不正確的地方,請朋友們指正。

看來debian安裝時,smartmontools 已經存在了,怎樣啟動,前面已提到,就不重複了。謝謝各位朋友鼓勵。問題是啟動以後怎麼辦,最後要達到什麼結果,就是以下需要探討的。我已經根據文章提示做過一遍,所以是安全的。

文章用的是sudo命令,所以,建議先檢查一下sudo裝了沒有,如果沒裝,就進入以下這一步。

Root使用者下輸入命令:
apt-get install sudo

設定sudoers:
chmod +w /etc/sudoers
vim /etc/sudoers
添加一行 username ALL=(ALL) ALL
其中username是使用者名稱,儲存退出。
(編輯時點鍵盤上插入鍵,即可輸入文字。編輯後點Esc鍵,再輸入:wq即可儲存退出。)
更改sudoers檔案許可權 chmod 0440 /etc/sudoers

輸入命令:
$ sudo smartctl -i /dev/sda

出現以下結果:

=== START OF INFORMATION SECTION ===
Model Family: SAMSUNG SpinPoint T133 series
Device Model: SAMSUNG HD300LJ
Serial Number: S0D7J1UL303628
Firmware Version: ZT100-12
User Capacity: 300,067,970,560 bytes
Device is: In smartctl database [for details use: -P show]
ATA Version is: 7
ATA Standard is: ATA/ATAPI-7 T13 1532D revision 4a
Local Time is: Fri Jan 2 03:08:20 2009 EST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
說明SMART已經處於支援狀態。

輸入命令:
$ sudo smartctl -s on -o on -S on /dev/sda

出現以下結果:

=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Enabled.
SMART Attribute Autosave Enabled.
SMART Automatic Offline Testing Enabled every four hours.
說明SMART將每四小時自動化的測試一下。

輸入命令:
$ sudo smartctl -H /dev/sda

出現以下結果:

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
說明到目前為此,電腦硬碟驅動處於健康狀態。通過檢測。

如果沒有PASSED(通過),這時所要做的就是儘快備份硬碟裡的資料,因為沒有多久,硬碟就要壞了。這就是該軟體最後要達到的警示目的。後面還有些內容,進一步瞭解也可以,就不贅言了。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.