# dmraid, no automount during boot with newer kernel

## hoacker

Hi there. 

I have a raid 1 array of two (USB) drives set up and running for quite some time. When I use a kernel newer than gentoo-3.7.10 the raid array does not automount during boot.

Kernel 3.7.10:

I have /dev/md127. In /etc/fstab a line assigns /dev/md127 to /mnt/raid. The raid automounts during boot.

Kernel 3.10.x and 3.12.12:

I have /dev/md1. I changed /etc/fstab to automount /dev/md1 to /mnt/raid. I can manually mount /dev/md1 and the files are showing in /mnt/raid. But the array is not mounted during boot.

I already tried to manually add an entry for /dev/md1 and it's UUID to /etc/conf.d/mdadm with no success. 

What is going wrong here? What more info do you need? Any help appreciated.

----------

## hoacker

Nobody?

I have just made a backup of the files on the raid. I'm going to rebuild the raid from scratch and hope that it automounts again.   :Sad: 

----------

## Goverp

FWIW, kernel automounting has been deprecated for some time.  You're supposed to use an initramfs.  AFAIK automounting is still expected to work, and people (not me) still use it successfully.

----------

## hoacker

 *Goverp wrote:*   

> FWIW, kernel automounting has been deprecated for some time.  You're supposed to use an initramfs.  AFAIK automounting is still expected to work, and people (not me) still use it successfully.

 

Thank you.

The raid does not contain the root file system or anything that is needed during boot. There's only user data on it. The device is supposed to mount via an fstab entry. I'd prefer not to use an initramfs. Maybe I'll just write a little script to mount it later in the boot process...

----------

## NeddySeagoon

hoacker,

Is mdraid in the default runlevel?

Is your mdraid.conf correct ?

For the kernel to start your raid during boot, you need all the USB support built in.

As your raid is only user data, an initrd is not required.

----------

## hoacker

Hi NeddySeagoon.

Mdadm is in default runlevel. I had no DEVICE or ARRAY entry in mdraid.conf until yesterday, automount worked anyway with older kernel.

Two identical USB drives are connected to the machine. Mdadm says the follwing:

```
# mdadm --detail --scan

ARRAY /dev/md/1 metadata=1.2 name=steward:1 UUID=716584c8:65b663cb:efc4803d:0c6517f7

```

With kernel 3.7.10 the device /dev/md127 is detected and mounted (xfs). There is an entry in /etc/fstab for automount of /dev/md127 to /mnt/raid.

Here's snippet from /dev/log/messages with 3.7.10, the two TekStor are the raid devices:

```
Apr 12 19:05:25 localhost kernel: md: raid0 personality registered for level 0

Apr 12 19:05:25 localhost kernel: md: raid1 personality registered for level 1

Apr 12 19:05:25 localhost kernel: md: raid10 personality registered for level 10

Apr 12 19:05:25 localhost kernel: md: raid6 personality registered for level 6

Apr 12 19:05:25 localhost kernel: md: raid5 personality registered for level 5

Apr 12 19:05:25 localhost kernel: md: raid4 personality registered for level 4

Apr 12 19:05:25 localhost kernel: device-mapper: ioctl: 4.23.0-ioctl (2012-07-25) initialised: dm-devel@redhat.com

[..]

Apr 12 19:05:25 localhost kernel: md: Waiting for all devices to be available before autodetect

Apr 12 19:05:25 localhost kernel: md: If you don't use raid, use raid=noautodetect

Apr 12 19:05:25 localhost kernel: md: Autodetecting RAID arrays.

Apr 12 19:05:25 localhost kernel: md: Scanned 0 and added 0 devices.

Apr 12 19:05:25 localhost kernel: md: autorun ...

Apr 12 19:05:25 localhost kernel: md: ... autorun DONE.

[..]

Apr 12 19:05:25 localhost kernel: usb 2-3: new high-speed USB device number 4 using ehci_hcd

Apr 12 19:05:25 localhost kernel: scsi8 : usb-storage 2-3:1.0

Apr 12 19:05:25 localhost kernel: scsi 3:0:0:0: Direct-Access     TrekStor DS maxi Xpress   0001 PQ: 0 ANSI: 6

Apr 12 19:05:25 localhost kernel: sd 3:0:0:0: Attached scsi generic sg2 type 0

Apr 12 19:05:25 localhost kernel: scsi 4:0:0:0: Direct-Access     TrekStor DS maxi Xpress   0001 PQ: 0 ANSI: 6

Apr 12 19:05:25 localhost kernel: sd 4:0:0:0: Attached scsi generic sg3 type 0

Apr 12 19:05:25 localhost kernel: md: bind<sdb1>

Apr 12 19:05:25 localhost kernel: sdc: sdc1

Apr 12 19:05:25 localhost kernel: sd 4:0:0:0: [sdc] No Caching mode page present

Apr 12 19:05:25 localhost kernel: sd 4:0:0:0: [sdc] Assuming drive cache: write through

Apr 12 19:05:25 localhost kernel: sd 4:0:0:0: [sdc] Attached SCSI disk

Apr 12 19:05:25 localhost kernel: md: bind<sdc1>

Apr 12 19:05:25 localhost kernel: md/raid1:md127: active with 2 out of 2 mirrors

Apr 12 19:05:25 localhost kernel: md127: detected capacity change from 0 to 2000395101184

Apr 12 19:05:25 localhost kernel: md127: unknown partition table

Apr 12 19:05:25 localhost kernel: XFS (md127): Mounting Filesystem

Apr 12 19:05:25 localhost kernel: XFS (md127): Ending clean mount
```

With kernel 3.10 or 3.12 the device /dev/md127 does not show, it's /dev/md1 instead. I changed fstab accordingly. After boot there's no automounted raid array, but manual mount works fine.

I've added the following lines to mdraid.conf:

```
DEVICE /dev/sd[bcdefghi]1

ARRAY /dev/md1 uuid=716584c8:65b663cb:efc4803d:0c6517f7

```

The snippet from /var/log/messages with kernel 3.12:

```
Apr 12 18:47:08 localhost kernel: md: raid0 personality registered for level 0

Apr 12 18:47:08 localhost kernel: md: raid1 personality registered for level 1

Apr 12 18:47:08 localhost kernel: md: raid10 personality registered for level 10

Apr 12 18:47:08 localhost kernel: md: raid6 personality registered for level 6

Apr 12 18:47:08 localhost kernel: md: raid5 personality registered for level 5

Apr 12 18:47:08 localhost kernel: md: raid4 personality registered for level 4

Apr 12 18:47:08 localhost kernel: device-mapper: ioctl: 4.26.0-ioctl (2013-08-15) initialised: dm-devel@redhat.com

Apr 12 18:47:08 localhost kernel: device-mapper: raid: Loading target version 1.5.2

Apr 12 18:47:08 localhost kernel: usb 1-2: new high-speed USB device number 2 using ehci-pci

[..]

Apr 12 18:47:08 localhost kernel: usb 1-3: new high-speed USB device number 3 using ehci-pci

[..]

Apr 12 18:47:08 localhost kernel: usb 1-4: new high-speed USB device number 4 using ehci-pci

[..]

Apr 12 18:47:08 localhost kernel: usb-storage 2-1:1.0: USB Mass Storage device detected

Apr 12 18:47:08 localhost kernel: scsi6 : usb-storage 2-1:1.0

Apr 12 18:47:08 localhost kernel: usb 2-2: new high-speed USB device number 3 using ehci-pci

Apr 12 18:47:08 localhost kernel: ata3: SATA link down (SStatus 0 SControl 300)

Apr 12 18:47:08 localhost kernel: md: Waiting for all devices to be available before autodetect

Apr 12 18:47:08 localhost kernel: md: If you don't use raid, use raid=noautodetect

Apr 12 18:47:08 localhost kernel: md: Autodetecting RAID arrays.

Apr 12 18:47:08 localhost kernel: md: Scanned 0 and added 0 devices.

Apr 12 18:47:08 localhost kernel: md: autorun ...

Apr 12 18:47:08 localhost kernel: md: ... autorun DONE.

Apr 12 18:47:08 localhost kernel: usb-storage 2-2:1.0: USB Mass Storage device detected

Apr 12 18:47:08 localhost kernel: scsi7 : usb-storage 2-2:1.0

Apr 12 18:47:08 localhost kernel: usb 2-3: new high-speed USB device number 4 using ehci-pci

Apr 12 18:47:08 localhost kernel: usb-storage 2-3:1.0: USB Mass Storage device detected

Apr 12 18:47:08 localhost kernel: scsi8 : usb-storage 2-3:1.0

Apr 12 18:47:08 localhost kernel: scsi 3:0:0:0: Direct-Access     TrekStor DS maxi Xpress   0001 PQ: 0 ANSI: 6

Apr 12 18:47:08 localhost kernel: sd 3:0:0:0: Attached scsi generic sg2 type 0

Apr 12 18:47:08 localhost kernel: scsi 4:0:0:0: Direct-Access     TrekStor DS maxi Xpress   0001 PQ: 0 ANSI: 6

Apr 12 18:47:08 localhost kernel: sd 4:0:0:0: Attached scsi generic sg3 type 0

Apr 12 18:47:08 localhost kernel: scsi 5:0:0:0: Direct-Access     Generic- Multi-Card       1.00 PQ: 0 ANSI: 0 CCS

Apr 12 18:47:08 localhost kernel: sd 5:0:0:0: Attached scsi generic sg4 type 0

Apr 12 18:47:08 localhost kernel: sd 5:0:0:0: [sdd] Attached SCSI removable disk

Apr 12 18:47:08 localhost kernel: Switched to clocksource tsc

Apr 12 18:47:08 localhost kernel: usb 7-2: new low-speed USB device number 2 using uhci_hcd

Apr 12 18:47:08 localhost kernel: scsi 6:0:0:0: Direct-Access     SAMSUNG  HD501LJ               PQ: 0 ANSI: 2 CCS

Apr 12 18:47:08 localhost kernel: sd 6:0:0:0: Attached scsi generic sg5 type 0
```

----------

## NeddySeagoon

hoacker,

With 

```
metadata=1.2 
```

the kernel will not auto assemble your raid.  That has only works with  metadata=0.9.

Indeed ,

```
Apr 12 19:05:25 localhost kernel: md: If you don't use raid, use raid=noautodetect

Apr 12 19:05:25 localhost kernel: md: Autodetecting RAID arrays.

Apr 12 19:05:25 localhost kernel: md: Scanned 0 and added 0 devices.

Apr 12 19:05:25 localhost kernel: md: autorun ...

Apr 12 19:05:25 localhost kernel: md: ... autorun DONE. 
```

shows your USB raid not being assembled by the kernel.

That snippet is the same in 3.12.

It follows that its not a kernel raid auto assembly issue.  

When you use 3.7.10 something prods mdadm to assemble your raid.

That manual mounting works with the later kernel suggests that the raid is assembled, even though there is nothing in dmesg.

Reboot a problem kerenel.  Do not do the manual mount. Post the content of /proc/mdstat

----------

## hoacker

 *NeddySeagoon wrote:*   

> Do not do the manual mount. Post the content of /proc/mdstat

 

Here we go:

 *Quote:*   

> # cat /proc/mdstat
> 
> Personalities : [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] 
> 
> md1 : active raid1 sdc1[1] sdb1[2]
> ...

 

----------

## NeddySeagoon

hoacker,

That shows /dev/md1 correctly assembled.

What does 

```
rc-update show
```

 produce?

I'm thinking of moving mdadm to the boot runlevel, or making everything needed for usb-storage as built into the kernel, so usb-storage works before you can load modules.

----------

## hoacker

Moving mdadm to boot runlevel makes no difference, tried both. I think I have compile relevant USB options into the kernel. If uploaded .config to pastebin if you would like to have a look. http://pastebin.com/7KTdRbws

```
# rc-update

                acpid |      default                                  

              apache2 |      default                                  

             bootmisc | boot                                          

            clamsmtpd |      default                                  

          consolefont | boot                                          

         cpufrequtils |      default                                  

                cupsd |      default                                  

                devfs |                                        sysinit

                dhcpd |      default                                  

                dmesg |                                        sysinit

              dovecot |      default                                  

                 fsck | boot                                          

             hostname | boot                                          

              hwclock | boot                                          

           irqbalance |      default                                  

              keymaps | boot                                          

            killprocs |                        shutdown               

                local |      default nonetwork                        

           localmount | boot                                          

             loopback | boot                                          

                mdadm | boot                                          

              modules | boot                                          

             mount-ro |                        shutdown               

                 mtab | boot                                          

                mysql |      default                                  

                named |      default                                  

               net.lo | boot                                          

             netmount |      default                                  

                  nfs |      default                                  

                 ntpd |      default                                  

              postfix |      default                                  

       postgresql-9.1 |      default                                  

               procfs | boot                                          

                 root | boot                                          

               rsyncd |      default                                  

                samba |      default                                  

            saslauthd |      default                                  

            savecache |                        shutdown               

                spamd |      default                                  

                 sshd |      default                                  

             svnserve |      default                                  

                 swap | boot                                          

            swapfiles | boot                                          

               sysctl | boot                                          

                sysfs |                                        sysinit

            syslog-ng |      default                                  

         termencoding | boot                                          

           timekeeper |      default                                  

         tmpfiles.dev |                                        sysinit

       tmpfiles.setup | boot                                          

                 udev |                                        sysinit

           udev-mount |                                        sysinit

              urandom | boot                                          

            usettings |      default                                  

           vixie-cron |      default
```

----------

## NeddySeagoon

hoacker,

That looks good.

Put mdadm back into the default runlevel.

Post your /etc/fstab.  You could try the bg option on your /devmd1.  I'm not sure if it would be valid, or if its only good for nfs.

See man mount

----------

## hoacker

```
XFS (md1): unknown mount option [bg]
```

I can't find a similar option for xfs.

The fstab entry:

```
/dev/md1        /mnt/raid               xfs             auto         0 0
```

----------

## NeddySeagoon

hoacker,

I think what's happening is that your raid in not assembled until after localmount has run.

As its not there, it does not get mounted.

This is a bit of a hack ...

See /etc/local.d/README

Make a file called say mountraid.start with one line

```
mount /dev/md1 /mnt/raid

chmod +x mountraid.start
```

I don't think it needs #!/bin/bash at the top.

You could also  edit /etc/init.d/localmount so it runs after mdadm

----------

## hoacker

 *NeddySeagoon wrote:*   

> This is a bit of a hack ...
> 
> See /etc/local.d/README

 

Yes, was thinking about that, too. I hoped that we could figure out the problem and solve it in a different way. local.d will solve my problem, I consider this case closed.

Thank you very much for your support, NeddySeagoon.

----------

## hoacker

 *NeddySeagoon wrote:*   

> You could also  edit /etc/init.d/localmount so it runs after mdadm

 

I chose that solution. Works!

```
-        after lvm modules

+        after lvm modules mdadm
```

----------

## NeddySeagoon

hoacker,

Take care. One day etc-update will revert that change, if you let it.

----------

## hoacker

 *NeddySeagoon wrote:*   

> Take care. One day etc-update will revert that change, if you let it.

 

I know, dispatch-conf is my friend...   :Wink: 

----------

