u/Aggravating_Goal1562

Recreating hardware RAID1 array with mdadm on Linux

Hello everyone 😄

I have two 6TB hard disks that I've used with a Buffalo DriveStation Duo USB enclosure up to now, set up as RAID1 (mirroring).

I would like to connect those two disks directly SATA and set up the same RAID1 setup with mdadm on Ubuntu Server 26.04, while preserving all data and not re-syncing anything.

The disks (/dev/sda and /dev/sdb both contain a single ext4 partition that spans over their entire length). These are the outputs of fdisk -l:

michele@michele-server:~$ sudo fdisk -l /dev/sda
The backup GPT table is not on the end of the device.
Disk /dev/sda: 5.46 TiB, 6001175126016 bytes, 11721045168 sectors
Disk model: ST6000VN001-2BB1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: C96AE699-2D21-4DAC-86EF-AB1487CB8F06 Device     Start         End     Sectors  Size Type
/dev/sda1   2048 11718770687 11718768640  5.5T Linux filesystem

michele@michele-server:~$ sudo fdisk -l /dev/sdb
The backup GPT table is not on the end of the device.
Disk /dev/sdb: 5.46 TiB, 6001175126016 bytes, 11721045168 sectors
Disk model: ST6000VN001-2BB1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: C96AE699-2D21-4DAC-86EF-AB1487CB8F06 Device     Start         End     Sectors  Size Type
/dev/sdb1   2048 11718770687 11718768640  5.5T Linux filesystem

Here is also the output of lsblk -f:

michele@michele-server:~$ lsblk -f
NAME                      FSTYPE      FSVER    LABEL   UUID

sda                                
└─sda1                    ext4        1.0      HD-WLU3 9ccd2da9-9064-438d-8129-f7087859be30                   

sdb                               
└─sdb1                    ext4        1.0      HD-WLU3 9ccd2da9-9064-438d-8129-f7087859be30

The disks are completely identical, block by block. Without mounting them, I used the following command to verify it:

cmp /dev/sda /dev/sdb

After several hours, if exited without any console output, with return code 0

I thought I would create the RAID1 array like this, using the --assume-clean flag:

sudo mdadm --create --verbose /dev/md0 --name=hddraid --level=1 --raid-devices=2 --assume-clean /dev/sda1 /dev/sda2

The thing that's mostly bugging me is the --metadata flag. I've been reading this article which compares versions 0.9, 1.0, 1.1 and 1.2. Depending on the version, the mdadm Superblock gets written at the beginning or end of the device. If I already have a filesystem, I'm afraid that this might overwrite something crucial, like a GPT table.

How do I do this right? 😄

reddit.com
u/Aggravating_Goal1562 — 9 days ago