大网数据广告活动
服务器运维问答

mdadm raid5 starts recovery right after creation

· 52CE 我爱测

just for getting some experience with mdadm I've put some HDD together and try a bit. I have 2 250 GB and one 500 GB HDD. I know thats not optimal for RAID5 and I'll only get 500 GB capacity in total. 250 GB of 500 GB HDD is wast…

问题原文

原帖链接 · Hannes · CC BY-SA 4.0

just for getting some experience with mdadm I've put some HDD together and try a bit. I have 2 250 GB and one 500 GB HDD. I know thats not optimal for RAID5 and I'll only get 500 GB capacity in total. 250 GB of 500 GB HDD is wasted. But as I said, I'm just playing around a bit.

First lets see the disk sizes:

lsblk /dev/sdb /dev/sdc /dev/sdd
NAME MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb    8:16   0 232.9G  0 disk
sdc    8:32   0 465.8G  0 disk
sdd    8:48   0 232.9G  0 disk

Create the RAID5:

sudo mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd -c 4 --auto md

Show info for created Raid5:

cat /proc/mdstat                                     Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sdd[3] sdc[1] sdb[0]
      488132976 blocks super 1.2 level 5, 4k chunk, algorithm 2 [3/2] [UU_]
      [>....................]  recovery =  0.5% (1354384/244066488) finish=59.7min speed=67719K/sec
      bitmap: 0/2 pages [0KB], 65536KB chunk

unused devices: <none>

Show a bit more details:

 sudo mdadm --detail /dev/md0
/dev/md0:
           Version : 1.2
     Creation Time : Wed Feb 26 14:52:54 2020
        Raid Level : raid5
        Array Size : 488132976 (465.52 GiB 499.85 GB)
     Used Dev Size : 244066488 (232.76 GiB 249.92 GB)
      Raid Devices : 3
     Total Devices : 3
       Persistence : Superblock is persistent

     Intent Bitmap : Internal

       Update Time : Wed Feb 26 14:57:43 2020
             State : clean, degraded, recovering
    Active Devices : 2
   Working Devices : 3
    Failed Devices : 0
     Spare Devices : 1

            Layout : left-symmetric
        Chunk Size : 4K

Consistency Policy : bitmap

    Rebuild Status : 7% complete

              Name : raspberrypi:0  (local to host raspberrypi)
              UUID : 3291b54e:fad8f43b:cc398574:a1845ff9
            Events : 57

    Number   Major   Minor   RaidDevice State
       0       8       16        0      active sync   /dev/sdb
       1       8       32        1      active sync   /dev/sdc
       3       8       48        2      spare rebuilding   /dev/sdd

Dmesg shows

[ 2462.122882] md/raid:md0: device sdc operational as raid disk 1
[ 2462.122892] md/raid:md0: device sdb operational as raid disk 0
[ 2462.126278] md/raid:md0: raid level 5 active with 2 out of 3 devices, algorithm 2
[ 2462.142439] md0: detected capacity change from 0 to 499848167424
[ 2462.222689] md: recovery of RAID array md0

So what am I doing wrong with the creation of RAID5? I'm also confused in output of mdadm --detail /dev/md0 with disknumber 0, 1 and 3 and not 0, 1, 2

已采纳解答

原帖链接 · shodanshok · CC BY-SA 4.0

This is correct behavior for a newly created RAID5 array: just after creation, it needs to compute the correct parity for each stripe.

You can append --assume-clean to your mdadm command to skip the initial sync, but I strongly suggest against it: if your parity does not match, any check will report thousands of errors, and you will be unable to recognize real error from "fake" ones. To fix this very ambiguous situation, you need to run a repair command - which will recompute parity just as the initial array creation does.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-02-26)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。