How to Migrate Linux Software RAID to New Machine Without Original Config Files


2 views

When moving a Linux software RAID array between machines, the physical disk order and component recognition are crucial. In this case, we have:

  • Original RAID 5 array with 4 IDE disks
  • Disks connected via PCI controllers (hde1, hdg1, etc.)
  • Kernel detects devices but no original mdadm.conf
  • Array status verified as clean via mdadm --examine

Here's how to safely reassemble the array on the new Gentoo system:


# First, check current disk status
mdadm --examine /dev/hde1
mdadm --examine /dev/hdg1
# (Repeat for all array members)

# Verify superblock information matches across devices

Since we know the device order and RAID level, we can use:


# Assemble the array in --readonly mode first for safety
mdadm --assemble --readonly /dev/md0 /dev/hde1 /dev/hdg1 /dev/hdh1 /dev/hdi1

# Verify data integrity before committing
mount -o ro /dev/md0 /mnt/temp
ls -l /mnt/temp
umount /mnt/temp

Once verified, perform the permanent assembly:


# Stop the readonly array
mdadm --stop /dev/md0

# Full assembly with write access
mdadm --assemble --run /dev/md0 /dev/hde1 /dev/hdg1 /dev/hdh1 /dev/hdi1

# Generate new config
mdadm --detail --scan >> /etc/mdadm.conf

# Update initramfs (on Gentoo)
emerge -av sys-fs/mdadm
mkinitramfs -o /boot/initramfs-$(uname -r).img $(uname -r)

Check array status after assembly:


cat /proc/mdstat
mdadm --detail /dev/md0

If devices show as spares or don't join properly:


# Force assembly with --force when necessary
mdadm --assemble --force /dev/md0 /dev/hde1 /dev/hdg1 /dev/hdh1 /dev/hdi1
  • Update /etc/fstab with new UUID if needed (use blkid)
  • Check dmesg for any disk errors during assembly
  • Consider running filesystem check if array was unclean

You've got a working Linux software RAID 5 array from an old machine, consisting of 4 IDE disks connected via PCI controllers. After moving both the controllers and disks to a new Gentoo Linux machine, the drives are detected, but you lack the original RAID configuration files. Here's how to safely reassemble the array.

First, confirm your kernel detects the disks correctly. Run:

lsblk
# or
fdisk -l

You should see your IDE disks (likely appearing as /dev/hde, /dev/hdg, etc.) with their RAID partitions.

Use mdadm to inspect each component device:

mdadm --examine /dev/hde1
mdadm --examine /dev/hdg1
# ... repeat for all member disks

Look for these key indicators:

  • "Device UUID" matching across all disks
  • Consistent "Events Count"
  • RAID level (in your case, level 5)
  • Clean/dirty state (preferably clean)

With the information from --examine, reassemble the array:

mdadm --assemble --verbose /dev/md0 /dev/hde1 /dev/hdg1 /dev/hdh1 /dev/hdi1 \
    --level=5 --raid-devices=4

Key parameters:

  • /dev/md0: The array device to create
  • Component devices: List all your RAID partitions
  • --level: Matches your RAID 5
  • --raid-devices: Total number of disks (4 in your case)

If you encounter "unsafe shutdown" warnings:

mdadm --assemble --force /dev/md0 /dev/hde1 /dev/hdg1 /dev/hdh1 /dev/hdi1

For arrays that won't start cleanly, try:

mdadm --create /dev/md0 --level=5 --raid-devices=4 \
    /dev/hde1 /dev/hdg1 /dev/hdh1 /dev/hdi1 \
    --assume-clean

Warning: Only use --assume-clean if you're absolutely certain the array was clean before shutdown.

Once the array is running, save the configuration:

mdadm --detail --scan >> /etc/mdadm/mdadm.conf
# On some distributions:
mdadm --detail --scan >> /etc/mdadm.conf

Update your initramfs to include the new configuration:

update-initramfs -u
# Or on Gentoo:
genkernel --mdadm initramfs

After assembly, check the array status:

cat /proc/mdstat
mdadm --detail /dev/md0

Consider running a filesystem check if you're using ext*:

e2fsck -f /dev/md0

For IDE-based arrays, you might want to tweak kernel parameters:

echo 32768 > /sys/block/md0/md/stripe_cache_size
echo 2048 > /sys/block/md0/queue/max_sectors_kb

Monitor performance with:

iostat -xm 1