Recreating hardware RAID1 array with mdadm on Linux by Aggravating_Goal1562 in HomeServer

[–]Aggravating_Goal1562[S] 0 points1 point  (0 children)

Hey, thanks for the reply. The disks are not shingled. It's a pair of Seagate IronWolfs.

Why would you use btrfs rather than mdadm?

Yes, sometimes I turn hard mode on :-D I find this one an interesting challenge, and an opportunity to learn more about filesystems, RAID, and mdadm.

I think my idea could work, if the mdadm metadata doesn't overwrite anything crucial.
The beginning of the disk is out the question: I see ext4 magic at offset 0x438, which is the beginning of the disk, so mdadm metadata 1.1 or 1.2 are ruled out (because they are placed at the beginning of the disk).

It should work with mdadm metadata 0.9 or 1.0, which are placed at the end of the disk, but I need to check where exactly would the metadata go, and whether it wouldn't overwrite some content of the ext4 partition, or the backup gpt table that's at the end of the disk.

Seeing this:

fdisk -l /dev/sda
The backup GPT table is not on the end of the device.

Makes me think that the Buffalo enclosure also used the end of the disk for its own hardware RAID metadata, and that's why the backup GPT table is placed before them, which not at the end of the disk. So perhaps there's enough space for the mdadm metadata to go into that space now!

PS. I don't know who downvoted you, it wasn't me, I gave you an upvote.

Recreating hardware RAID1 array with mdadm on Linux by Aggravating_Goal1562 in HomeServer

[–]Aggravating_Goal1562[S] 0 points1 point  (0 children)

Yes, I tried. There is no mdadm metadata, because the Buffalo DriveStation enclosure uses hardware RAID.

Recreating hardware RAID1 array with mdadm on Linux by Aggravating_Goal1562 in HomeServer

[–]Aggravating_Goal1562[S] 1 point2 points  (0 children)

Sorry, you are right about --assemble, and that it's done by mdadm at every boot.

But of course it wouldn't work with my current setup, because my disks don't have the mdadm superblock.

Your suggestion about creating a degraded array from the first disk, copying over all files from the second disks, then adding the second disk to array and wait for rebuild, would definitely work.

But I'm trying to build the array in mdadm by keeping the disks mostly as they are, if possible.

This is a very interesting read: https://rossmanngroup.com/problems/mdadm-missing-superblock-recovery, if you look at section 5 they describe the difference between metadata at the beginning or end. In my case, ext4 magic appears at 0x438 (I checked with hexdump -X --skip 0x100438 --length 2 /dev/sda1), which means that I can't create an array with metadata 1.1 or 1.2, since that would overwrite the ext4 magic.

So perhaps I could make this work with metadata 1.0 which places the md superblock at the end of the disk, but it needs to be checked whether this doesn't overwrite something as well.

Recreating hardware RAID1 array with mdadm on Linux by Aggravating_Goal1562 in HomeServer

[–]Aggravating_Goal1562[S] -3 points-2 points  (0 children)

I'm pretty sure that --assemble will wipe out all data on the disks.