Skip to main content

Debian mdadm post boot assemble

After the upgrade to Debian Stretch, I had problems getting my raid volume with external bitmap assembled. After assembling, definition in /etc/mdadm/mdadm.conf, the array was created without the configured eternal bitmap.

ARRAY /dev/md0 metadata=1.2 bitmap=/var/lib/mdadm/bitmap-md0.bin UUID=aaaaaaa:bbbbbbbb:cccccccc:dddddddd name=server:Raid1_00

Reason for this “Issue” was the fact that the mdadm assemble is done in the¬†initramfs during the boot. In this stage, the volume for the external bitmap doesn’t exist yet.

To solve this, we need to disable the mdadm assemble during boot. The following steps describe how to configure mdadm to assemble an array after booting the kernel and support an external bitmap.

Add an external bitmap to the array.

mdadm --grow --bitmap=/var/lib/mdadm/bitmap-md0.bin /dev/md0

Disable the initramfs mdadm hook.

#!/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

# disable hook
# no boottime mdadm assemble
exit 0

PREREQ="udev"
prereqs()
{
    echo "$PREREQ"
}

Update the initramfs.

update-initramfs -u

To check the current initramfs you can do the following.

mkdir /tmp/initramfs
cd /tmp/initramfs
zcat /boot/initrd.img-3.8-trunk-amd64 | cpio -idmv

After reboot you should find the assembled array with enabled external bitmap.

cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[2] sdc1[0]
 976629760 blocks super 1.2 [2/2] [UU]
 bitmap: 0/466 pages [0KB], 1024KB chunk, file: /var/lib/mdadm/bitmap-md0.bin

Leave a Reply

Your email address will not be published. Required fields are marked *