可能的 mdadm RAID 状态?

j-g*_*tus 7 linux raid mdadm ubuntu

我正在为 Ubuntu 10.4 上的家庭服务器 RAID mdadm 编写监控插件。

使用sudo mdadm --detail /dev/md0 我得到这样的输出:

/dev/md0:
        Version : 00.90
  Creation Time : Thu Dec 17 14:31:49 2009
     Raid Level : raid5
     Array Size : 4395407808 (4191.79 GiB 4500.90 GB)
  Used Dev Size : 1465135936 (1397.26 GiB 1500.30 GB)
   Raid Devices : 4
  Total Devices : 4
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Sun Jul 11 06:57:28 2010
          State : clean
 Active Devices : 4
Working Devices : 4
 Failed Devices : 0
  Spare Devices : 0

...
Run Code Online (Sandbox Code Playgroud)

我正在寻找“状态”的可能值,但似乎无法在任何地方找到它,我找到man在线文档似乎也没有列表。

有谁知道在哪里可以找到可能的状态列表?

Den*_*son 8

基于源代码, ("clean" or "active") and ("degraded" or "") and ("" or "resyncing" or "recovering") and ("" or "Not Started")。

if (array.raid_disks)
                  printf("          State : %s%s%s%s\n",
                         (array.state&(1<<MD_SB_CLEAN))?"clean":"active",
                         array.active_disks < array.raid_disks? ", degraded":"",
                         (!e || e->percent < 0) ? "" :
                         (e->resync) ? ", resyncing": ", recovering",
                         larray_size ? "": ", Not Started");
Run Code Online (Sandbox Code Playgroud)

你没有问 about disk.state,但这里是相关的源代码:

if (disk.state & (1<<MD_DISK_FAULTY)) {
                        printf(" faulty");
                        if (disk.raid_disk < array.raid_disks &&
                            disk.raid_disk >= 0)
                              failed++;
                  }
                  if (disk.state & (1<<MD_DISK_ACTIVE)) printf(" active");
                  if (disk.state & (1<<MD_DISK_SYNC)) printf(" sync");
                  if (disk.state & (1<<MD_DISK_REMOVED)) printf(" removed");
                  if (disk.state & (1<<MD_DISK_WRITEMOSTLY)) printf(" writemostly");
                  if ((disk.state &
                       ((1<<MD_DISK_ACTIVE)|(1<<MD_DISK_SYNC)|(1<<MD_DISK_REMOVED)))
                      == 0) {
                        printf(" spare");
                        if (is_26) {
                              if (disk.raid_disk < array.raid_disks && disk.raid_disk >= 0)
                                    printf(" rebuilding");
                        } else if (is_rebuilding && failed) {
                              /* Taking a bit of a risk here, we remove the
                               * device from the array, and then put it back.
                               * If this fails, we are rebuilding
                               */
                              int err = ioctl(fd, HOT_REMOVE_DISK, makedev(disk.major, disk.minor));
                              if (err == 0) ioctl(fd, HOT_ADD_DISK, makedev(disk.major, disk.minor));
                              if (err && errno ==  EBUSY)
                                    printf(" rebuilding");
Run Code Online (Sandbox Code Playgroud)