LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Recover mdadm raid1 data after recreate new array over old (http://www.linuxquestions.org/questions/linux-general-1/recover-mdadm-raid1-data-after-recreate-new-array-over-old-918212/)

Murz 12-11-2011 02:46 PM

Recover mdadm raid1 data after recreate new array over old
 
I had the raid1 (mirror) mdadm working array /dev/md1 with one failed disk, so /dev/sda5 is active and /dev/sdb5 is missing (partition is deleted), and I try to mark second drive as failed.
But I do the mistake: create new array over old data instead of run:
Code:

# mdadm --stop /dev/md1
# mdadm --create /dev/md1 /dev/sda5 ...
instead of
# mdadm --assemble /dev/md1
or
# mdadm --run /dev/md1

So, this create command overwrite the superblock and other info about old md1 array.
How can I recover data from old md1 array now?

smallpond 12-13-2011 11:12 AM

Quote:

Originally Posted by Murz (Post 4547339)
I had the raid1 (mirror) mdadm working array /dev/md1 with one failed disk, so /dev/sda5 is active and /dev/sdb5 is missing (partition is deleted), and I try to mark second drive as failed.
But I do the mistake: create new array over old data instead of run:
Code:

# mdadm --stop /dev/md1
# mdadm --create /dev/md1 /dev/sda5 ...
instead of
# mdadm --assemble /dev/md1
or
# mdadm --run /dev/md1

So, this create command overwrite the superblock and other info about old md1 array.
How can I recover data from old md1 array now?

This post:
http://kevin.deldycke.com/2007/03/ho...d-superblocks/

claims that if you recreate your original RAID correctly, that the content will not be destroyed.
Before doing anything it would be a good idea to make a binary copy of the whole partitions and only work on the copies. Something like:

Code:

dd if=/dev/sda5 of=/dev/sdz1 bs=1m

Murz 12-15-2011 06:04 AM

Quote:

Originally Posted by smallpond (Post 4548830)
This post:
http://kevin.deldycke.com/2007/03/ho...d-superblocks/

claims that if you recreate your original RAID correctly, that the content will not be destroyed.

Thanks, I recreate my raid, but after that it don't want to mount correctly. But I run fsck /dev/md1, it found and recover many errors, but after that I correctly mount it and see my files.
I found info that mdadm metadata version 0.90 save superblock at end of drive, but 1.2 version - at first of drive, so after I create over old mdadm 0.90 mdraid new 1.2 mdraid, it rewrite the start of ext3 filesystem. But fsck found copies and recover it.


All times are GMT -5. The time now is 04:08 AM.