Migrating from single disk to RAID5.

Published by Tobias Hofmann on

4 min read


I have 1 HDD with data on it, and two new, empty HDDs. All 3 disks have the same size (10TB).

  • Data: SDC
  • New: SDE
  • New: SDF

I want to go for a RAID5 using all 3 HDDs, without losing data. For this to work, the idea is to:

  1. Create a 3 disk RAID5 with the two new HDD SDE and SDF. One drive will be marked as missing.
  2. Copy data from existing disk SDC to RAID5
  3. Add HDD SDC to RAID5 as the missing drive
  4. Have a RAID 5 with 3 disks: SDC, SDE, SDF and the old data from SDC on it


Install mdmadm

apt-get update
apt-get install mdadm

Create RAID5

mdadm --create /dev/md0 --level=5 --raid-devices=3 missing /dev/sde1 /dev/sdf1

This starts the RAID5 creation process. To see the current status

cat /proc/mdstat

Two drives SDF and SDE are working, one (SDC) is missing: [_UU]. The RAID5 is now ready. To use it, format it. I am using ext4

mkfs.ext4 /dev/md0

Capacity of the MD0 Raid5 is 20 TB

Copy files

With the RAID5 available and a file system created, I can start to copy the files from my HDD SDC to md0. This will take a while.

rsync -av /mnt/sdc/ /mnt/md0

Add disk to RAID5

After copying the files from to md0, I can add the HDD SDC to the RAID5 as the missing disk. Currently, there is partition with an ext4 filesystem on the old HDD. This can be deleted, as the data is already on md0. Create the partition using parted /dev/sdc

parted -s -a optimal /dev/sdc mklabel gpt

Next step is to add the now empty SDC to the RAID5 md0. Reminder: currently the RAID5 is active with 3 HDDs and one missing: [_UU].

Add SDC as the missing one to md0:

mdadm --add /dev/md0 /dev/sdc1

To see the current progress, look at /proc/mdstat.

cat /proc/mdstat

The new disk is now added as the missing one in the 3 disk RAID5. Syncing all the data will take hours. The initial estimate is close to 22 hours.

After the sync is done, all three HDDs will be shown as [UUU]

Capacity of the RAID5 is 20 TB.

Let the world know
Categories: Technology

Tobias Hofmann

Doing stuff with SAP since 1998. Open, web, UX, cloud. I am not a Basis guy, but very knowledgeable about Basis stuff, as it's the foundation of everything I do (DevOps). Performance is king, and unit tests is something I actually do. Developing HTML5 apps when HTML5 wasn't around. HCP/SCP user since 2012, NetWeaver since 2002, ABAP since 1998.


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.