Hello,

TL;DR: the Debian installer uses an mdadm.conf located at
/tmp/mdadm.conf.

On Thu, Sep 10, 2020 at 04:18:27PM +0000, Andy Smith wrote:
> I have confirmed that creating a new array from the d-i shell using
> mdadm commands manually does result in a new array without a bbl (so
> this invocation of mdadm did read /etc/mdadm/mdadm.conf):

I made a shell history mistake and ended up examining the wrong
device, so in fact I did not confirm this. I ended up testing a
device that I had previously forced to have its bbl removed, that's
why the bbl was gone.

> ~ # mdadm -v --create /dev/md2 --assume-clean --level=1 --raid-devices=2 
> /dev/sd[ab]3

…array made with /dev/sd[ab]3…

> ~ # mdadm --examine /dev/sda1

…but I examined sda1 by mistake.

So. Going through this manual creation again, what I see is that
if I force mdadm to read its config file then:

~ # swapoff /dev/md2
~ # mdadm --stop /dev/md2 
mdadm: stopped /dev/md2
~ # mdadm --zero-superblock /dev/sda3
~ # mdadm --zero-superblock /dev/sdb3
~ # mdadm --create -v --config=/etc/mdadm/mdadm.conf /dev/md2 --assume-clean 
--level=1 --raid-devices=2 /dev/sd[ab]3
mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
mdadm: size set to 1951744K
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md2 started.
~ # mdadm --examine /dev/sda3
/dev/sda3:
…
(no bbl)
…

but if I just call mdadm as normal, it does not read its config
file:

~ # mdadm --stop /dev/md2 
mdadm: stopped /dev/md2
~ # mdadm --zero-superblock /dev/sda3
~ # mdadm --zero-superblock /dev/sdb3
~ # mdadm --create -v /dev/md2 --assume-clean --level=1 --raid-devices=2 
/dev/sd[ab]3
mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
mdadm: size set to 1951744K
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md2 started.
~ # mdadm --examine /dev/sdb3
…
  Bad Block Log : 512 entries available at offset 72 sectors
…

So that'd explain why d-i's usage of mdadm doesn't obey the config
file. Yet the man page for mdadm says:

    --config=
        Specify   the   config   file  or  directory.   Default  is
        to use /etc/mdadm/mdadm.conf…

I have now tried this in a real system and there the config file is
respected. I am really confused at this point.

So I installed strace in the d-i shell, and…

~ # strace -e trace=open -o strace.log mdadm --create -v /dev/md2 
--assume-clean --level=1 --raid-devices=2 /dev/sd[ab]3
…
~ # grep .conf strace.log 
open("/tmp/mdadm.conf", O_RDONLY)       = 3
open("/tmp/mdadm.conf.d", O_RDONLY)     = -1 ENOENT (No such file or directory)

Uh, alright then.

~ # cp /etc/mdadm/mdadm.conf /tmp/
~ # mdadm --create -v /dev/md2 --assume-clean --level=1 --raid-devices=2 
/dev/sd[ab]3
~ # mdadm --examine /dev/sda3
/dev/sda3:
(no bbl)

I assume there is a good reason for d-i having an mdadm binary that
wants to use /tmp/ and not /etc/mdadm/ for its config directory.

Cheers,
Andy

Reply via email to