What information is found in the following excerpt from the file /proc/mdstat? (Choose two.)

Personalities: [raid6] [raid5] [raid4]
md0 : active raid5 sdb1[3] (S) sdc1[7] sda1[4] (S) sdd1[6] sde1[5]
      1046528 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2] [UU_]
      [===>.......] recovery = 15.9 % (83808/523264) finish=0.1min
speed=71770K/sec
unused devices: <none>

A. One of the disks in /dev/md0 has failed and a spare disk is used to recreate full redundancy
B. The spare disk /dev/sda1 is used to restore full redundancy after the current recovery
C. The information [UU_] means, that the raid is missing one disk and is not fully redundant
D. The device is using version 1.2 metadata to allow LILO and GRUB Legacy to use /dev/md0 as the boot partition. This would not have been necessary with GRUB2
E. The information [3/2] means that 3 RAID disks belong to the array and 2 disks are spare. Together they equal the number of available disks

题解

「/proc/mdstat」文件存放着 Linux 内核正在使用的 RAID 信息。

md0 : active raid5 sdb1[3] (S) sdc1[7] sda1[4] (S) sdd1[6] sde1[5] 这个是在表示 md0 这个软件模拟的 RAID5 设备目前正在使用「sdb1」、「sdc1」、「sda1」、「sdd1」和「sde1」这几个分割区,当作其组成结构的硬盘。中括号「[]」中的数字表示该分割区在这个结构中的设备编号,使用中的硬盘编号不一定会小于主要硬盘的数量(硬盘被替换过后,新加入的硬盘会使用新的编号),所以不能只用编号来判断哪些是备援硬盘,而是要看后面有没有标示「(S)」。备援硬盘是在主要硬盘出问题后才会被系统自动换上。

接着先跳来看 [3/2] [UU_],「[3/2]」的「3」表示用来组成 RAID 的主要磁盘数量,「2」是表示其中正在激活的硬盘数量,所以「[3/2]」代表着目前有一个硬盘是不激活的状态,「[UU_]」则代表着是第三个位置的硬盘为不激活的状态。所以此时要有一个备援硬盘要被拿来替换原先第三个位置的硬盘,不然这个 RAID5 就会出问题了。

再回头看 md0 : active raid5 sdb1[3] (S) sdc1[7] sda1[4] (S) sdd1[6] sde1[5],虽然所有的硬盘编号都在「3」以上,但这并不代表它们都是备援硬盘。「(S)」表示「(S)」左边的那个硬盘为目前还没有被使用的备援硬盘,所以「sdb1」和「sda1」是闲置中的备援硬盘。至于没有标示「(S)」的「sdc1」、「sdd1」和「sde1」,则是目前占用着这个 RAID5 三个位置的硬盘,其中有一个是在原先的硬盘失效之后才被替换上去的,系统正在对它重建(recovery)数据。等重建完成后,这个 RAID5 就会恢复成 full redundancy 的状态,而「sdb1」和「sda1」仍然会是闲置中的备援硬盘。

选项 A,正确,有一个硬盘失效,且有一个备援硬盘被替换上去,正在重建数据。

选项 B,错误,目前正在进行的重建完成后就会恢复 full redundancy,不需要再用到「/dev/sda1」,它仍然会是闲置中的备援硬盘。

选项 C,正确。

选项 D,错误,LILO 和 GRUB Legacy 貌似只能使用版本 <1.0 的元数据,GRUB2 则貌似可以支持版本 >=0.9 的元数据。

选项 E,错误,「[3/2]」的「2」是表示正在激活的硬盘数量,不是备援硬盘的数量。