Why isn't md raid assembled after reboot?

I'm trying to get an Intel RAID setup. The problem I have is that after a reboot the raid is not available.

These are the steps I go through to setup the Intel RAID using the mdadm command. I've followed the steps on http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/rst-linux-paper.pdf.

$ sudo mdadm --detail-platform
   Platform : Intel(R) Matrix Storage Manager
    Version : 12.0.0.1783
RAID Levels : raid0 raid1 raid10 raid5
Chunk Sizes : 4k 8k 16k 32k 64k 128k
2TB volumes : supported
  2TB disks : supported
  Max Disks : 6
Max Volumes : 2 per array, 4 per controller
I/O Controller : /sys/devices/pci0000:00/0000:00:1f.2 (SATA)

$ cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] 
unused devices: <none>

$ sudo mdadm --create /dev/md/imsm /dev/sd[b-c] -n 2 -e imsm
mdadm: container /dev/md/imsm prepared.                                                                                                                                         

$ sudo mdadm --create /dev/md/vol0 /dev/md/imsm -n 2 -l 1                                                                                                                       
mdadm: cannot open device: 11:0
mdadm: array /dev/md/vol0 started.

$ cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] 
md126 : active raid1 sdc[1] sdb[0]
  1953511424 blocks super external:/md127/0 [2/2] [UU]
  [>....................]  resync =  0.4% (8213824/1953511424) finish=192.8min speed=168142K/sec

md127 : inactive sdc[1](S) sdb[0](S)
  2210 blocks super external:imsm

unused devices: <none>

$ sudo mdadm --examine --scan --config=mdadm.conf
ARRAY metadata=imsm UUID=1b6e3d9e:e14f7906:38f86e54:1f85cdcd
ARRAY /dev/md/vol0 container=1b6e3d9e:e14f7906:38f86e54:1f85cdcd member=0 UUID=546b601a:ccfa6f04:2cc1d0f5:aa05edc2

$ sudo vi /etc/mdadm/mdadm.conf
$ cat /etc/mdadm/mdadm.conf
# mdadm.conf
#
# Please refer to mdadm.conf(5) for information about this file.
#

# by default (built-in), scan all partitions (/proc/partitions) and all
# containers for MD superblocks. alternatively, specify devices to scan, using
# wildcards if desired.
#DEVICE partitions containers

# 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
ARRAY metadata=imsm UUID=1b6e3d9e:e14f7906:38f86e54:1f85cdcd
ARRAY /dev/md/vol0 container=1b6e3d9e:e14f7906:38f86e54:1f85cdcd member=0 UUID=546b601a:ccfa6f04:2cc1d0f5:aa05edc2

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
I then rebooted here with the raid working
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

$ cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] 
unused devices: <none>
$ sudo mdadm --assemble --scan
mdadm: Container /dev/md/imsm0 has been assembled with 2 drives
mdadm: Started /dev/md/vol0 with 2 devices
$ cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] 
md126 : active raid1 sdb[1] sdc[0]
  1953511424 blocks super external:/md127/0 [2/2] [UU]
  [>....................]  resync =  4.0% (78945280/1953511424) finish=30274.0min speed=1024K/sec

md127 : inactive sdc[1](S) sdb[0](S)
  6306 blocks super external:imsm

unused devices: <none>

So after running an assemble command the raid is available but why isn't it there after a reboot by default?

The system is running;

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=13.10
DISTRIB_CODENAME=saucy
DISTRIB_DESCRIPTION="Ubuntu 13.10"

$ uname -a
Linux mdk1 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Support for intel fakeraids is new to mdadm in 14.04. Previous Ubuntu releases used dmraid to activate them. Note that unless you are dual booting with Windows, you should avoid the fakeraid stuff entirely and just stick to native mdadm.


For people facing bug #1318351 "mdadm doesn't assemble imsm raids during normal boot" affecting Intel Hardware RAID (imsm) on Ubuntu 14 & 15 at least, this solved the issue:

Edit /etc/default/grub to have:

#GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomdmonddf nomdmonisw"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

Edit /etc/default/grub.d/dmraid2mdadm.cfg to have:

DMRAID2MDADM_TOAPPEND=""

Launch:

sudo dpkg-reconfigure mdadm
sudo update-grub
sudo update-initramfs -u

You can stop here if it solved your problem. Below is to go further.

This of course supposes your /etc/mdadm/mdadm.conf is good. Mine looks like this for a NTFS RAID0:

CREATE owner=MYUSERNAME group=disk mode=0775 auto=yes
MAILADDR root
ARRAY /dev/md0 level=container num-devices=2 metadata=imsm UUID=XXXXXXXX:XXXXXXXX:XXXXXXXX:XXXXXXXX devices=/dev/sdb,/dev/sdc
ARRAY /dev/md1 level=raid0 num-devices=2 container=/dev/md0 member=0 UUID=YYYYYYYY:YYYYYYYY:YYYYYYYY:YYYYYYYY devices=/dev/sdb,/dev/sdc auto=md

It was generated with:

sudo mdadm --assemble --scan
sudo mdadm --detail --scan --verbose

And a bit adapted.

Finally, if disks are properly assembled at boot (visible in Nautilus), you can start to play with /etc/fstab to mount the disk at boot.

Always test your /etc/fstab with this to avoid being stuck at boot:

sudo mount -a

If normal boot fails after fstab edit, then boot in recovery mode and go for the command line:

loadkeys fr
mount -o remount,rw /
pico /etc/fstab

fr for french keyboards.


Add

auto=md

to the proper ARRAY line in mdadm.conf:

Before:

ARRAY /dev/md/vol0 container=1b6e3d9e:e14f7906:38f86e54:1f85cdcd member=0    UUID=546b601a:ccfa6f04:2cc1d0f5:aa05edc2

After:

ARRAY /dev/md/vol0 container=1b6e3d9e:e14f7906:38f86e54:1f85cdcd member=0 UUID=546b601a:ccfa6f04:2cc1d0f5:aa05edc2 auto=md

In my case, i'm not using containers (as in the Intel paper), so i have only one line where i also specify the metadata format, as below:

ARRAY /dev/md/hdd level=raid10 metadata=1.0 num-devices=4 UUID=462b55f7:e09bc196:deb847c4:b6be609c name=hdd auto=md

In md, raid names only work with metadata 1.0 or higher. Hope this help.


I got the same problem with a fake bios raid. Since my raid is needed to boot, I had to put a script in /usr/share/initramfs-tools/scripts/init-premount to assemble the raid:

#!/bin/sh
mdadm --assemble --scan

Then I update the initram by running the command:

update-initramfs -u

I try to make my raid work with dmraid but only the raid0 set was working. raid5 seems to work only with mdadm. However with Ubuntu 12.04 both raid set was working with dmraid.