问题原文
原帖链接 · 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 DEVICEWhere
ARRAYis the ID of the array like /dev/md2 andDEVICEis a partition of that array like sdc2 or sdd2.Change the size of the RAID1 to two disks:
mdadm --grow ARRAY -n 2Change the type of array from RAID1 to RAID5:
mdadm --grow ARRAY -l 5Now add all the disks again, that were removed in the first step:
mdadm ARRAY --add-spare DEVICE DEVICE ...Please note, that unlike for
--failand--remove, you need to specify the full pathnames of theDEVICEs.Grow the RAID5 to the number of available
DISKS:mdadm --grow ARRAY -n DISKSThis 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/mdstatto 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.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
