linux单盘raid0,MegaCli修复单盘RAID0

背景:某台机器做个几块单盘RAID0,可以理解成单盘单用,因为有RAID卡必须要做RAID才能识别到硬盘,所以单块盘也要做成RAID0。现在有块盘坏了,厂家换了新盘没重做,怎么恢复呢?

1、查看所有磁盘的状态,这没啥好说的

./MegaCli64 -PDList -a0

2、有块盘Firmware state是Unconfigured(bad),这是今天要拯救的目标

Enclosure Device ID: 0

Slot Number: 3

Device Id: 8

Sequence Number: 2

Media Error Count: 0

Other Error Count: 0

Predictive Failure Count: 0

Last Predictive Failure Event Seq Number: 0

PD Type: SATA

Raw Size: 3.638 TB [0x1d1c0beb0 Sectors]

Non Coerced Size: 3.637 TB [0x1d1b0beb0 Sectors]

Coerced Size: 3.637 TB [0x1d1b00000 Sectors]

Firmware state: Unconfigured(bad)

SAS Address(0): 0x5001c45000785ca3

Connected Port Number: 0(path0)

Inquiry Data: 手动马赛克

FDE Capable: Not Capable

FDE Enable: Disable

Secured: Unsecured

Locked: Unlocked

Foreign State: None

Device Speed: Unknown

Link Speed: Unknown

Media Type: Hard Disk Device

3、可选:查看磁盘的缓存策略,每块盘一行,现在的结果应该少一行,因为少块盘

./MegaCli64 -LDGetProp -Cache -Lall -a0

4、先让这块磁盘变成good

./MegaCli64 -PDMakeGood -PhysDrv[0:3] -a0

Adapter: 0: EnclId-0 SlotId-3 state changed to Unconfigured-Good.

Exit Code: 0x00

这里-PhysDrv[0:3]对应上面的Enclosure Device ID和Slot Number,-a肯定是Adapter #0,不太懂为啥盘要有Good/bad之分。再看磁盘的状态

Enclosure Device ID: 0

Slot Number: 3

Device Id: 8

Sequence Number: 3

Media Error Count: 0

Other Error Count: 0

Predictive Failure Count: 0

Last Predictive Failure Event Seq Number: 0

PD Type: SATA

Raw Size: 3.638 TB [0x1d1c0beb0 Sectors]

Non Coerced Size: 3.637 TB [0x1d1b0beb0 Sectors]

Coerced Size: 3.637 TB [0x1d1b00000 Sectors]

Firmware state: Unconfigured(good), Spun Up

SAS Address(0): 0x5001c45000785ca3

Connected Port Number: 0(path0)

Inquiry Data: 手动马赛克

FDE Capable: Not Capable

FDE Enable: Disable

Secured: Unsecured

Locked: Unlocked

Foreign State: Foreign

Foreign Secure: Drive is not secured by a foreign lock key

Device Speed: Unknown

Link Speed: Unknown

Media Type: Hard Disk Device

5、磁盘确实Good了,但是Foreign State变成了Foreign,需要清除Foreign

./MegaCli64 -cfgforeign -clear -a0

Foreign configuration 0 is cleared on controller 0.

Exit Code: 0x00

再看磁盘的状态

Enclosure Device ID: 0

Slot Number: 3

Device Id: 8

Sequence Number: 3

Media Error Count: 0

Other Error Count: 0

Predictive Failure Count: 0

Last Predictive Failure Event Seq Number: 0

PD Type: SATA

Raw Size: 3.638 TB [0x1d1c0beb0 Sectors]

Non Coerced Size: 3.637 TB [0x1d1b0beb0 Sectors]

Coerced Size: 3.637 TB [0x1d1b00000 Sectors]

Firmware state: Unconfigured(good), Spun Up

SAS Address(0): 0x5001c45000785ca3

Connected Port Number: 0(path0)

Inquiry Data: 手动马赛克

FDE Capable: Not Capable

FDE Enable: Disable

Secured: Unsecured

Locked: Unlocked

Foreign State: None

Device Speed: Unknown

Link Speed: Unknown

Media Type: Hard Disk Device

6、现在再做RAID0

./MegaCli64 -cfgldadd -r0 [0:3] WB RA Direct -a0

Adapter 0: Created VD 马赛克

Adapter 0: Configured the Adapter!!

Exit Code: 0x00

这时候再看./MegaCli64 -LDGetProp -Cache -Lall -a0,应该会多一行,对应上面的新VD