Is it possible to assemble a specific RAID array using mdadm and its scan-functionality, but without the need for a configuration file?

I'm using a custom-made initramfs to setup my system (dm-crypt and other stuff). Everything is done and configured within the init script and that's the way I'd like to keep it, i.e. without any additional config files.

My goal:
Within the init script, I'd like to assemble one specific RAID array using command-line only. The array is identified via its UUID, the md device name is given and array members should be scanned for (since e.g. an attached USB stick or a failed device would mess up /dev/sdX names). All other devices and potential RAID arrays are to be ignored, since during boot only that one array is of interest (carries the root filesystem).

Thoroughly reading mdadm's man page and performing several tests I came up with this:

mdadm --assemble --uuid <uuid> /dev/md0

This seems to be working, but is this the right way to do it?

From the man page:
If precisely one device is listed, but --scan is not given, then mdadm acts as though --scan was given and identity information is extracted from the configuration file.

1 Answer 1


If you know the array UUID, then mdadm --assemble /dev/md0 --uuid <uuid> (note the slight difference in parameter order) will do what you want: scan all unused volumes for ones that have md metadata for the given UUID. Other options:

  • mdadm --assemble /dev/md0 --name <name> (does the same thing as --uuid, but with an array name instead of a UUID.)
  • mdadm --assemble /dev/md0 --super-minor <minor id #> (does the same thing as --uuid, but with minor device numbers in the metadata. Only recommended for version 0.90 metadata.)
  • mdadm --assemble /dev/md0 /dev/disk/by-id/<disk>... (if udev has set up /dev/disk/by-id aliases, which should be static across hardware changes.)
  • mdadm --assemble --scan with no arrays listed in the configuration file (scan all unused volumes for md metadata, and assemble RAID arrays based on what's found. Note that if you've got multiple arrays and only want to set up one of them, or if your array has gotten split, this won't do what you want.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .