Re: Defective RAID

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

 



On Tue, May 22, 2018 at 06:11:34AM +0000, Axel Spallek IT-Dienstleistungen wrote:
> I read a howto where one wrote I should recreate the raid:

https://unix.stackexchange.com/a/131927/30851

> Did I destroy the RAID?

Maybe. It depends...

If the RAID-5 was in sync before, and used all of the same offsets, 
and you re-created with the same number of drives... then the only 
thing that is really damaged is whatever the metadata overwrote 
(if you used a different metadata version before).

For all other data, XOR is XOR is XOR, even if you use the wrong 
chunk size and all, the result is still the same. That is assuming 
it was in sync before, of course.

Example with 4 loop devices:

# truncate -s 100M a b c d
# losetup --find --show a
/dev/loop0
# losetup --find --show b
/dev/loop1
# losetup --find --show c
/dev/loop2
# losetup --find --show d
/dev/loop3

Create RAID 5 with chunk 64:

# mdadm --create /dev/md42 --chunk=64 --level=5 --raid-devices=4 /dev/loop0 /dev/loop1 /dev/loop2 /dev/loop3
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md42 started.

Put some data on it:

# shred -v -n 1 /dev/md42
shred: /dev/md42: pass 1/1 (random)...
# md5sum /dev/md42
85febad8a4c2bd97b91e4da882d44b60  /dev/md42

Now destroy the RAID, re-create with wrong chunksize, wrong drive order:

# mdadm --stop /dev/md42
mdadm: stopped /dev/md42
# mdadm --create /dev/md42 --chunk=512 --level=5 --raid-devices=4 /dev/loop3 /dev/loop0 /dev/loop2 /dev/loop1
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md42 started.

With this, the data seems to be gone.

# md5sum /dev/md42
01d6d4ce2af6c4d7891aefc96efb9152  /dev/md42
# expected 85febad8a4c2bd97b91e4da882d44b60

Re-create RAID with original drive order and chunk size:

# mdadm --stop /dev/md42
mdadm: stopped /dev/md42
# mdadm --create /dev/md42 --chunk=64 --level=5 --raid-devices=4 /dev/loop0 /dev/loop1 /dev/loop2 /dev/loop3
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md42 started.
# md5sum /dev/md42
85febad8a4c2bd97b91e4da882d44b60  /dev/md42

Data is back.

So a wrong re-create does not necessarily harm your data. 
But it depends. If the RAID wasn't in sync before, or you 
re-created in a way that will cause the on disk data to 
actually change from the original layout, then it might 
not be possible to do a recovery anymore.

Whatever you do, use overlays for recovery experiments.
(This is mentioned in the StackExchange answer I linked above.)

It would help if you had mdadm --examine output of your 
original RAID layout, otherwise you can just trial & error, 
or try to deduce correct RAID structure from raw data.

Regards
Andreas Klauer
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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