Join already setup software raid

When moving disks from one host to another, I wanted to join the raid already setup on the disks.

On the new host ensure mdadm is already installed.

$ sudo apt-get install mdadm

Scan for the raid:

$ sudo mdadm --detail --scan

Check that it was found successfully.

Persist the found raid in /etc/mdadm/mdadm.conf:

$ sudo mdadm --detail --scan >> /etc/mdadm/mdadm.conf

Update initramfs:

$ sudo update-initramfs -u

Add the raid to /etc/fstab so it’ll be mounted on boot:

/dev/md0 /mnt/md0 ext4 defaults,nofail,discard 0 0