Re: Replacing a member disk in RAID0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
# 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



[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux