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

RAID-1 to RAID-5 using mdadm

· 52CE 我爱测

As per subject. When converting from RAID-1 to RAID-5 using mdadm, why must a RAID 1 array contain 2 devices and not more than 2 devices? I don't understand RAID strong enough to pinpoint a reason. Background: My three RAID-1 arr…

问题原文

原帖链接 · stampkick · CC BY-SA 3.0

As per subject.

When converting from RAID-1 to RAID-5 using mdadm, why must a RAID 1 array contain 2 devices and not more than 2 devices? I don't understand RAID strong enough to pinpoint a reason.

Background: My three RAID-1 arrays contain 3 devices each, my goal is to remove one device from two of the arrays, and attach the spare devices to the remaining RAID-1 array. That will leave two RAID-1 arrays with 2 devices each, and the remaining RAID array with 4 devices. The goal is take the 4 device RAID-1 array and convert that to RAID-5. This is not a discussion about which RAID architectures are better or worse, just the process to change a RAID-1 array to a RAID-5 array.

社区高分解答

原帖链接 · Kai Petzke · CC BY-SA 4.0

Upgrading an N-disk RAID1 to an N-disk RAID5 is possible, though a bit tedious:

  • Remove all but two disks from the RAID1. To do so, repeatedly execute:

    mdadm ARRAY --fail DEVICE
    mdadm ARRAY --remove DEVICE
    

    Where ARRAY is the ID of the array like /dev/md2 and DEVICE is a partition of that array like sdc2 or sdd2.

  • Change the size of the RAID1 to two disks:

    mdadm --grow ARRAY -n 2
    
  • Change the type of array from RAID1 to RAID5:

    mdadm --grow ARRAY -l 5
    
  • Now add all the disks again, that were removed in the first step:

    mdadm ARRAY --add-spare DEVICE DEVICE ...
    

    Please note, that unlike for --fail and --remove, you need to specify the full pathnames of the DEVICEs.

  • Grow the RAID5 to the number of available DISKS:

    mdadm --grow ARRAY -n DISKS
    

    This is the only slow operation, as it needs to move all data on the disks and generate parity. However, while it is in progress, you can still work on the machine, but you should expect degraded disk performance.

  • After the grow operation has finished (use cat /proc/mdstat to see its progress), you can resize the file system. Assuming, that you use ext4, this goes via:

    resize2fs ARRAY
    

Because of the lengthy re-arrangement of the data, it is often faster to delete the RAID1, then create a fresh RAID5 (which still needs to create parity, but which is an easier operation than to re-shuffle all data) and restore the data from a backup.

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

资料来源与适用范围

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

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

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