Assembling Linux software partitions

I thought there was an easier way to do this but perhaps I have forgotten. I am a fan of Linux software RAID because of the fact you can transport the drives to other systems without having to worry about hardware RAID compatibility. Linux software RAID 1 also possesses good performance and reliability. However, sometimes you need to repair file system damage or create an image of the filesystem or perform other tasks needing the arrays to be accessible from either a Live CD or from another system. Here’s how I accomplished this recently.

The drive in question had 3 RAID 1 partitions (I believe /boot, swap, and /). To assemble and run the arrays I ran the following commands:

  • mdadm --assemble --run /dev/md0 /dev/sdb1
    mdadm: /dev/md0 has been started with 1 drive (out of 2).
  • mdadm --assemble --run /dev/md1 /dev/sdb2
    mdadm: /dev/md1 has been started with 1 drive (out of 2).
  • mdadm --assemble --run /dev/md2 /dev/sdb3
    mdadm: /dev/md2 has been started with 1 drive (out of 2).

I was then able to mount the md devices. This was on a machine without RAID in which I had attached the drive via a USB enclosure. I assume it would work even if the md device numbers were not the same as the original drive but I did not test that. I had thought there was a way to do this more easily but the scan option seems to only check the config file, which of course is not helpful in these situations at all.

Trackback URL for this post:

http://hightechsorcery.com/trackback/161
Creative Commons License Except where otherwise noted, content on this site is licensed under a Creative Commons by-nc-sa 3.0 License