1

I have existing RAID0 setup with two disks. I have to add a new drive to it. But when I try to run the following command:

mdadm --add /dev/md/customer_upload /dev/xvdl

I get an error:

mdadm: add new device failed for /dev/xvdl as 2: Invalid argument

How do I add a new disk to an existing RAID0?

I used the following steps to create RAID 0 initially:

 sudo mdadm --create --verbose /dev/md/customer_upload --level=stripe --raid-devices=2 device_name1 device_name2

EDIT

Seems like you cannot add disk to RAID0.

I ran the following command and it made it RAID4 How & Why I am still not clear

/dev/md/customer_upload --grow -l 0 --raid-devices=3 -a /dev/xvdl

I can see three disks in RAID4 but total space is still 2Tb

xvdf    202:80   0     1T  0 disk  
└─md127   9:127  0     2T  0 raid4 /customer_upload
xvdg    202:96   0     1T  0 disk  
└─md127   9:127  0     2T  0 raid4 /customer_upload
xvdl    202:176  0     1T  0 disk  
└─md127   9:127  0     2T  0 raid4 /customer_upload
MadHatter
  • 80,590
Ut xD
  • 238

3 Answers3

10

yes you can, to add one disk to raid 0

mdadm --grow /dev/md0 --level=0 --raid-devices=3 --add /dev/sdd

or you can add several disks

mdadm --grow /dev/md0 --level=0 --raid-devices=4 --add /dev/sdd /dev/sde

raid-devices=4 total devices count with new disks, raid 0 become raid 4 and after reshape will be raid 0 again

and these sysctl opts for reshape speed control dev.raid.speed_limit_min and dev.raid.speed_limit_max

3

According to the kernel.org RAID wiki:

After the new disk was partitioned, the RAID level 1/4/5/6 array can be grown

that is, RAID-0 is not eligible for growing. You will need to backup all the data, recreate the array from scratch, and restore from backups.

MadHatter
  • 80,590
  • I did mdadm /dev/md/customer_upload --grow -l 0 --raid-devices=3 -a /dev/xvdl and it made my setup RAID4, I can see all the three disks attached using lsblk but total space is still 2Tb. How to resolve this? It should be 3Tb since each disk is of 1Tb – Ut xD Dec 04 '14 at 12:17
  • Firstly, are you sure it changed the RAID level? Can you cut-and-paste the output of cat /proc/mdstat into your question? Secondly, have you grown the FS to fill the device? You keep telling us you know things ("total space is still 2Tb") but you don't show us how you know them, which makes it difficult to comment. – MadHatter Dec 04 '14 at 12:23
  • added to question – Ut xD Dec 04 '14 at 12:28
  • A three-1TB-stripe RAID-4 should be 2TB usable (2 data 1 parity), which is what you say you see. You need this to be a 3-stripe RAID-0, and I still think that means you'll need to backup, nuke, recreate, and restore. – MadHatter Dec 04 '14 at 12:33
  • How much space would I require for parity in RAID5? – Ut xD Dec 04 '14 at 12:43
  • The same; the only difference is that the parity blocks are striped across all three drives in 5, as opposed to all on one disc in 4. – MadHatter Dec 04 '14 at 13:29
0

Ok I searched about 20 different unsolved articles and I finally figured it out by dumb luck.

I had the same issue. I cloned the drive using sfdisk -d | sfdisk like the many manuals and blogs said. I later just opened fdisk /dev/sdd and then simply hit w to rewrite the partition table. This fixed my Invalid Argument error.

I hope this helps someone.

Juzzy
  • 1