I ran accidentally "mdadm --create /dev/sda2 /dev/sdb2" on an existing raid 1

Using TestDisk to repair the filesystem
Forum rules
When asking for technical support:
- Search for posts on the same topic before posting a new question.
- Give clear, specific information in the title of your post.
- Include as many details as you can, MOST POSTS WILL GET ONLY ONE OR TWO ANSWERS.
- Post a follow up with a "Thank you" or "This worked!"
- When you learn something, use that knowledge to HELP ANOTHER USER LATER.
Before posting, please read https://www.cgsecurity.org/testdisk.pdf
Locked
Message
Author
Fisher
Posts: 2
Joined: 02 May 2020, 14:03

I ran accidentally "mdadm --create /dev/sda2 /dev/sdb2" on an existing raid 1

#1 Post by Fisher »

Hi,

I am desperately looking for a help to recover a partition. I have 2 identical HDDs (1 TB, each) mounted as RAID 1. Accidentally, I ran mdadm --create /dev/md2 --level=raid1 --raid-devices=2 /dev/sda2 /dev/sdb2 over an existing RAID 1 (Ext4 file system). After that I cannot mount /dev/md2 (even /dev/sda2 nor /dev/sdb2). It results in:
mount: wrong fs type, bad option, bad superblock on /dev/sdb1,
missing codepage or helper program, or other error
I tried dumpe2fs and fsck, but here is not valid superblocks (I tried all superblock found by dumpe2fs) and they did not able to repair the file system.

Is there any way to revert what I have done or repair the file system?

Thank you.

User avatar
cgrenier
Site Admin
Posts: 5432
Joined: 18 Feb 2012, 15:08
Location: Le Perreux Sur Marne, France
Contact:

Re: I ran accidentally "mdadm --create /dev/sda2 /dev/sdb2" on an existing raid 1

#2 Post by cgrenier »

You should try to mount /dev/md2 but the error message shows /dev/sdb1...
Depending of the version of the logical raid (0.9, 1.0, 1.1 or 1.2), the raid metadata aren't stored at the same location:
- 0.9: at the end of the disk
- 1.0: at the end of the disk
- 1.1: at the beginning of the disk
- 1.2: 4096 bytes
For md raid 1.1 and 1.2, if you want to mount a single disk of the raid, you should mount it in read-only and use an offset, something like mount -o loop,offset=4096,ro /dev/sdb1 /mnt/tmp (or 8096)

Fisher
Posts: 2
Joined: 02 May 2020, 14:03

Re: I ran accidentally "mdadm --create /dev/sda2 /dev/sdb2" on an existing raid 1

#3 Post by Fisher »

cgrenier,

Thank you for quick reply.
cgrenier wrote: 03 May 2020, 07:53 You should try to mount /dev/md2 but the error message shows /dev/sdb1...
Sorry, I made a mistake with typing. The actual partition is /dev/sdb2.
cgrenier wrote: 03 May 2020, 07:53 Depending of the version of the logical raid (0.9, 1.0, 1.1 or 1.2), the raid metadata aren't stored at the same location:
- 0.9: at the end of the disk
- 1.0: at the end of the disk
- 1.1: at the beginning of the disk
- 1.2: 4096 bytes
For md raid 1.1 and 1.2, if you want to mount a single disk of the raid, you should mount it in read-only and use an offset, something like mount -o loop,offset=4096,ro /dev/sdb1 /mnt/tmp (or 8096)
The logical raid version is 1.2:

Code: Select all

/dev/sdb2:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x1
     Array UUID : 7537c8c8:9c7db3b4:cfbbc926:4a3b3cde
           Name : papi.yum:2  (local to host papi.yum)
  Creation Time : Tue Apr 28 21:07:20 2020
     Raid Level : raid1
   Raid Devices : 2

 Avail Dev Size : 1876686848 (894.87 GiB 960.86 GB)
     Array Size : 938343424 (894.87 GiB 960.86 GB)
    Data Offset : 264192 sectors
   Super Offset : 8 sectors
   Unused Space : before=264112 sectors, after=0 sectors
          State : clean
    Device UUID : fdf65483:92bdb055:c2290591:8839a363

Internal Bitmap : 8 sectors from superblock
    Update Time : Tue Apr 28 22:58:12 2020
  Bad Block Log : 512 entries available at offset 16 sectors
       Checksum : 6d57c235 - correct
         Events : 1350


   Device Role : Active device 0
   Array State : AA ('A' == active, '.' == missing, 'R' == replacing)
The raid was stopped to preserve data.

I tried mount -o loop,offset=4096,ro /dev/sda2 /mnt/, but it retorned:

Code: Select all

# mount -o loop,offset=4096,ro /dev/sda2 /mnt/
mount: /mnt: wrong fs type, bad option, bad superblock on /dev/loop0, missing codepage or helper program, or other error.
(*) /dev/sda2 is mirror of /dev/sdb2. PhotoRec is running on /dev/sdb2 and it will take 39h (estimated).

Locked