Raid

如何使用 mdadm 將額外的鏡像驅動器添加到現有的 RAID 陣列?

  • May 29, 2020

我創建了一個數組:

mdadm --create --verbose /dev/md3 --level=mirror --raid-devices=2 /dev/sdc1 /dev/sdd1

以上已經成功完成。

現在我想添加一個額外的驅動器以得到 3 個相同的鏡像。所以根據這裡的資訊https://raid.wiki.kernel.org/index.php/A_guide_to_mdadm#Adding_a_drive_to_a_mirror我跑了:

sudo mdadm --grow /dev/md127 --add /dev/sda --raid-devices=3
mdadm: added /dev/sda
raid_disks for /dev/md127 set to 3

但是查看診斷:

sudo mdadm -D /dev/md127
/dev/md127:
          Version : 1.2
    Creation Time : Wed May 20 18:06:31 2020
       Raid Level : raid1
       Array Size : 2928507904 (2792.84 GiB 2998.79 GB)
    Used Dev Size : 2928507904 (2792.84 GiB 2998.79 GB)
     Raid Devices : 3
    Total Devices : 3
      Persistence : Superblock is persistent

    Intent Bitmap : Internal

      Update Time : Thu May 28 14:44:52 2020
            State : clean, degraded, recovering 
   Active Devices : 2
  Working Devices : 3
   Failed Devices : 0
    Spare Devices : 1

Consistency Policy : bitmap

   Rebuild Status : 0% complete

             Name : blueberry:3  (local to host blueberry)
             UUID : 3cfe6a05:7fbfe9c6:0249d666:1a23a6aa
           Events : 5468

   Number   Major   Minor   RaidDevice State
      0       8       17        0      active sync   /dev/sdb1
      1       8       33        1      active sync   /dev/sdc1
      2       8        0        2      spare rebuilding   /dev/sda
cat /proc/mdstat 
Personalities : [raid1] 
md127 : active raid1 sda[2] sdc1[1] sdb1[0]
     2928507904 blocks super 1.2 [3/2] [UU_]
     [>....................]  recovery =  3.1% (92780288/2928507904) finish=336.6min speed=140405K/sec
     bitmap: 0/22 pages [0KB], 65536KB chunk

unused devices: <none>

似乎這個驅動器已被添加為spare替代?但奇怪的是它會這樣做rebuild嗎?

這似乎最終實際上是正確的。

最終輸出為:

cat /proc/mdstat 
Personalities : [raid1] 
md127 : active raid1 sda[2] sdc1[1] sdb1[0]
     2928507904 blocks super 1.2 [3/3] [UUU]
     bitmap: 0/22 pages [0KB], 65536KB chunk

unused devices: <none>
sudo mdadm -D /dev/md127
/dev/md127:
          Version : 1.2
    Creation Time : Wed May 20 18:06:31 2020
       Raid Level : raid1
       Array Size : 2928507904 (2792.84 GiB 2998.79 GB)
    Used Dev Size : 2928507904 (2792.84 GiB 2998.79 GB)
     Raid Devices : 3
    Total Devices : 3
      Persistence : Superblock is persistent

    Intent Bitmap : Internal

      Update Time : Thu May 28 22:22:04 2020
            State : clean 
   Active Devices : 3
  Working Devices : 3
   Failed Devices : 0
    Spare Devices : 0

Consistency Policy : bitmap

             Name : blueberry:3  (local to host blueberry)
             UUID : 3cfe6a05:7fbfe9c6:0249d666:1a23a6aa
           Events : 11028

   Number   Major   Minor   RaidDevice State
      0       8       17        0      active sync   /dev/sdb1
      1       8       33        1      active sync   /dev/sdc1
      2       8        0        2      active sync   /dev/sda

引用自:https://unix.stackexchange.com/questions/589511