Diskless and Raid

HI,
I’m working on a diskless solution, booting and loading ign file via pxe.
I run podman containers at startup and the show is going on !
I store datas in /var mounted on 2 1to hdd with raid1 written in fcc/ign file as :

storage:
  raid:
  - name: Raid
    level: raid1
    devices:
    - /dev/disk/by-id/ata-WDC_WD10SPZX-80Z10T2_WD-WX41A49H9FT4
    - /dev/disk/by-id/ata-WDC_WD10SPZX-80Z10T2_WD-WXL1A49KPYFD
    options:
    - --config=/etc/mdadm.conf

  filesystems: 
    - path: /var
      device: /dev/md/Raid
      format: xfs
      label: Var
      wipe_filesystem: false
      with_mount_unit: true
  files:
- path: /etc/mdadm.conf
      mode: 0644
      contents:
        inline: |
          ARRAY /dev/md/Raid metadata=1.2 name=any:Raid UUID=7ec8d4df:823fae52:c55d5e56:e773b281

Everything works fine except that my raid is rebuilt/resync with a new UUID at every boot even if I give coreos a mdadm.conf file …

How could I prevent raid resync on each boot ?
Perhaps a fcc/ign option like “should_exist” will make boot process looking for existing raid before creating one or will need a mdadm.conf file ?

As a workaround, I’ve added some options : (same uuid as in mdadm.conf)

  raid:
  - name: Raid
    level: raid1
    devices:
    - /dev/disk/by-id/ata-WDC_WD10SPZX-80Z10T2_WD-WX41A49H9FT4
    - /dev/disk/by-id/ata-WDC_WD10SPZX-80Z10T2_WD-WXL1A49KPYFD
    options:
    - --config=/etc/mdadm.conf
    - --assume-clean
    - --uuid=7ec8d4df:823fae52:c55d5e56:e773b281

But I’m looking for a better way to do it …

The /etc/mdadm.conf file that the Ignition config writes is in the real root, but the RAID device gets assembled by Ignition itself at the initramfs stage. So mdadm doesn’t actually see the config file.

Offhand, there’s at least two ways around this. One is simply to use command-line args as you have in your second snippet. The second is to specify in your PXE config a second initramfs which contains /etc/mdadm.conf. Something like:

$ mkdir -p mdadm-conf/etc
$ cd mdadm-conf
$ echo 'my config' > etc/mdadm.conf
$ find . -mindepth 1 -print0 | cpio -o -H newc -R root:root --quiet --reproducible --force-local --null -D . | gzip -1 > ../mdadm-conf.img

I would personally go with the former approach so that everything is contained within the Ignition config.

2 Likes