前述
很多情况下,我们需要从OS下查询硬盘的SN,来定位硬盘的物理槽位。如:系统下硬盘报错,对于系统下的硬盘的报错是以硬盘的盘符体现的,而这种情况下我们需要知道该盘符对应硬盘的SN和具体的物理槽位以实现故障硬盘的更换。因此,今天将对这个过程做个介绍,我们将介绍常用OS,比如Linux、ESXi下定位硬盘的一些方法。
Linux
几个工具
Sg_inq
This utility by default sends a SCSI INQUIRY command to the given device and then outputs the response. All SCSI devices are meant to respond to a "standard" INQUIRY command with at least a 36 byte response (in SCSI 2 and higher). An INQUIRY is termed as "standard" when both the EVPD and CmdDt (now obsolete) bits are clear.
Stocli
Stocli是broadcom Raid/HBA卡的一个CLI工具,支持Windows/ESXi/Linux多种操作系统,可以实现硬盘信息的一些查询。
smartctl
smartctl controls the Self-Monitoring, Analysis and Reporting Technology (SMART) system built into most ATA/SATA and SCSI/SAS hard drives and solid-state drives. The purpose of SMART is to monitor the reliability of the hard drive and predict drive failures, and to carry out different types of drive self-tests. smartctl also supports some features not related to SMART. This version of smartctl is compatible with ACS-3, ACS-2, ATA8-ACS, ATA/ATAPI-7 and earlier standards (see REFERENCES below).
几种方法
注:SN作为媒介,来参照不同的信息。
通过Smartctl或Sg_inq和Stocli工具以SN为媒介获取盘符跟硬盘槽位之间的关系
[root@localhost~]# sg_inq /dev/sda
standard INQUIRY:
PQual=0 Device_type=0 RMB=0 version=0x06 [SPC-4]
[AERC=0] [TrmTsk=0] NormACA=0 HiSUP=1 Resp_data_format=2
SCCS=0 ACC=0 TPGS=0 3PC=0 Protect=1 [BQue=0]
EncServ=0 MultiP=1 (VS=0) [MChngr=0] [ACKREQQ=0] Addr16=0
[RelAdr=0] WBus16=0 Sync=0 Linked=0 [TranDis=0] CmdQue=1
[SPI: Clocking=0x0 QAS=0 IUS=0]
length=164 (0xa4) Peripheral device type: disk
Vendor identification: LENOVO
Product identification: AL15SEB060N
Product revision level: TB55
Unit serial number: 58U0A1AWFHSF
[root@localhost ~]# smartctl -i /dev/sda
smartctl 6.5 2016-05-07 r4318 [x86_64-linux-3.10.0-862.el7.x86_64] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Vendor: LENOVO
Product: AL15SEB060N
Revision: TB55
Compliance: SPC-4
User Capacity: 600,127,266,816 bytes [600 GB]
Logical block size: 512 bytes
Rotation Rate: 10500 rpm
Form Factor: 2.5 inches
Logical Unit id: 0x50000398a8a01dd5
Serial number: 58U0A1AWFHSF
Device type: disk
Transport protocol: SAS (SPL-3)
Local Time is: Fri Jul 15 19:49:27 2022 CST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
Temperature Warning: Enabled
[root@localhost~]# ./onecli/ts_tools/storcli_x64 /c0/eall/sall show all|egrep "^Drive|^SN"
Drive /c0/e0/s4 :
Drive /c0/e0/s4 - Detailed Information :
Drive /c0/e0/s4 State :
Drive /c0/e0/s4 Device attributes :
SN = 58U0A1K5FHSF
Drive /c0/e0/s4 Policies/Settings :
Drive /c0/e0/s6 :
Drive /c0/e0/s6 - Detailed Information :
Drive /c0/e0/s6 State :
Drive /c0/e0/s6 Device attributes :
SN = 58U0A1BKFHSF
Drive /c0/e0/s6 Policies/Settings :
Drive /c0/e0/s2 :
Drive /c0/e0/s2 - Detailed Information :
Drive /c0/e0/s2 State :
Drive /c0/e0/s2 Device attributes :
SN = 58U0A1AWFHSF
Drive /c0/e0/s2 Policies/Settings :
Drive /c0/e0/s3 :
Drive /c0/e0/s3 - Detailed Information :
Drive /c0/e0/s3 State :
Drive /c0/e0/s3 Device attributes :
SN = 58U0A19PFHSF
Drive /c0/e0/s3 Policies/Settings :
Drive /c0/e0/s5 :
Drive /c0/e0/s5 - Detailed Information :
Drive /c0/e0/s5 State :
Drive /c0/e0/s5 Device attributes :
SN = 58U0A1ACFHSF
Drive /c0/e0/s5 Policies/Settings :
Drive /c0/e0/s7 :
Drive /c0/e0/s7 - Detailed Information :
Drive /c0/e0/s7 State :
Drive /c0/e0/s7 Device attributes :
SN = 58U0A1KAFHSF
Drive /c0/e0/s7 Policies/Settings :
注:通过SN的一致性信息可以查看出来sda盘符对应slot2硬盘。
通过Stocli和Lsscsi工具以wwn为媒介获取盘符跟硬盘槽位之间的关系
[root@localhost ~]# ./ts_tools/storcli_x64 /c0 show all|grep -i -E "Device attributes|WWN"
Drive /c0/e0/s4 Device attributes :
WWN = 50000398a8a0e241 sdc
Drive /c0/e0/s2 Device attributes :
WWN = 50000398a8a01dd5 sda
Drive /c0/e0/s7 Device attributes :
WWN = 50000398a8a0e275 sdf
Drive /c0/e0/s3 Device attributes :
WWN = 50000398a8a010a9 sdb
Drive /c0/e0/s5 Device attributes :
WWN = 50000398a8a01b41 sdd
Drive /c0/e0/s6 Device attributes :
WWN = 50000398a8a0205d sde
[root@localhost ~]# lsscsi -w
[0:0:0:0] disk 0x50000398a8a01dd5 /dev/sda
[0:0:1:0] disk 0x50000398a8a010a9 /dev/sdb
[0:0:2:0] disk 0x50000398a8a0e241 /dev/sdc
[0:0:3:0] disk 0x50000398a8a01b41 /dev/sdd
[0:0:4:0] disk 0x50000398a8a0205d /dev/sde
[0:0:5:0] disk 0x50000398a8a0e275 /dev/sdf
[0:0:6:0] enclosu
通过Smartctl和Stocli工具以WWN为媒介获取盘符跟硬盘槽位之间的关系
[root@localhost ~]# smartctl -a /dev/sda|grep -i "Logical Unit id"
Logical Unit id: 0x50000398a8a01dd5
[root@sr570-1102-9102 ~]# ./onecli/ts_tools/storcli_x64 /c0/eall/sall show all|grep -i 50000398a8a01dd5 -A 5 -B 10
Predictive Failure Count = 0
S.M.A.R.T alert flagged by drive = No
Drive /c0/e0/s2 Device attributes :
=================================
Manufacturer Id = LENOVO
Model Number = AL15SEB060N
NAND Vendor = NA
SN = 58U0A1AWFHSF
WWN = 50000398a8a01dd5
Firmware Revision = TB55
Raw size = 558.911 GB [0x45dd2faf Sectors]
Coerced size = 558.911 GB [0x45dd2faf Sectors]
Non Coerced size = 558.911 GB [0x45dd2faf Sectors]
Device Speed = Unknown
注:smartctl命令输出了盘符跟wwn的匹配关系,stocli命令输出了wwn跟slot的对应关系,结合两者输出就可以建立起盘符跟slot的对应关系了。
通过Smartctl和BMC工具以SN为媒介获取盘符跟槽位的对应关系
注:前提是首先系统下通过smartctl知道硬盘的SN。
[root@localhost ~]# smartctl -i /dev/sda
smartctl 6.5 2016-05-07 r4318 [x86_64-linux-3.10.0-862.el7.x86_64] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Vendor: LENOVO
Product: AL15SEB060N
Revision: TB55
Compliance: SPC-4
User Capacity: 600,127,266,816 bytes [600 GB]
Logical block size: 512 bytes
Rotation Rate: 10500 rpm
Form Factor: 2.5 inches
Logical Unit id: 0x50000398a8a01dd5
Serial number: 58U0A1AWFHSF
Device type: disk
Transport protocol: SAS (SPL-3)
Local Time is: Fri Jul 15 20:24:58 2022 CST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
Temperature Warning: Enabled
system> storage -show disk[1-2] info
Product Name: AL15SEB060N
State: JBOD
Slot No.: 2
Disk Type: SAS
Media Type: HDD
Health Status: Normal
Capacity: 558.912GB
Speed: 12.0Gb/s
Current Temperature: 23C
Rotation Rate: 10500RPM
Media Error Count: 0
Other Error Count: 0
Predication Fail Count: 0
Remaining Life: N/A
FDE Capable: No
Secured: No
Manufacture: Toshiba
Device ID: 3
Enclosure ID: 0x0000
Machine Type:
Model:
Serial No.: 58U0A1AW
FRU No.: 00YK014
Part No.: D7A01863
注:Smartctl命令输出盘符跟SN的对应关系,BMC工具输出SN跟slot的对应关系,结合两者就可以建立盘符跟slot的对应关系。
ESXi系统
通过esxcli命令直接定位槽位
[root@localhost:~] esxcli storage core device list |grep naa
naa.600062b2039dab8029f0e420d7f2d964
Display Name: Local Lenovo Disk (naa.600062b2039dab8029f0e420d7f2d964)
Devfs Path: /vmfs/devices/disks/naa.600062b2039dab8029f0e420d7f2d964
naa.600062b2039dab80299f2fce682df661
Display Name: Local Lenovo Disk (naa.600062b2039dab80299f2fce682df661)
Devfs Path: /vmfs/devices/disks/naa.600062b2039dab80299f2fce682df661
naa.5000c500c14b27bb
Display Name: Local LENOVO Disk (naa.5000c500c14b27bb)
Devfs Path: /vmfs/devices/disks/naa.5000c500c14b27bb
naa.55cd2e41514592ce
Display Name: Local ATA Disk (naa.55cd2e41514592ce)
Devfs Path: /vmfs/devices/disks/naa.55cd2e41514592ce
[root@localhost:~] esxcli storage core device physical get -d naa.5000c500c14b27bb
Physical Location: enclosure 1, slot 6
[root@localhost:~] esxcli storage core device physical get -d naa.55cd2e41514592ce
Physical Location: enclosure 1, slot 4
注:通过esxcli 的命令可以直接定位硬盘的slot槽位,这块需要说明的是硬盘得是JBOD模式。
通过esxcli命令点亮 硬盘指示灯定位硬盘槽位
点亮硬盘定位灯
[root@localhost:~] esxcli storage core device set -l locator -d naa.5000c500c14b27bb
关闭硬盘定位灯
[root@localhost:~] esxcli storage core device set -l off -d naa.5000c500c14b27bb
通过stocli和esxcli命令以sas address为媒介配合定位硬盘槽位
[root@localhost:~] esxcli storage core path list |egrep -i "Device: naa.|Target Identifier"
Device: naa.5000cca0ab0333d4
Target Identifier: sas.5000cca0ab0333d5
Device: naa.5000cca0ab03207c
Target Identifier: sas.5000cca0ab03207d
Device: naa.55cd2e41514592ce
Target Identifier: sas.300062b2039dab88
Target Identifier: sata.0:2
Device: naa.5000c500c14b27bb
Target Identifier: sas.5000c500c14b27b9
Target Identifier: sas.300162b2039dab80
Device: naa.600062b2039dab80299f2fce682df661
Target Identifier: sas.609f2fce682df661
[root@localhost:~] /opt/lsi/storcli/storcli /c0/eall/sall show all |egrep -i "Device attributes|WWN|Active|sas address"
Drive /c0/e134/s0 Device attributes :
WWN = 55cd2e4150c85da3
Port Status Linkspeed SAS address
0 Active 6.0Gb/s 0x300062b2039dab81
Drive /c0/e134/s1 Device attributes :
WWN = 55cd2e4150c85dad
Port Status Linkspeed SAS address
0 Active 6.0Gb/s 0x300062b2039dab83
Drive /c0/e134/s2 Device attributes :
WWN = 5000CCA0AB03207F
Port Status Linkspeed SAS address
0 Active 12.0Gb/s 0x5000cca0ab03207d
1 Active 12.0Gb/s 0x0
Drive /c0/e134/s3 Device attributes :
WWN = 5000CCA0AB0333D7
Port Status Linkspeed SAS address
0 Active 12.0Gb/s 0x5000cca0ab0333d5
1 Active 12.0Gb/s 0x0
Drive /c0/e134/s4 Device attributes :
WWN = 55cd2e41514592ce
Port Status Linkspeed SAS address
0 Active 6.0Gb/s 0x0
1 Active 6.0Gb/s 0x300062b2039dab88
Drive /c0/e134/s6 Device attributes :
WWN = 5000C500C14B27B8
Port Status Linkspeed SAS address
0 Active 12.0Gb/s 0x5000c500c14b27b9
1 Active 12.0Gb/s 0x0
注:ESXi下esxcli storage core path list 输出中的Target Identifier跟stocli 输出的sas address为匹配的,这样就可以建立esxi naa number>>esxi Target Identifier>> stocli sas address>>disk physical slot的对应关系,然后就可以建立naa number>>physical slot number的对应关系了。
[root@localhost:~] sh disk_placement.sh
disk_placement.sh: line 1: script: not found
=============Physical disks placement==============
naa.600062b2039dab80299f2fce682df661
naa.600062b2039dab80299f2fce682df661 is not a physical device
====================================================
naa.5000c500c14b27bb
Physical Location: enclosure 1, slot 6
====================================================
naa.5000cca0ab0333d4
Physical Location: enclosure 1, slot 3
====================================================
naa.55cd2e41514592ce
Physical Location: enclosure 1, slot 4
====================================================
naa.5000cca0ab03207c
Physical Location: enclosure 1, slot 2
====================================================
ESXi查询物理磁盘槽位的脚本
脚本案例
# Script to obtain the placement of the physical disk by naa on ESXi hosts
# Author: Jorluis Perales, VxRail TSE 2 @ Dell EMC
# Version 1.0
#
# Do not change anything below this line
# --------------------------------------
echo "=============Physical disks placement=============="
echo ""
esxcli storage core device list | grep "naa" | awk '{print $1}' | grep "naa" | while read in; do
echo "$in"
esxcli storage core device physical get -d "$in"
sleep 1
echo "===================================================="
done
运行结果
[root@localhost:~] sh disk_placement.sh
disk_placement.sh: line 1: script: not found
=============Physical disks placement==============
naa.600062b2039dab8029f0e420d7f2d964
naa.600062b2039dab8029f0e420d7f2d964 is not a physical device
====================================================
naa.600062b2039dab80299f2fce682df661
naa.600062b2039dab80299f2fce682df661 is not a physical device
====================================================
naa.5000c500c14b27bb
Physical Location: enclosure 1, slot 6
====================================================
naa.55cd2e41514592ce
Physical Location: enclosure 1, slot 4
====================================================
备注:此脚本为引用网上他人案例,如侵犯到您的权益请您及时联系,谢谢。