How to regenerate the boot configuration for mdadm

Alteration of the software RAID arrangement often requires an update to the boot configuration of the mdadm utility for management of Software RAID.

Notice the mdadm warning during the exection of update-initramfs.

$ sudo apt-get install firmware-linux-nonfree
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  firmware-linux-nonfree
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 2584 kB of archives.
After this operation, 5128 kB of additional disk space will be used.
Get:1 http://ftp.task.gda.pl/debian wheezy/non-free amd64 firmware-linux-nonfree all 20161130-3 [2584 kB]
Fetched 2584 kB in 4s (547 kB/s)
Selecting previously unselected package firmware-linux-nonfree.
(Reading database ... 42468 files and directories currently installed.)
Unpacking firmware-linux-nonfree (from .../firmware-linux-nonfree_0.43~bpo70+1_all.deb) ...
Setting up firmware-linux-nonfree (0.43~bpo70+1) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools ...
update-initramfs: Generating /boot/initrd.img-3.2.0-4-amd64
W: mdadm: the array /dev/md2 with UUID 9bceb0b3:7eae7c53:9d737992:15c84904
W: mdadm: is currently active, but it is not listed in mdadm.conf. if
W: mdadm: it is needed for boot, then YOUR SYSTEM IS NOW UNBOOTABLE!
W: mdadm: please inspect the output of /usr/share/mdadm/mkconf, compare
W: mdadm: it to /etc/mdadm/mdadm.conf, and make the necessary changes.
localepurge: Disk space freed in /usr/share/locale: 0 KiB
localepurge: Disk space freed in /usr/share/man: 0 KiB

Total disk space freed by localepurge: 0 KiB

As stated above, the mdadm.conf configuration file does not contain /dev/md2 array.

$ cat /etc/mdadm/mdadm.conf
# mdadm.conf
#
# Please refer to mdadm.conf(5) for information about this file.
#

# by default (built-in), scan all partitions (/proc/partitions) and all
# containers for MD superblocks. alternatively, specify devices to scan, using
# wildcards if desired.
#DEVICE partitions containers

# auto-create devices with Debian standard permissions
CREATE owner=root group=disk mode=0660 auto=yes

# automatically tag new arrays as belonging to the local system
HOMEHOST 

# instruct the monitoring daemon where to send mail alerts
MAILADDR root

# definitions of existing MD arrays
ARRAY /dev/md/0 metadata=1.2 UUID=924159a9:2bb84a58:acaae1f3:c91b95e7 name=localhost:0
ARRAY /dev/md/1 metadata=1.2 UUID=a1774f0b:e3f62a09:144847a8:240d4714 name=localhost:1

# This file was auto-generated on Wed, 28 Dec 2016 16:12:56 +0100
# by mkconf 3.2.5-5

Display current array configuration.

$ sudo mdadm --examine --scan
ARRAY /dev/md/0 metadata=1.2 UUID=924159a9:2bb84a58:acaae1f3:c91b95e7 name=localhost:0
ARRAY /dev/md/1 metadata=1.2 UUID=a1774f0b:e3f62a09:144847a8:240d4714 name=localhost:1
ARRAY /dev/md/2 metadata=1.2 UUID=9bceb0b3:7eae7c53:9d737992:15c84904 name=2

Authenticate to update the cached credentials without running a command.

$ sudo -v

Display differences between current and new version of the mdadm.conf configuration file.

$ diff -u <(cat mdadm.conf) <(sudo bash /usr/share/mdadm/mkconf)
--- /dev/fd/63	2017-10-25 13:18:14.851682845 +0000
+++ /dev/fd/62	2017-10-25 13:18:14.851682845 +0000
@@ -20,6 +20,7 @@
 # definitions of existing MD arrays
 ARRAY /dev/md/0 metadata=1.2 UUID=924159a9:2bb84a58:acaae1f3:c91b95e7 name=localhost:0
 ARRAY /dev/md/1 metadata=1.2 UUID=a1774f0b:e3f62a09:144847a8:240d4714 name=localhost:1
+ARRAY /dev/md/2 metadata=1.2 UUID=9bceb0b3:7eae7c53:9d737992:15c84904 name=2

-# This file was auto-generated on Wed, 28 Dec 2016 16:12:56 +0100
+# This configuration was auto-generated on Wed, 25 Oct 2017 13:18:15 +0000
 # by mkconf 3.2.5-5

Update mdadm.conf configuration file.

$ sudo bash /usr/share/mdadm/mkconf | sudo tee /etc/mdadm/mdadm.conf
# mdadm.conf
#
# Please refer to mdadm.conf(5) for information about this file.
#

# by default (built-in), scan all partitions (/proc/partitions) and all
# containers for MD superblocks. alternatively, specify devices to scan, using
# wildcards if desired.
#DEVICE partitions containers

# auto-create devices with Debian standard permissions
CREATE owner=root group=disk mode=0660 auto=yes

# automatically tag new arrays as belonging to the local system
HOMEHOST <system>

# instruct the monitoring daemon where to send mail alerts
MAILADDR root

# definitions of existing MD arrays
ARRAY /dev/md/0 metadata=1.2 UUID=924159a9:2bb84a58:acaae1f3:c91b95e7 name=localhost:0
ARRAY /dev/md/1 metadata=1.2 UUID=a1774f0b:e3f62a09:144847a8:240d4714 name=localhost:1
ARRAY /dev/md/2 metadata=1.2 UUID=9bceb0b3:7eae7c53:9d737992:15c84904 name=2

# This configuration was auto-generated on Wed, 25 Oct 2017 11:38:33 +0000
# by mkconf 3.2.5-5

Update initramfs.

$ sudo update-initramfs -u
update-initramfs: Generating /boot/initrd.img-3.2.0-4-amd64

Solved.

Milosz Galazka's Picture

About Milosz Galazka

Milosz is a Linux Foundation Certified Engineer working for a successful Polish company as a system administrator and a long time supporter of Free Software Foundation and Debian operating system.