dark

Using multipath together with mdadm on Debian

blank
blank

Using multipath together with mdadm on Debian Linux requires some changes to the initrd image, otherwise mdadm might start before multipath, leading to only one FC path being used or even failure of starting multipath (no FC paths found at all).

To prevent this issue, three steps are required:

  • change the order kernel modules get loaded by initrd
  • disable the mdadm auto-assembly of disks when initrd is loaded
  • generate a new initrd image

The initrd configuration files can be found at /etc/initramfs-tools.

First define the order of module loading during boot (ensure that multipath is loaded before mdadm). Edit the file /etc/initramfs-tools/modules to match:

# List of modules that you want to include in your initramfs.
# They will be loaded at boot time in the order below.
#
# Syntax: module_name [args ...]
#
# You must run update-initramfs(8) to effect this change.
#
# Examples:
#
# raid1
# sd_mod
libfc
megaraid_sas
scsi_dh_alua
scsi_transport_fc
dm_multipath
dm_service_time
multipath
md_mod

This starts by loading the “fiber channel libs” (libfc) first, followed by the MegaRAID modules, SCSI over fiber channel, multipath and mdadm.

Now copy the mdadm initramfs hook to /etc to override the default one:

cp /usr/share/initramfs-tools/hooks/mdadm /etc/initramfs-tools/hooks/

Edit the hook file in /etc/initramfs-tools/hooks/mdadm and add an ‘exit 0‘ (see line 10):

#!/bin/sh
#
# Copyright © 2006-2008 Martin F. Krafft <madduck@debian.org>,
#
2012 Michael Tokarev <mjt@tls.msk.ru>
# based on the scripts in the initramfs-tools package.
# released under the terms of the Artistic Licence.
#
set -eu
exit 0
PREREQ="udev"
prereqs()
{
echo "$PREREQ"
}

Disable automatic startup of the mdadm service:

rm /lib/systemd/system/mdadm.service
systemctl daemon-reload
systemctl disable mdadm.service

Finally, update the initrd images for all kernel versions installed:

update-initramfs -u -k all

Reboot the server to see if modules are now loaded in the correct order, and multipath is loaded and started before mdadm.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Previous Post
blank

Use multiple Azure subscriptions in Terraform modules

Next Post
blank

Jenkins to manage a libvirt infrastructure with Terraform

Related Posts