How to create raid1 mirror for existing mdadm raid0 - without overwriting data

0

I created a /dev/md1 raid0 across two drives, added ext4 filesystem, and it's mountable and working fine.

I created a /dev/md2 raid0 across two drives, added ext4 filesystem, and it's also mountable and working fine.

When I try to make a /dev/md0 raid1 using devices /dev/md1 and /dev/md2 it changes the filesystem to linux raid member, and cannot be mounted.

If I add ext4 to the raid1, will it overwrite the underlying raid0 data, or will it apply only to the raid1? I don't understand how the filesystem interacts with mdadm builds.

gboone

Posted 2019-01-02T15:35:52.710

Reputation: 3

Just like you had to partition and format your raid 0, you have to partition and format your raid 1. Whatever is currently on the raid 0 volumes will be destroyed as is the case when creating any RAID. – Appleoddity – 2019-01-02T15:40:57.940

Answers

1

Linux Software RAID member devices do not have filesystems, they are block devices. Once you create the RAID1 using the two underlying devices, the existing ext4 filesystems on those devices are basically not relevant.

You would only create a filesystem once, on top of the RAID1 device.

The only filesystem that would be mounted is the one on top of the RAID1 device.

Dan Stoner

Posted 2019-01-02T15:35:52.710

Reputation: 41

So to clarify from a raid build standpoint, I thought it was possible to "add" a mirror. Assuming I am correct (please confirm, thanks) then, in this case, it's not possible to do that because there is not ALREADY an existing raid1? Something like that? – gboone – 2019-01-02T16:03:51.367

I believe "add a mirror" means add to an existing RAID1. When the RAID1 is first created it has a single member, so "add" means add the second member (and possibly a standby, etc.). Filesystems get created on top of (after) RAID devices. So for your 4 drives total, you could 1. make two RAID0 devices 2. make a RAID1 device on top of the RAID0 devices 3. create a filesystem on top of the RAID1 device. – Dan Stoner – 2019-01-02T20:58:38.307