如何在 Ubuntu 18.04 上的 raid1 系统上查找磁盘序列号

如何在 Ubuntu 18.04 上的 raid1 系统上查找磁盘序列号

我有一台装有 SSD RAID1 磁盘的远程服务器。我找不到出错磁盘的序列号。有人能帮忙吗?谢谢!

我收到以下错误信息:

A DegradedArray event had been detected on md device /dev/md/1.

PS /proc/mdstat 文件当前包含以下内容:

Personalities : [raid1] [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid10] 
md0 : active raid1 sda1[0] sdc1[2] sdd1[3]
     16760832 blocks super 1.2 [4/3] [U_UU]

md2 : active raid6 sdd3[3] sdc3[2] sda3[0]
     432926720 blocks super 1.2 level 6, 512k chunk, algorithm 2 [4/3] [U_UU]
     bitmap: 2/2 pages [8KB], 65536KB chunk

md1 : active raid1 sda2[0] sdd2[3] sdc2[2]
     523712 blocks super 1.2 [4/3] [U_UU]

unused devices: <none>

lshw 级磁盘报告

*-磁盘:0

   description: SCSI Disk
   product: MR9260-4i
   vendor: LSI
   physical id: 2.0.0
   bus info: scsi@0:2.0.0
   logical name: /dev/sda
   version: 2.13
   serial: 00f03316f7f4b700ffa0bf2c09b00506
   size: 223GiB (239GB)
   capabilities: partitioned partitioned:dos
   configuration: ansiversion=5 logicalsectorsize=512 sectorsize=512 signature=0aff576a

*-磁盘:1

   description: SCSI Disk
   product: MR9260-4i
   vendor: LSI
   physical id: 2.2.0
   bus info: scsi@0:2.2.0
   logical name: /dev/sdc
   version: 2.13
   serial: 006c491cf7f5b700ffa0bf2c09b00506
   size: 223GiB (239GB)
   capabilities: partitioned partitioned:dos
   configuration: ansiversion=5 logicalsectorsize=512 sectorsize=512 signature=2fc55799

*-磁盘:2

   description: SCSI Disk
   product: MR9260-4i
   vendor: LSI
   physical id: 2.3.0
   bus info: scsi@0:2.3.0
   logical name: /dev/sdd
   version: 2.13
   serial: 002ee71ff7f5b700ffa0bf2c09b00506
   size: 223GiB (239GB)
   capabilities: partitioned partitioned:dos
   configuration: ansiversion=5 logicalsectorsize=512 sectorsize=512 signature=fecae65e

答案1

我编写了一个脚本,可以检查阵列和所有磁盘以及磁盘的序列号,以便更容易地找到它们。

该脚本(我称之为我的drive_check.bsh):

#!/bin/bash

# Check for root
if [ "$EUID" -ne 0 ]; then
  echo "Please run $0 as root"
  echo ""
  echo "example:"
  echo "sudo $0"
  exit 1
fi

# Check for smartmontools
smartctl -h > /dev/null
case $? in
    1) echo "smartmontools is not installed.  Please install it with the following command:"
    echo ""
    echo "sudo apt install smartmontools"
    exit 1;;
    0) ;;
esac

#Get metadisk details for each array
awk '/: active/ {print $1}' /proc/mdstat | while read drv
do
    sudo mdadm -D /dev/$drv
done

echo ""

# Create drive array
drives=( $(smartctl --scan | awk '{print $1}') )

# Loop through array and check each drive
for ((i=0; i < ${#drives[@]}; ++i))
do
    model=$(smartctl -a ${drives[$i]} | grep -i "device model:" | awk '{print substr($0,index($0,$3))}')
    serial=$(smartctl -a ${drives[$i]} | grep -i "serial number:" | awk '{print $NF}')
    result=$(smartctl -H ${drives[$i]} | awk '/overall-health/ {print $NF}')
    echo -n "${drives[$i]} Model: $model Serial: $serial SMART: $result"
    j=$(echo ${drives[$i]} | cut -d/ -f3); echo -n " Errors: "
    grep -i error /var/log/kern.log 2>/dev/null | grep "$j," | wc -l
done

使其成为可执行脚本,然后使用 运行它sudo

例子:

terrance@Intrepid:~$ sudo ./drive_check.bsh 
/dev/md0:
           Version : 1.2
     Creation Time : Wed Dec 27 18:06:03 2017
        Raid Level : raid1
        Array Size : 484323328 (461.89 GiB 495.95 GB)
     Used Dev Size : 484323328 (461.89 GiB 495.95 GB)
      Raid Devices : 2
     Total Devices : 2
       Persistence : Superblock is persistent

     Intent Bitmap : Internal

       Update Time : Wed Oct 28 19:48:39 2020
             State : active 
    Active Devices : 2
   Working Devices : 2
    Failed Devices : 0
     Spare Devices : 0

Consistency Policy : bitmap

              Name : Intrepid:root  (local to host Intrepid)
              UUID : f9b257fc:d64f97c7:95581e88:004e3a4b
            Events : 45438

    Number   Major   Minor   RaidDevice State
       2       8      161        0      active sync   /dev/sdk1
       1       8        1        1      active sync   /dev/sda1
/dev/md2:
           Version : 1.2
     Creation Time : Wed Dec 27 18:18:25 2017
        Raid Level : raid1
        Array Size : 3927040 (3.75 GiB 4.02 GB)
     Used Dev Size : 3927040 (3.75 GiB 4.02 GB)
      Raid Devices : 2
     Total Devices : 2
       Persistence : Superblock is persistent

       Update Time : Wed Oct 28 19:48:10 2020
             State : clean 
    Active Devices : 2
   Working Devices : 2
    Failed Devices : 0
     Spare Devices : 0

Consistency Policy : resync

              Name : Intrepid:swap  (local to host Intrepid)
              UUID : 2cdfcb03:e5e0c30f:d68d4e20:37b50e41
            Events : 125

    Number   Major   Minor   RaidDevice State
       2       8      165        0      active sync   /dev/sdk5
       1       8        5        1      active sync   /dev/sda5
/dev/md1:
           Version : 1.2
     Creation Time : Tue Feb  3 01:16:55 2015
        Raid Level : raid5
        Array Size : 15627542528 (14903.59 GiB 16002.60 GB)
     Used Dev Size : 3906885632 (3725.90 GiB 4000.65 GB)
      Raid Devices : 5
     Total Devices : 5
       Persistence : Superblock is persistent

     Intent Bitmap : Internal

       Update Time : Wed Oct 28 18:28:07 2020
             State : clean 
    Active Devices : 5
   Working Devices : 5
    Failed Devices : 0
     Spare Devices : 0

            Layout : left-symmetric
        Chunk Size : 512K

Consistency Policy : bitmap

              Name : Intrepid:1  (local to host Intrepid)
              UUID : 3bb988cb:d5270497:36e75f46:67a9bc65
            Events : 1154191

    Number   Major   Minor   RaidDevice State
       0       8       81        0      active sync   /dev/sdf1
       1       8       97        1      active sync   /dev/sdg1
       2       8      113        2      active sync   /dev/sdh1
       3       8      129        3      active sync   /dev/sdi1
       5       8      145        4      active sync   /dev/sdj1

/dev/sda Model: MAXTOR STM3500630A Serial: 9QG9152W SMART: PASSED Errors: 0
/dev/sdf Model: WDC WD40EFRX-68WT0N0 Serial: WD-WCC4EJPD3EXP SMART: PASSED Errors: 0
/dev/sdg Model: WDC WD40EFRX-68WT0N0 Serial: WD-WCC4E5UZUKPY SMART: PASSED Errors: 0
/dev/sdh Model: WDC WD40EFRX-68WT0N0 Serial: WD-WCC4E3XCP660 SMART: PASSED Errors: 0
/dev/sdi Model: WDC WD40EFRX-68WT0N0 Serial: WD-WCC4E7ZRRN8U SMART: PASSED Errors: 0
/dev/sdj Model: WDC WD40EFRX-68WT0N0 Serial: WD-WCC4EJXKY26C SMART: PASSED Errors: 0
/dev/sdk Model: ST3500418AS Serial: 6VM1HTNN SMART: PASSED Errors: 0

希望这可以帮助!

相关内容