On Mon, 15 Apr 2019 15:45:56 +0200 Andreas Klauer <Andreas.Klauer@xxxxxxxxxxxxxx> wrote: > On Mon, Apr 15, 2019 at 02:04:09PM +0500, Roman Mamedov wrote: > > I have a 2-device RAID0 with mdadm. I would like to replace one disk with > > a new one, while keeping the array online. > > Well, it's possible ... just not intuitive. Maybe a bit risky as well? > > | set up some test devices with random data > > # truncate -s 100M a b c > # shred -v -n 1 a b c > # losetup --find --show a > /dev/loop0 > # losetup --find --show b > /dev/loop1 > # losetup --find --show c > /dev/loop2 > > | create a 2-device RAID 0 and checksum > > # mdadm --create /dev/md42 --level=0 --raid-devices=2 /dev/loop[01] > # md5sum /dev/md42 > 7d1bba7a97467fd97d60d5e0303e4785 /dev/md42 > > | replace /dev/loop0 with /dev/loop2 > > # mdadm --grow /dev/md42 --level=5 > mdadm: level of /dev/md42 changed to raid5 At this point it starts rewriting data on both member devices into RAID5: [93729.643620] md/raid:md0: device sdg3 operational as raid disk 1 [93729.643622] md/raid:md0: device sdi3 operational as raid disk 0 [93729.674327] md/raid:md0: raid level 5 active with 2 out of 3 devices, algorithm 5 [93729.750306] md: reshape of RAID array md0 md0 : active raid5 sdg3[1] sdi3[0] 726982656 blocks super 1.2 level 5, 1024k chunk, algorithm 5 [3/2] [UU_] [>....................] reshape = 1.5% (5624832/363491328) finish=51.1min speed=116584K/sec Not what I was expecting. And surely converting back to RAID0 require another rewrite, i.e. this process is not a good solution either. > # mdadm --manage /dev/md42 --add-spare /dev/loop2 --replace /dev/loop0 --with /dev/loop2 > mdadm: added /dev/loop2 > mdadm: Marked /dev/loop0 (device 0 in /dev/md42) for replacement > mdadm: Marked /dev/loop2 in /dev/md42 as replacement for device 0 > # mdadm --wait /dev/md42 > # mdadm --grow /dev/md42 --level=0 > mdadm: level of /dev/md42 changed to raid0 > > | see if data is still intact > > # md5sum /dev/md42 > 7d1bba7a97467fd97d60d5e0303e4785 /dev/md42 > > Regards > Andreas Klauer -- With respect, Roman