The following might be helpful to others too. I was trying to setup a new raid1 device from two partitions /dev/sda4 and /dev/sdb4. I wanted to do this the “right way” and use UUID everywhere, i.e. in /etc/mdadm/mdadm.conf and in /etc/fstab.

I hit a few snags along the way.

create the array

# mdadm --create --verbose /dev/md6 --level=1 --raid-devices=2 \
/dev/sda4 /dev/sdb4

Get the uuid mdadm uses:

# mdadm --detail  /dev/md6 | grep UUID
  UUID : dc9aba5e:ed1a70d4:770765d8:b0f56d86 (local to host elektron2)

Check. Add that to /etc/mdadm/mdadm.conf:

# grep md6 < /etc/mdadm/mdadm.conf
ARRAY /dev/md6 level=raid1 num-devices=2 UUID=dc9aba5e:ed1a70d4:770765d8:b0f56d86

Okay, that should take care of the array. Now I wanted to get it into the fstab


The magic command here is blkid. Let’s run it:

# blkid | grep md6

Huh, nothing…. hmmm. Okay maybe because there is no filesystem on it, it won’t show up?

# mke2fs -j /dev/md0
# blkid | grep md6
/dev/md6: UUID="d4776336-0d4c-42e6-9b7f-a668522f3f40" SEC_TYPE="ext2" TYPE="ext3" 

Great, that did the trick. The UUID you see here can be put in fstab. It is a completely different one than mdadm uses.

I’ve added the following to the fstab

# /dev/md6
UUID=d4776336-0d4c-42e6-9b7f-a668522f3f40 /vol ext3 relatime  0  2

Ok, lets mount it:

# mount /vol
mount: special device /dev/disk/by-uuid/d4776336-0d4c-42e6-9b7f-a668522f3f40 does not exist

WTF? So blkid is spitting out a UUID and udev hasn’t updated the links in /dev…. okay. Some helpfull bug reports , here and here.

The one from Debian had the missing command:

# echo add > /sys/block/md6/uevent

And low and behold, the symlink shows up in /dev/disk/by-uuid/

# mount /vol
# cd /vol
# ls