目录

Linux操作系统-根据分区查看磁盘插槽

根据磁盘的分区查看磁盘在物理服务器上对应的插槽号.

开始

日常运维少不了对服务器的磁盘进行维护,下面我们来看看如何根据磁盘分区来快速定位到磁盘在物理服务器上的插槽编号。

查看磁盘分区

使用系统自带的命令 lsscsi 查看 DiskGroup 和对应的分区。

1
2
3
4
5
lsscsi
[0:2:0:0]    disk    DELL     PERC H710        3.13  /dev/sda 
[0:2:1:0]    disk    DELL     PERC H710        3.13  /dev/sdb 
[0:2:2:0]    disk    DELL     PERC H710        3.13  /dev/sdc 
[0:2:3:0]    disk    DELL     PERC H710        3.13  /dev/sdd

[0:2:1:0] 表示 /dev/sdb 分区在磁盘组 DiskGroup Target Id 为 1 里面的组里面。

我们再通过 MegaCli 工具来查看对应的 DiskGroup 里面的物理盘相关信息:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/opt/MegaRAID/MegaCli/MegaCli64 -cfgdsply -aALL 

DISK GROUP: 1
Number of Spans: 1
SPAN: 0
Span Reference: 0x01
Number of PDs: 1
Number of VDs: 1
Number of dedicated Hotspares: 0
Virtual Drive Information:
Virtual Drive: 1 (Target Id: 1)
Name                :
RAID Level          : Primary-0, Secondary-0, RAID Level Qualifier-0
Size                : 465.25 GB
Sector Size         : 512
Parity Size         : 0
State               : Optimal
Strip Size          : 64 KB
Number Of Drives    : 1
Span Depth          : 1
Default Cache Policy: WriteBack, ReadAdaptive, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteBack, ReadAdaptive, Direct, No Write Cache if Bad BBU
Default Access Policy: Read/Write
Current Access Policy: Read/Write
Disk Cache Policy   : Disk's Default
Encryption Type     : None
Default Power Savings Policy: Controller Defined
Current Power Savings Policy: None
Can spin up in 1 minute: No
LD has drives that support T10 power conditions: No
LD's IO profile supports MAX power savings with cached writes: No
Bad Blocks Exist: No
Is VD Cached: No

# 这里开始是物理磁盘的信息,是一组磁盘信息,我们做了raid0,且只有一个盘
Physical Disk Information:
Physical Disk: 0
Enclosure Device ID: 32

# 在这看到磁盘插槽
Slot Number: 2

Drive's position: DiskGroup: 1, Span: 0, Arm: 0
Enclosure position: 1
Device Id: 2
WWN: 5002538d420c8c33
Sequence Number: 2
Media Error Count: 0
Other Error Count: 1158
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SATA

Raw Size: 465.761 GB [0x3a386030 Sectors]
Non Coerced Size: 465.261 GB [0x3a286030 Sectors]
Coerced Size: 465.25 GB [0x3a280000 Sectors]
Sector Size:  0
Firmware state: Online, Spun Up
Device Firmware Level: 2B6Q
Shield Counter: 0
Successful diagnostics completion on :  N/A
SAS Address(0): 0x4433221105000000
Connected Port Number: 5(path0) 
Inquiry Data: S2RCNB0J601332N     Samsung SSD 850 EVO 500GB               EMT02B6Q
FDE Capable: Capable
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: None 
Device Speed: 6.0Gb/s 
Link Speed: 6.0Gb/s 
Media Type: Solid State Device
Drive:  Not Certified
Drive Temperature : N/A
PI Eligibility:  No 
Drive is formatted for PI information:  No
PI: No PI
Port-0 :
Port status: Active
Port's Linkspeed: 6.0Gb/s 
Drive has flagged a S.M.A.R.T alert : No

定位到磁盘后,我们就可以对磁盘进行更换和维护的操作了。