2

I have a linux server (3.19.0) which has raid setup with md (v3.2.5). / is a raid1 device with 2 disks. There was a mistake when installing this machine, instead we need those 2 disks to be in raid0 configuration. Is there an easy way to change the md device like this?

I can maybe figure out how to make this happen by jugglying disks around, (and reinstalling is an option), but is there an easy way to turn a raid1 into a raid0?

In theory this feels possible to me. Is it possible for md to act like one of the disks is empty, and change the raid type from 1 to 0?

Amandasaurus
  • 31,471
  • 65
  • 192
  • 253

2 Answers2

2
mdadm /dev/md0 --grow --level=0
mdadm: level of /dev/md0 changed to raid0

mdadm /dev/md0 --grow --raid-devices=2 --add /dev/sdb1
mdadm: level of /dev/md0 changed to raid4
//here pause for reshare array
mdadm: level of /dev/md0 changed to raid0

resize2fs /dev/md0
2

mdadm(8) sez:

The GROW mode is used for changing the size or shape of an active array. [...] Currently the supported changes include

[...]

  • convert between RAID1 and RAID5, between RAID5 and RAID6, between RAID0, RAID4, and RAID5, and between RAID0 and RAID10 (in the near-2 mode).

So, going from RAID1 to RAID0 doesn't appear to be possible. If you had a third disk, you could perhaps go from RAID1 to RAID5 to RAID0, but that seems like a rather roundabout way to do it.

The manpage does, however, say that you can "increase or decrease the "raid-devices" attribute of RAID0, RAID1, RAID4, RAID5, and RAID6", so you could break the RAID1, turn one of the disks into a new one-disk RAID0 array, copy the data across, then nuke the other half of the RAID1 and add that now available disk into the RAID0.

Finally, you can do it the right way, and just backup the data, reconfigure the RAID array offline, and then restore the backup onto the new array.

womble
  • 96,255
  • 29
  • 175
  • 230
  • 2
    I did `mdadm /dev/md2 --grow --level=0` and it has turned `md2` into a raid0 device, with only disk in it. However i have another problem with this new raid device where I can't add any other disks: http://serverfault.com/questions/737811/personality-does-not-support-diskops-when-trying-to-add-a-drive-to-a-mdadm-ra – Amandasaurus Nov 20 '15 at 14:01