In this lesson, you will learn how to safely detach a software RAID array from one Linux host and migrate it to another without losing your data.
When you move physical drives that contain a RAID array between servers, the operating system does not automatically "know" they belong together. To ensure a smooth migration, you must treat the array as a discrete unit of storage that needs to be cleanly unmounted and identified.
Preparing for Export
Before physically removing drives, you must stop the array to ensure all data in the system cache is flushed to the disks and the RAID metadata is finalized.
- Unmount the filesystem:
sudo umount /mnt/my_raid_data - Stop the array:
sudo mdadm --stop /dev/md0
This command deactivates the array and removes the device entry from the kernel, ensuring no pending write operations are interrupted when you unplug the cables.
Importing on a New Host
Once you have moved the disks to the new machine, the kernel will detect the RAID superblocks during boot or scan, but it might not assemble the array automatically if the configuration files (mdadm.conf) don't match. To manually import and assemble the array, use the assemble flag:
sudo mdadm --assemble --scan
The --scan option tells mdadm to look for arrays defined in the /etc/mdadm/mdadm.conf file. If the array does not appear because it is a new environment, you can point to the specific devices directly:
sudo mdadm --assemble /dev/md0 /dev/sdb1 /dev/sdc1
After the assembly is successful, verify the status with cat /proc/mdstat or sudo mdadm --detail /dev/md0. If everything looks healthy—showing a status of clean—you can mount the filesystem normally.
The primary risk during this process is failing to stop the array before disconnection, which can leave the RAID metadata in an inconsistent state, potentially triggering a forced "check" or "resync" upon import. Always ensure the array is stopped cleanly before pulling the drives.
Key Takeaway: Exporting a RAID array requires cleanly unmounting the filesystem and stopping the device via mdadm --stop, while importing relies on mdadm --assemble to re-scan the superblocks on the migrated drives.