I have a RAID5 consisting of 3 disks, one of which is broken. I was wondering if it is possible to convert those two disks to a RAID1 without data loss and without having to back-up the data elsewhere.
Can mdadm convert a RAID5 to a RAID1
mdadmraid1raid5
Related Topic
- Linux – mdadm: Convert RAID10 to RAID1
- Linux – How to Convert RAID1 to RAID0
- Lvm – MD, partially grown from RAID1 to RAID5 but was interrupted, disks removed, and now file system is FUBAR
- TRIM issues with software RAID1 (mdadm) on two different SSDs (size and manufacturer)
- HP Smart Array P410: Convert RAID10 to RAID1 OR remove disks from RAID10
Best Answer
You'd be left with only half the capacity, so if the file system was more than half full already, it would be impossible. Even if there is sufficiently free space, the operation involves resizing the file system, which requires intimate knowledge of the file system.
Moreover applying ordinary resizing tools to a degraded RAID5 before converting it to RAID1 means that for a large part of the operation you will be performing lots of writes to a degraded RAID5. Another disk failure during that operation would leave you with practically no chance to recover your data (even if you somehow managed to get the first failed disk alive again).
Performing the operation safely would have to first identify those areas of the RAID5 where both data disks had free blocks. All of those free blocks as well as the parity of two free blocks can be used as scratch space during a conversion operation.
If enough such scratch space can be identified, it is in principle possible to first perform a sequence of "safe" writes in order to regain redundancy and then from that point start a conversion to RAID1.
Software to perform that task would be complicated and rarely used hence not well tested. Even if we could find such software, I wouldn't trust it with any important data.
My conclusion from this is that if the data is important you get a new disk ASAP.