MDADM: automount only works with dev, not UUID

fstabmdadm

I am using Arch Linux. I have three functioning RAID arrays via MDADM:

~ cat /etc/mdadm.conf                                                                                                                                                                                                                           
ARRAY /dev/md0 metadata=1.2 name=beast:0 UUID=564fbbac:07f9bbeb:07ef9229:1d8fd77e
ARRAY /dev/md1 metadata=1.2 name=beast:1 UUID=7559b085:3b4715cc:59205fdd:12c0db08
ARRAY /dev/md2 metadata=1.2 name=beast:2 UUID=2dddbf33:26249617:ef8f8b65:c9670bdb

I have three directories in /run/media that I try to automount these mdadm arrays via fstab:

#THE FOLLOWING SHOULD WORK BUT AUTOMOUNT FAILS!!!!!
#UUID=564fbbac:07f9bbeb:07ef9229:1d8fd77e   /run/media/tcarpent/MDADM_SYSRAID   ntfs-3g   auto,user,rw,exec,nofail     0       0
/dev/md0                                    /run/media/tcarpent/MDADM_SYSRAID   ntfs-3g   auto,user,rw,exec,nofail     0       0

#THE FOLLOWING SHOULD WORK BUT AUTOMOUNT FAILS!!!!!
#UUID=7559b085:3b4715cc:59205fdd:12c0db08    /run/media/tcarpent/MDADM_MISCRAID  ext4      auto,user,rw,exec,nofail     0      0
/dev/md1                                      /run/media/tcarpent/MDADM_MISCRAID  ext4      auto,user,rw,exec,nofail     0     0

#THE FOLLOWING SHOULD WORK BUT AUTOMOUNT FAILS!!!!!
#UUID=2dddbf33:26249617:ef8f8b65:c9670bdb    /run/media/tcarpent/MDADM_MEDIARAID ext4     auto,user,rw,exec,nofail     0       0
/dev/md2                                    /run/media/tcarpent/MDADM_MEDIARAID ext4     auto,user,rw,exec,nofail     0    0

Using the commented out UUID lines, automount does not work. I see the drive as 'active but not mounted' in webmin, but am required to mount it, and enter my password, then the drive mounts. However, with the /dev/,,, lines, automount works, no password required.

What gives? I've been told to ALWAYS fstab with UUIDs and never device names so I want to fix this.

Best Answer

The UUID seen in mdadm.conf are related to the MD drivers.

The UUID used in fstab are related to filesytems.

What you need are the filesystem UUID numbers. You can get them with a command line

sudo dumpe2fs /dev/md0 | grep UUID

So in my case:

$ grep md/0 /etc/mdadm/mdadm.conf                                              
ARRAY /dev/md/0 metadata=1.2 UUID=d634adc8:69deedd8:d491a79e:69aeff78

$ sudo dumpe2fs /dev/md0 | grep UUID  
dumpe2fs 1.42.12 (29-Aug-2014)
Filesystem UUID:          195237da-8825-45fb-abf7-a62895bd0967

$ grep boot /etc/fstab
UUID=195237da-8825-45fb-abf7-a62895bd0967 /boot           ext4    defaults        0       2

So we can see the UUID used is the filesystem UUID and not the MD UUID.

Related Question