How to Fix “mdadm: array active but not listed in mdadm.conf” Boot Critical Warning in Linux RAID Systems


4 views

When running apt-get update on a Linux system with software RAID (mdadm), you might encounter this critical warning during initramfs generation:

W: mdadm: the array /dev/md/1 with UUID c622dd79:496607cf:c230666b:5103eba0
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!

This occurs when your active RAID arrays aren't properly registered in /etc/mdadm/mdadm.conf, which is crucial for system boot processes.

First, verify which arrays are actually active and their mount points:

# Check mounted arrays
mount | grep md

# Get detailed array information
for i in {0..6}; do 
    echo "Checking /dev/md$i:";
    mdadm --detail /dev/md$i 2>/dev/null || echo "Not active";
done

From the output, we can see:

  • /dev/md1 is mounted as root (/) filesystem
  • /dev/md2 is mounted on /boot
  • /dev/md5 is mounted on /tmp
  • /dev/md6 is mounted on /home
  • /dev/md0 and /dev/md3 are inactive

The key files to examine are:

# Current configuration
cat /etc/mdadm/mdadm.conf

# Recommended configuration
/usr/share/mdadm/mkconf

The main discrepancy is that the active arrays (md1, md2, md5, md6) weren't listed in the configuration file, while inactive arrays (md0, md3) were incorrectly included.

Here's how to properly update your mdadm configuration:

# Backup current config
cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf.bak

# Generate new config
/usr/share/mdadm/mkconf > /etc/mdadm/mdadm.conf

# Verify new config matches active arrays
grep ARRAY /etc/mdadm/mdadm.conf

# Update initramfs
update-initramfs -u -k all

Before rebooting, perform these final checks:

# Verify fstab entries match active arrays
cat /etc/fstab | grep md

# Check bootloader configuration
cat /boot/grub/menu.lst  # For GRUB Legacy
cat /boot/grub/grub.cfg  # For GRUB2

Key points to validate:

  • Root filesystem (/dev/md1) is properly referenced in both fstab and grub
  • /boot partition (/dev/md2) is accessible before root mounts
  • No references to inactive arrays (md0, md3)

To prevent future issues, consider this monitoring script:

#!/bin/bash
# RAID configuration monitor

ACTIVE_ARRAYS=$(mdadm --detail --scan | awk '{print $2}')
CONFIGURED_ARRAYS=$(grep ^ARRAY /etc/mdadm/mdadm.conf | awk '{print $2}')

# Check for arrays missing from config
for array in $ACTIVE_ARRAYS; do
    if ! grep -q "$array" /etc/mdadm/mdadm.conf; then
        echo "WARNING: Active array $array not in mdadm.conf" | mail -s "RAID Config Alert" admin@example.com
    fi
done

# Check for stale config entries
for array in $CONFIGURED_ARRAYS; do
    if ! mdadm --detail "$array" &>/dev/null; then
        echo "NOTICE: Configured array $array not active" | mail -s "RAID Config Notice" admin@example.com
    fi
done

After implementing these changes:

  1. Schedule a maintenance window to test rebooting the server
  2. Consider setting up remote console access (IPMI/iDRAC/ILO) for out-of-band management
  3. Implement regular configuration backups including /etc/mdadm/mdadm.conf and /etc/fstab

When running apt-get update on a Linux server with software RAID (mdadm), you might encounter scary warnings like:

W: mdadm: the array /dev/md/1 with UUID c622dd79:496607cf:c230666b:5103eba0
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!

First, check which arrays are actually active and mounted:

mount | grep md
mdadm --detail /dev/md*

In our case, we found that /dev/md1 (root), /dev/md2 (boot), /dev/md5 (tmp), and /dev/md6 (home) were active but not properly listed in /etc/mdadm/mdadm.conf.

Instead of manually editing mdadm.conf, use the official method to generate a proper configuration:

# Generate current array information
mdadm --detail --scan > /etc/mdadm/mdadm.conf

# Verify the new configuration
cat /etc/mdadm/mdadm.conf

After updating the configuration, regenerate your initramfs:

update-initramfs -u -k all

Check /etc/fstab to confirm which arrays are needed for boot:

cat /etc/fstab | grep md

Sample critical entries:

/dev/md1      /                    ext3 defaults,usrquota,grpquota 1 1
/dev/md2       /boot    ext2       defaults 1 2

For production servers, consider adding this to your update scripts:

#!/bin/bash
# Update mdadm configuration after array changes
mdadm --detail --scan > /etc/mdadm/mdadm.conf
update-initramfs -u
grub-install /dev/sda
grub-install /dev/sdb
update-grub

Before rebooting, verify everything:

# Check arrays
cat /proc/mdstat

# Verify initramfs contains mdadm
lsinitramfs /boot/initrd.img-$(uname -r) | grep mdadm

# Test config (dry-run)
mdadm --examine --scan --config=/etc/mdadm/mdadm.conf