命令拷屏之硬盤檢測


smartctl
hdparm
lshw
fdisk
badblock

 

 

 

軟raid
mount /dev/md0 /opt                
[root@localhost root]# cp /usr/share/doc/raidtools-1.00.3/raid*.conf.* /etc
[root@localhost root]# ls -l /etc/ |grep raid
[root@localhost root]# vi /etc/raid0.conf.sample  
mkraid /dev/md0
mkfs.ext3 /dev/md0
lsraid -A -a /dev/md0
[root@localhost root]# more /proc/mdstat
不使用的時候請直接刪除/etc/raidtab文件. # rm /etc/raidtab  

有時想知道服務器上有幾塊磁盤,如果沒有做raid,則可以簡單使用fdisk -l就可以看到。但是做了raid呢,這樣就看不出來了。那么如何查看服務器上做了raid?
windows:RAID卡廠商都有RAID安裝程序與驅動的。在配置完RAID后,進WINDOWS系統,下載相應的RAID安裝程序並安裝。比如 LSI 1064E 在官網上就可以下載到。 或者HD tune可以查看基本的raid信息
linux:分軟與硬
軟件raid:只能通過Linux系統本身來查看cat /proc/mdstat,可以看到raid級別,狀態等信息。
硬件raid:最佳的辦法是通過已安裝的raid廠商的管理工具來查看,有cmdline,也有圖形界面。如Adaptec公司的硬件卡就可以通過下面的命令進行查看:
# /usr/dpt/raidutil -L all可以看到非常詳細的信息。
當然更多情況是沒有安裝相應的管理工具,只能依靠Linux本身,一般有兩種方式:
# dmesg |grep -i raid
# cat /proc/scsi/scsi
顯示的信息差不多,raid的廠商,型號,級別,但無法查看各塊硬盤的信息。

[root@coreserv log]# cat /proc/scsi/scsi
Attached devices:
Host: scsi6 Channel: 02 Id: 00 Lun: 00
  Vendor: IBM      Model: ServeRAID M1015  Rev: 2.13
  Type:   Direct-Access                    ANSI  SCSI revision: 05
Host: scsi7 Channel: 00 Id: 00 Lun: 00
  Vendor: IBM SATA Model:  DEVICE 81Y3672  Rev: SA81
  Type:   CD-ROM                           ANSI  SCSI revision: 00

# fdisk -l
Disk /dev/sda: 145.9 GB, 145999527936 bytes
255 heads, 63 sectors/track, 17750 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14       17750   142472452+  8e  Linux LVM
# cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: SEAGATE  Model: ST3146356SS      Rev: HS09
  Type:   Direct-Access                    ANSI SCSI revision: 05
Host: scsi0 Channel: 00 Id: 01 Lun: 00
  Vendor: SEAGATE  Model: ST3146356SS      Rev: HS09
  Type:   Direct-Access                    ANSI SCSI revision: 05
Host: scsi0 Channel: 01 Id: 00 Lun: 00
  Vendor: Dell     Model: VIRTUAL DISK     Rev: 1028
  Type:   Direct-Access                    ANSI SCSI revision: 05
通過以上信息可以看出,該服務器有兩塊磁盤。品牌是希捷的,磁盤代號為 ST3146356SS,如果你熟悉細節磁盤的代號命名規則,你會輕易判定該磁盤大小為146G 。再根據fdisk 得出的結果可以判定,該服務器是拿兩塊146G的硬盤做的raid1.

不同的文件系統(xfs,reiserfs,ext3)都有自己的檢測和修復工具。檢測之前可以先使用dmesg命令查看有沒有硬件I/O故障的日志,如果有,先用fsck看看是不是文件系統有問題,如果不是則可以使用下面介紹硬盤檢測和優化方法來修復它。 grep "error" /va/log/messages*

--------------------------------------------------------------------------------------------------------------

使用SMART檢測硬盤
SMART是一種磁盤自我分析檢測技術,早在90年代末就基本得到了普及每一塊硬盤(包括IDE、SCSI),在運行的時候都會將自身的若干參數記錄下來,這些參數包括型號、容量、溫度、密度、扇區、尋道時間、傳輸、誤碼率等。硬盤運行了幾千小時后,很多內在的物理參數都會發生變化,某一參數超過報警閾值,則說明硬盤接近損壞,此時硬盤依然在工作,如果用戶不理睬這個報警繼續使用,那么硬盤將變得非常不可靠,隨時可能故障。
啟用SMART
SMART是和主板BIOS上相應功能配合的,要使用SMART,必須先進入到主板BIOS設置里邊啟動相關設置。一般從Pentium2級別起的主板,都支持SMART,BIOS啟動以后,就是操作系統級別的事情了(Windows沒有內置SMART相關工具,需要安裝第三方工具軟件),好在Linux上很早就有了SMART支持了,如果把Linux裝在VMware等虛擬機上,在系統啟動時候可以看到有個服務啟動報錯:smartd。這個服務器就是smart的daemon進程(因為vmware虛擬機的硬盤不支持SMART,所以報錯)。smartd是一個守護進程(一個幫助程序),它能監視擁有自我監視,分析和匯報技術(Self-Monitoring, Analysis, and Reporting Technology - SMART)的硬盤。SMART體系使得硬盤能監視並匯報自己的運行狀況.它的一個重要特性是能夠預測失敗,使得系統管理員能避免數據丟失。

[root@coreserv log]# rpm -qf /usr/sbin/smartctl
smartmontools-5.42-2.el6.x86_64
[root@coreserv log]# rpm -ql smartmontools
/etc/rc.d/init.d/smartd
/etc/smartd.conf
/etc/sysconfig/smartmontools
/usr/sbin/smartctl
/usr/sbin/smartd
/usr/sbin/update-smart-drivedb


[root@localhost ~]# smartctl --scan /dev/sda -d scsi # /dev/sda, SCSI device /dev/sdb -d scsi # /dev/sdb, SCSI device 這是一個固態盤 [root@localhost ~]# smartctl -i /dev/sda smartctl 5.43 2016-09-28 r4347 [x86_64-linux-2.6.32-431.el6.x86_64] (local build) Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net === START OF INFORMATION SECTION === Device Model: Kingstek 120GB Serial Number: AA000000000000001053 LU WWN Device Id: 0 000000 000000000 Firmware Version: 20150818 User Capacity: 120,034,123,776 bytes [120 GB] Sector Size: 512 bytes logical/physical Device is: Not in smartctl database [for details use: -P showall] ATA Version is: 8 ATA Standard is: ACS-2 (revision not indicated) Local Time is: Tue Jan 8 09:26:49 2019 CST SMART support is: Available - device has SMART capability. SMART support is: Enabled

 

----------------------------------------------------------------------------------------------------------------------------------

使用badblocks檢測硬盤壞塊
badblocks命令可以檢查磁盤裝置中損壞的區塊。執行該指令時須指定所要檢查的磁盤裝置,及此裝置的磁盤區塊數。

badblocks -s//顯示進度  -v//顯示執行詳細情況   /dev/sda1
# badblocks -s -v /dev/sda
正在檢查從 0 到 244198583的塊
Checking for bad blocks (read-only test): ^C0.10% done, 0:04 elapsed
Interrupted at block 272896
$badblocks -s//顯示進度 -w//以寫去檢測 -v//顯示執行詳細情況 /dev/sda2
# badblocks -w -s -v /dev/sda1
Checking for bad blocks in read-write mode
From block 0 to 25607577
Testing with pattern 0xaa: ^C0.73% done, 0:03 elapsed
注意,不能以寫的方式檢測已經掛載的硬盤


----------------------------------------------------------------------------------------------------------------------------
使用hdparm測試  

yum install hdparm

測試硬盤讀寫速度
# hdparm -Tt /dev/sda

 

可以查看轉速,型號

[root@kvm2 ~]# hdparm -I /dev/sda

/dev/sda:

ATA device, with non-removable media
        Model Number:       ST1000DM003-1ER162
        Serial Number:      Z4YBD720
        Firmware Revision:  CC45
        Transport:          Serial, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
[root@kvm2 ~]# hdparm -i /dev/sda

/dev/sda:

 Model=ST1000DM003-1ER162, FwRev=CC45, SerialNo=Z4YBD720


---------------------------------------------------------------------------------------------------------------------

下載安裝

下載地址:ftp://download2.boulder.ibm.com/ecc/sar/CMA/XSA/ibm_utl_sraidmr_megacli-8.00.48_linux_32-64.zip
或https://docs.broadcom.com/docs-and-downloads/raid-controllers/raid-controllers-common-files/8-07-06_MegaCLI.zip
在線下載:
wget ftp://download2.boulder.ibm.com/ecc/sar/CMA/XSA/ibm_utl_sraidmr_megacli-8.00.48_linux_32-64.zip

磁硬盤陣列后如何檢測和監控硬盤健康狀況?
https://blog.csdn.net/enweitech/article/details/82893085


https://blog.csdn.net/xinqidian_xiao/article/details/80940306  MegaCli使用手冊

wget https://docs.broadcom.com/docs-and-downloads/raid-controllers/raid-controllers-common-files/8-07-06_MegaCLI.zip unzip -d me 8-07-06_MegaCLI.zip
cd linux
rpm -ivh MegaCli-8.07.06-1.noarch.rpm
cd /opt/MegaRAID/MegaCli/
./MegaCli64 -adpcount
./MegaCli64 -AdpAllInfo -aALL

[root@kvm1 MegaCli]# ./MegaCli64 -adpcount
[root@kvm1 MegaCli]# ./MegaCli64 -AdpAllInfo -aALL
[root@kvm1 MegaCli]# ./MegaCli64 -LdPdInfo -aALL
[root@kvm1 MegaCli]# ./MegaCli64 -LDInfo -Lall -aALL
[root@kvm1 MegaCli]# ./MegaCli64 -AdpBbuCmd -aALL

命令行具體使用


[root@kvm1 MegaCli]# ./MegaCli64 -AdpAllInfo -aALL Adapter #0 ============================================================================== Versions ================ Product Name : ServeRAID M5210 Serial No : SV61224052 FW Package Build: 24.9.0-0029 Mfg. Data ================ Mfg. Date : 03/18/16 Rework Date : 00/00/00 Revision No : 04E Battery FRU : N/A Image Versions in Flash: ================ BIOS Version : 6.25.03.3_4.17.08.00_0x060E0301 FW Version : 4.290.00-4923 NVDATA Version : 3.1507.00-0011 Ctrl-R Version : 5.10-0710 Preboot CLI Version: 01.07-05:#%0000 Boot Block Version : 3.07.00.00-0002 Pending Images in Flash ================ None PCI Info ================ Controller Id : 0000 Vendor Id : 1000 Device Id : 005d SubVendorId : 1014 SubDeviceId : 0454 Host Interface : PCIE ChipRevision : C0 Link Speed : 0 Number of Frontend Port: 0 Device Interface : PCIE Number of Backend Port: 8 Port : Address 0 50000397081bdd32 1 50000397081b3932 2 5000c50096e01591 3 50000397a8430476 4 50000397a8430306 5 0000000000000000 6 0000000000000000 7 0000000000000000 HW Configuration ================ SAS Address : 500605b00ba2c280 BBU : Absent Alarm : Absent NVRAM : Present Serial Debugger : Present Memory : Present Flash : Present Memory Size : 1024MB TPM : Absent On board Expander: Absent Upgrade Key : Present Temperature sensor for ROC : Present Temperature sensor for controller : Absent ROC temperature : 58 degree Celsius Settings ================ Current Time : 8:40:57 1/7, 2019 Predictive Fail Poll Interval : 300sec Interrupt Throttle Active Count : 16 Interrupt Throttle Completion : 50us Rebuild Rate : 30% PR Rate : 30% BGI Rate : 30% Check Consistency Rate : 30% Reconstruction Rate : 30% Cache Flush Interval : 4s Max Drives to Spinup at One Time : 2 Delay Among Spinup Groups : 12s Physical Drive Coercion Mode : 1GB Cluster Mode : Disabled Alarm : Disabled Auto Rebuild : Enabled Battery Warning : Disabled Ecc Bucket Size : 15 Ecc Bucket Leak Rate : 1440 Minutes Restore HotSpare on Insertion : Disabled Expose Enclosure Devices : Enabled Maintain PD Fail History : Enabled Host Request Reordering : Enabled Auto Detect BackPlane Enabled : SGPIO/i2c SEP Load Balance Mode : Auto Use FDE Only : Yes Security Key Assigned : No Security Key Failed : No Security Key Not Backedup : No Default LD PowerSave Policy : Controller Defined Maximum number of direct attached drives to spin up in 1 min : 10 Auto Enhanced Import : Yes Any Offline VD Cache Preserved : No Allow Boot with Preserved Cache : No Disable Online Controller Reset : No PFK in NVRAM : No Use disk activity for locate : No POST delay : 90 seconds BIOS Error Handling : Stop On Errors Current Boot Mode :Normal Capabilities ================ RAID Level Supported : RAID0, RAID1, RAID5, RAID00, RAID10, RAID50, PRL 11, PRL 11 with spanning, SRL 3 supported, PRL11-RLQ0 DDF layout with no span, PRL11-RLQ0 DDF layout with span Supported Drives : SAS, SATA Allowed Mixing: Mix in Enclosure Allowed Status ================ ECC Bucket Count : 0 Limitations ================ Max Arms Per VD : 32 Max Spans Per VD : 8 Max Arrays : 128 Max Number of VDs : 64 Max Parallel Commands : 928 Max SGE Count : 60 Max Data Transfer Size : 8192 sectors Max Strips PerIO : 42 Max LD per array : 64 Min Strip Size : 64 KB Max Strip Size : 1.0 MB Max Configurable CacheCade Size: 0 GB Current Size of CacheCade : 0 GB Current Size of FW Cache : 831 MB Device Present ================ Virtual Drives : 3 Degraded : 0 Offline : 0 Physical Devices : 6 Disks : 5 Critical Disks : 0 Failed Disks : 0 Supported Adapter Operations ================ Rebuild Rate : Yes CC Rate : Yes BGI Rate : Yes Reconstruct Rate : Yes Patrol Read Rate : Yes Alarm Control : No Cluster Support : No BBU : Yes Spanning : Yes Dedicated Hot Spare : Yes Revertible Hot Spares : Yes Foreign Config Import : Yes Self Diagnostic : Yes Allow Mixed Redundancy on Array : No Global Hot Spares : Yes Deny SCSI Passthrough : No Deny SMP Passthrough : No Deny STP Passthrough : No Support Security : Yes Snapshot Enabled : No Support the OCE without adding drives : Yes Support PFK : Yes Support PI : Yes Support Boot Time PFK Change : Yes Disable Online PFK Change : Yes Support LDPI Type1 : No Support LDPI Type2 : No Support LDPI Type3 : No PFK TrailTime Remaining : 0 days 0 hours Support Shield State : Yes Block SSD Write Disk Cache Change: Yes Support Online FW Update : Yes Supported VD Operations ================ Read Policy : Yes Write Policy : Yes IO Policy : Yes Access Policy : Yes Disk Cache Policy : Yes Reconstruction : Yes Deny Locate : No Deny CC : No Allow Ctrl Encryption: No Enable LDBBM : No Support Breakmirror : Yes Power Savings : No Supported PD Operations ================ Force Online : Yes Force Offline : Yes Force Rebuild : Yes Deny Force Failed : No Deny Force Good/Bad : No Deny Missing Replace : No Deny Clear : No Deny Locate : No Support Temperature : Yes Disable Copyback : No Enable JBOD : No Enable Copyback on SMART : Yes Enable Copyback to SSD on SMART Error : Yes Enable SSD Patrol Read : No PR Correct Unconfigured Areas : Yes Error Counters ================ Memory Correctable Errors : 0 Memory Uncorrectable Errors : 0 Cluster Information ================ Cluster Permitted : No Cluster Active : No Default Settings ================ Phy Polarity : 0 Phy PolaritySplit : 0 Background Rate : 30 Strip Size : 256kB Flush Time : 4 seconds Write Policy : WB Read Policy : Adaptive Cache When BBU Bad : Disabled Cached IO : No SMART Mode : Mode 6 Alarm Disable : No Coercion Mode : 1GB ZCR Config : Unknown Dirty LED Shows Drive Activity : No BIOS Continue on Error : 0 Spin Down Mode : None Allowed Device Type : SAS/SATA Mix Allow Mix in Enclosure : Yes Allow HDD SAS/SATA Mix in VD : No Allow SSD SAS/SATA Mix in VD : No Allow HDD/SSD Mix in VD : No Allow SATA in Cluster : No Max Chained Enclosures : 16 Disable Ctrl-R : Yes Enable Web BIOS : No Direct PD Mapping : No BIOS Enumerate VDs : Yes Restore Hot Spare on Insertion : No Expose Enclosure Devices : Yes Maintain PD Fail History : Yes Disable Puncturing : Yes Zero Based Enclosure Enumeration : No PreBoot CLI Enabled : No LED Show Drive Activity : Yes Cluster Disable : Yes SAS Disable : No Auto Detect BackPlane Enable : SGPIO/i2c SEP Use FDE Only : Yes Enable Led Header : No Delay during POST : 0 EnableCrashDump : Yes Disable Online Controller Reset : No EnableLDBBM : No Un-Certified Hard Disk Drives : Allow Treat Single span R1E as R10 : No Max LD per array : 64 Power Saving option : All power saving options are disabled Default spin down time in minutes: 30 Enable JBOD : No TTY Log In Flash : No Auto Enhanced Import : Yes BreakMirror RAID Support : Yes Disable Join Mirror : No Enable Shield State : Yes Time taken to detect CME : 60s Exit Code: 0x00

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM