The Hidden Blog

As it turns out, I do have a hostname.

Ubuntu 24.04: mdadm: /dev/md does not appear to be an md device

Published on Oct 19, 2024

I've recently updated my server from an older Ubuntu LTS version to Ubuntu 24.04.1 LTS. The upgrade didn't go through smoothly but I don't fully recall what was the issue.

Today I've tried to do the regular apt-get update && apt-get upgrade dance and realized that it was failing with the following error message:

Setting up snapd (2.65.3+24.04) ...
Installing new version of config file /etc/apparmor.d/usr.lib.snapd.snap-confine.real ...
snapd.failure.service is a disabled or a static unit not running, not starting it.
snapd.snap-repair.service is a disabled or a static unit not running, not starting it.
Setting up libgomp1:amd64 (14.2.0-4ubuntu2~24.04) ...
Setting up grub-pc (2.12-1ubuntu7) ...
Installing for i386-pc platform.
mdadm: /dev/md does not appear to be an md device
grub-install: error: ioctl RAID_VERSION error: Inappropriate ioctl for device.
dpkg: error processing package grub-pc (--configure):
 installed grub-pc package post-installation script subprocess returned error exit status 1
Setting up libproc2-0:amd64 (2:4.0.4-4ubuntu3.2) ...
Setting up tailscale (1.76.1) ...
Setting up python3-update-manager (1:24.04.9) ...
Setting up procps (2:4.0.4-4ubuntu3.2) ...
Setting up initramfs-tools-bin (0.142ubuntu25.4) ...
Setting up update-manager-core (1:24.04.9) ...
Setting up initramfs-tools-core (0.142ubuntu25.4) ...
Setting up initramfs-tools (0.142ubuntu25.4) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for man-db (2.12.0-4build2) ...
Processing triggers for dbus (1.14.10-4ubuntu4.1) ...
Processing triggers for mailcap (3.70+nmu1ubuntu1) ...
Processing triggers for libc-bin (2.39-0ubuntu8.3) ...
Processing triggers for initramfs-tools (0.142ubuntu25.4) ...
update-initramfs: Generating /boot/initrd.img-6.8.0-47-generic
I: The initramfs will attempt to resume from /dev/sdc3
I: (UUID=2fdf1830-9ce8-423e-afb0-0eeab6c44cdb)
I: Set the RESUME variable to override this.
Errors were encountered while processing:
 grub-pc
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)

The important bit here seems to be the grub-pc installation that fails with mdadm: /dev/md does not appear to be an md device. After researching more it started to look like an Ubuntu bug. There's also some other reports that looked relevant but didn't really have a clear solution.

What worked for me was the following:

1) Identify the disks that make up your RAID array by using cat /proc/mdstat or lsblk -f

root@notmyhostname:~# cat /proc/mdstat
Personalities : [raid1] [raid0] [raid6] [raid5] [raid4] [raid10]
md2 : active raid1 sda2[0] sdb2[1] sdc2[2]
      1951805440 blocks super 1.2 [3/3] [UUU]
      bitmap: 8/15 pages [32KB], 65536KB chunk

md1 : active raid1 sda1[0] sdb1[1] sdc1[2]
      1046528 blocks super 1.2 [3/3] [UUU]

unused devices: <none>

2) Re-install grub on all of the real disks, but not the "virtual" disks of the RAID (md1, md2) by running the following:

  • grub-install /dev/sda

  • grub-install /dev/sdb

  • grub-install /dev/sdc

The same should also be achieved by doing the following and then only selecting /dev/sda, /dev/sdb and /dev/sdc in the UI.

sudo apt-get purge grub-pc
sudo apt-get install grub-pc
sudo dpkg-reconfigure grub-pc

3) Restart...and hope it works.