Initial considerations
It is possible to upgrade RAID1 to RAID5 without losing data, but as any operation that involves stored data it is dangerous and may result in dataloss if not performed correctly, so be warned. Please be aware that this operation requires a Disk ARRAY
of N-disk where N ≥ 3.
The process to upgrade RAID1 to RAID5 without losing data, depending on the disk technology and array size, may be extremely slow and tedious. As the array gets upgraded, it will need to move data across all disks and generate parity. While doing so the machine will show degraded disk performance.
Table of Contents
- What is RAID
- Advantages of RAID5 over RAID1
- Upgrade Procedure
- Performing the upgrade
What is RAID
RAID, or Redundant Array of Inexpensive Disks is a data storage technology that combines multiple disk drives into one or more logical units, in order to achieve data redundancy, improved performance, or both. To do so, RAID employs techniques of data mirroring or/and data stripping.
Mirroring, like the name suggests, will copy identical data onto more than one disk drive. Stripping allows to spread data over more than one disk drive. There is also hybrid-RAID that employs multiple RAID techniques like RAID 1+0 often referred to as RAID 10.
A RAID array can be managed either by software or hardware. In case of an hardware-based solution, a dedicated controller will manage RAID operations and disk drives, while in software-based a software RAID implementation will manage RAID. Today, most modern operating systems include RAID support.
Advantages of RAID5 over RAID1
![Upgrade RAID1 to RAID5 without losing data 1 RAID 1](https://www.isscloud.io/delta/wp-content/uploads/2022/10/raid-1.webp)
RAID 1 or disk mirroring, is the replication of data to two or more disks. RAID 1 is a typical choice for applications that require high availability. One of the main points for RAID 1 is the increased fault tolerance, as it can tolerate more than one disk drives failure. The read
performance is improved, but write
performance is the same as for a single disk and has no improvement.
![Upgrade RAID1 to RAID5 without losing data 2 RAID 5](https://www.isscloud.io/delta/wp-content/uploads/2022/10/raid-5.webp)
RAID 5 is based on block-level stripping parity. The parity information is stripped across each disk drive on the array, enabling it to function even if one drive fails. This is also the main limitation of **RAID 5**, to maintain operation it is limited to one disk drive failure. RAID 5 requires at least three disks, but is often recommended to use five or above for performance reasons.
The RAID5 architecture enables read and write operations to span multiple drives, which results in better read and write performance.
In this guide we will show you how to upgrade RAID1 to RAID5 without losing data on and existing RAID1 ARRAY
.
Upgrade Procedure
To upgrade RAID1 to RAID5 without losing data we will go over the following process:
- Remove all devices from the RAID array but two
- Shrink the RAID array to the size of 2
- Upgrade the array
- Add all the devices back
- Grow the RAID array to the total number of disks
- Resize the filesystem
Please backup your data first. Errors may result in full data loss.
Performing the upgrade
Let’s go over the following steps to upgrade RAID1 to RAID5 without losing data:
- Remove all but two disks from the RAID1 by repeatedly executing:
mdadm ARRAY --fail DEVICE
mdadm ARRAY --remove DEVICE
Code language: PHP (php)
Where ARRAY
is the ID of the array like /dev/md127
and DEVICE
is a partition of that array like sda1
or sdc1
.
- Change the size of the RAID1
ARRAY
to two disks:
mdadm --grow ARRAY -n 2
Code language: PHP (php)
- Change the type of
ARRAY
from RAID1 to RAID5
mdadm --grow ARRAY -l 5
Code language: PHP (php)
- Re-add all the disks removed in the first step. Unlike for
--fail
and--remove
, you have to specify the full path forDEVICE
.
mdadm ARRAY --add-spare DEVICE DEVICE ...
Code language: PHP (php)
- Grow the RAID5 to the number of available
DISKS
mdadm --grow ARRAY -n DISKS
Code language: PHP (php)
This is the slow part of the job, which may become daunting depending on the disks size. You may still work on the machine, but you should expect degraded performance.
- To monitor the job progress, use
watch -n0.5 cat /proc/mdstat
![Upgrade RAID1 to RAID5 without losing data 3 Upgrade RAID1 to RAID5 without losing data](https://www.isscloud.io/delta/wp-content/uploads/2022/10/upgrade-raid1-to-raid5-without-losing-data-1024x152.webp)
After the operation has finished, you can resize the filesystem.
- For ext4 use:
resize2fs ARRAY
Code language: PHP (php)
- For xfs use:
xfs_growfs ARRAY
Code language: PHP (php)
And that’s it. We have successfully finished how to upgrade RAID1 to RAID5 without losing data. Due to the data operations this may become a very tedious operation on systems with large disks. It is often faster to backup the data, delete the RAID1 array and create a fresh RAID5 array, then restore the data from the backup.
Hope you enjoyed it and you are welcome to leave a comment. For other amazing articles and guides, visit our blog.