I have a RAID-1 mirror setup with 2 external USB drives. The drives are only powered on just before a backup, and powered off when I'm done.
How do I configure linux to automatically assemble the RAID and mount the drives when they are powered up.
The manual process I follow is:
1. Power on the drives.
2. Determine the device files with
fdisk -l | grep raid
/dev/sdc1 1 60801 488384001 fd Linux raid autodetect
/dev/sdd1 1 60801 488384001 fd Linux raid autodetect
3. Assemble the array with
mdadm --assemble /dev/md0 /dev/sdc1 /dev/sdd1
4. Finally, I mount the array with
mount /dev/md0 /mnt/md0
I tried using UDEV rules to create specific device files. However, the mdadm utility complains that the files don't have valid superblock. So mdadm only works with the actual device file as listed above.
I could easily write a script to do this for me. However, the script would only work after both drives have powered on an initialized. Usually, it takes 20 seconds after powering them on, before I can see the drives with 'fdisk -l'.