Bug#873171: mdadm starts arrays on boot even though AUTO -all specified if no ARRAY in mdadm.conf

2023-08-27 Thread Michael

Seems like 2 bugs.

mkconf doesn't save the "AUTO" value from the existing mdadm.conf as 
defaults:


# save existing values as defaults
if [ -r "$CONFIG" ]; then
  DEVICE="$(sed -ne 's/^DEVICE //p' $CONFIG)"
  HOMEHOST="$(sed -ne 's/^HOMEHOST //p' $CONFIG)"
  PROGRAM="$(sed -ne 's/^PROGRAM //p' $CONFIG)"
fi


and then the initramfs-tools/hooks/mdadm looks for ^ARRAY and if not 
found, it doesn't use the mdadm.conf but rather uses mkconf to generate 
which of course ignores the AUTO option.



if [ ! -f $CONFIG ]; then



else
    cp -p $CONFIG ${DESTDIR}/etc/mdadm
    sed -i '/^CREATE/s/^/#/' $DESTMDADMCONF
    if ! grep -q '^ARRAY' $CONFIG; then
    tmpfile="${DESTMDADMCONF}.tmp"
    if /usr/share/mdadm/mkconf > $tmpfile; then
    cp -p $tmpfile $DESTMDADMCONF
    rm -f $tmpfile



Bug#873171: mdadm starts arrays on boot even though AUTO -all specified if no ARRAY in mdadm.conf

2017-08-25 Thread John Hughes
Package: mdadm
Version: 3.4-4+b1
Severity: normal

Dear Maintainer,

   * What led up to the situation?

Upgraded from Jessie to Stretch

   * What exactly did you do (or not do) that was effective (or
 ineffective)?

We want to start our mdadm raid arrays manually, so we have no ARRAY lines
in mdadm.conf and we have AUTO -all.

   * What was the outcome of this action?

Arrays are not started on udev events (which is good), but they *are*
started on boot (which is bad).

   * What outcome did you expect instead?

No array to be automatically started.

What is happening is:

When the /usr/share/initramfs-tools/hooks/mdadm script is run during initrd
creation it notices that we have no ARRAY lines in our mdadm.conf, so it uses
/usr/share/mdadm/mkconf to make a new mdadm.conf which means that all
arrays connected to the machine when the initrd is created will be started
on boot.

As a workaround we have added a dummy ARRAY declaration to our mdadm.conf:

AUTO -all
ARRAY name=unused

And now, although mkinitrd issues many boring warnings about arrays not being
in mdadm.conf it doesn't start all our arrays on boot.


-- Package-specific info:
--- mdadm.conf
DEVICE partitions
CREATE owner=root group=disk mode=0660 auto=yes
HOMEHOST 
MAILADDR sta...@olympic.calvaedi.com
AUTO -all
ARRAY name=unused

--- /etc/default/mdadm
AUTOCHECK=true
START_DAEMON=true
DAEMON_OPTIONS="--syslog"
VERBOSE=false

--- /proc/mdstat:
Personalities : [raid1] [raid10] [linear] [multipath] [raid0] [raid6] [raid5] 
[raid4] 
md125 : active raid1 sdb[2] sdd[3]
  3906887360 blocks super 1.2 [2/2] [UU]
  bitmap: 0/30 pages [0KB], 65536KB chunk

md126 : active raid1 sdc[2] sde[3]
  1953511869 blocks super 1.1 [2/2] [UU]
  bitmap: 0/466 pages [0KB], 2048KB chunk

md127 : active raid10 sdz[0] sdi[11] sdq[12] sdj[9] sdt[8] sdk[7] sdu[6] sdl[5] 
sdw[4] sdm[3] sdx[2] sdn[1]
  429729792 blocks super 1.2 512K chunks 2 near-copies [12/12] 
[]
  bitmap: 1/4 pages [4KB], 65536KB chunk

unused devices: 

--- /proc/partitions:
major minor  #blocks  name

   80   71041024 sda
   81 498688 sda1
   82  1 sda2
   85   70539264 sda5
  1101048575 sr0
   8   16 3907018584 sdb
   8   32 1953514584 sdc
   8   48 3907018584 sdd
   8   64 1953514584 sde
   8   80  976762584 sdf
   8   96  143374740 sdg
   8  112   71687325 sdh
   8  128   71687325 sdi
   8  144   71687325 sdj
   8  160   71687325 sdk
   8  176   71687325 sdl
   8  192   71687325 sdm
   8  208   71687325 sdn
   8  224  143374740 sdo
   8  240   62522712 sdp
  650   71687325 sdq
  65   16  976762584 sdr
  65   32  143374740 sds
  65   48   71687325 sdt
  65   64   71687325 sdu
  65   80   62522712 sdv
  65   96   71687325 sdw
  65  112   71687325 sdx
  65  128  143374740 sdy
  65  144   71687325 sdz
 25307811072 dm-0
 2531   23437312 dm-1
 2532   15622144 dm-2
 25337811072 dm-3
   9  127  429729792 md127
 2590 258016 md127p1
 2591  429471504 md127p2
   9  126 1953511869 md126
   9  125 3906887360 md125

--- LVM physical volumes:
  PV VGFmt  Attr PSize  PFree 
  /dev/sda5  arabic-vg lvm2 a--  67.27g 15.12g
--- mount output
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs 
(rw,nosuid,relatime,size=12328556k,nr_inodes=3082139,mode=755)
devpts on /dev/pts type devpts 
(rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=2468104k,mode=755)
/dev/mapper/arabic--vg-root on / type ext4 
(rw,relatime,errors=remount-ro,data=ordered)
securityfs on /sys/kernel/security type securityfs 
(rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup 
(rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/memory type cgroup 
(rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup 
(rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/freezer type cgroup 
(rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/perf_event type cgroup 
(rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup 
(rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/blkio type cgroup 
(rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on