Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I successfully created a RAID (mirroring) by utilizing mdadm. However, I must run the following commands after each boot:

mdadm --stop --scan // to stop /dev/md127 - I don't know where the number 127 even comes from
mdadm --assemble --scan // to start /dev/md0

What am I doing wrong/why do I need to run these commands at boot? What is the right way to auto-start RAID with each (re)boot?

share|improve this question

3 Answers 3

up vote 19 down vote accepted

NB: You either need to be logged in as root, or use sudo to do all this...

  • Use your favourite editor to create or edit /etc/mdadm/mdadm.conf file as follows:

If the file does not even exist, paste the following into the new, empty file:

# mdadm.conf
#
# Please refer to mdadm.conf(5) for information about this file.
#

DEVICE partitions

# auto-create devices with Debian standard permissions
CREATE owner=root group=disk mode=0660 auto=yes

# automatically tag new arrays as belonging to the local system
HOMEHOST <system>

# instruct the monitoring daemon where to send mail alerts
MAILADDR root

# definitions of existing MD arrays
  • Save the file

  • Run the following command to add a reference to your array config at the end of the file:

    mdadm --detail --scan >> /etc/mdadm/mdadm.conf

This should add a line like the following to the end of mdadm.conf:

ARRAY /dev/md0 level=raid5 num-devices=3 metadata=00.90 UUID=a44a52e4:0211e47f:f15bce44:817d167c

If the mdadm command has added any other stuff above the ARRAY line, remove it. For example, on one of my machines, the command returns 'mdadm: metadata format 00.90 unknown, ignored.' before the ARRAY line.

Your array should now auto-build on boot and thus you can add an entry to /etc/fstab to mount it (if it's not already there)

share|improve this answer
3  
I would maybe add: you should also update your initramfs with update-initramfs -u –  Pablo Montepagano Oct 19 '12 at 3:08
    
mdadm --detail --scan does not print anything on my system, although I know for sure that I have two partitions that are part of a raid0 (mirror). Any general advice on this is welcome. –  Lennart Rolland Mar 14 at 13:59

I realize this is an older question, but I had a frustrating time with this on the 32-bit version of Ubuntu Server 12.04.

Running mdadm --detail --scan >> /etc/mdadm/mdadm.conf appended the line

ARRAY /dev/md0 metadata=1.2 name=ubuntu:0 UUID=a8a570c6:96f61865:05abe131:5c2e2f7e

After a reboot I could never see /dev/md0. Running the mdadm --detail --scan again (without putting the result in a file) I would see

ARRAY /dev/md/ubuntu:0 metadata=1.2 name=ubuntu:0 UUID=a8a570c6:96f61865:05abe131:5c2e2f7e

and manually mounting /dev/md/ubuntu:0 would work. In the end, that was what I put in the fstab file too.

I am not sure what I got wrong, if this is how it works in Ubuntu 12.04, or if this is a bad practice. Just wanted to share what worked for me.

share|improve this answer

On Debian wheezy one more step is required: in /etc/default/mdadm set autostart from false to true

#AUTOSTART:
#   should mdadm start arrays listed in /etc/mdadm/mdadm.conf automatically
#   during boot?
AUTOSTART=true

Also I had to use mdadm -Es >>/etc/mdadm/mdadm.conf instead of the --scan option, as that did not work for me.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.