5

I am upgrading the kernel in Debian 9.0 Stretch to kernel to 4.9.0-1-amd64.

The package is installed, however, at the end of the procedure I got the cryptic error:

device-mapper: reload ioctl on osprober-linux-sda2 failed: Device or resource busy
Command failed

I also am worried about rebooting it, and it not booting properly.

Running dpkg-reconfigure linux-image-4.9.0-1-amd64 also produces the same error.

Oddly enough, at /etc/fstab I have no sda2 partition, and the procedure used to work until now. It just stopped working after the last package upgrades (in fact I could swear I saw the error first after the last udev package upgrade to 232-18 ). VMs with Jessie are still working fine.

So fstab is:

$cat /etc/fstab
/dev/sda1 / ext3 errors=remount-ro,noatime 0 1
/dev/sda3 none swap sw 0 0

However, running blkid, I remember now /dev/sda2 is the ext3 journaling partition:

/dev/sda1: UUID="43dcd715-1914-4da8-8e55-27879705920a" EXT_JOURNAL="b153f326-cb4e-491b-9b38-f9750dcf5165" TYPE="ext3" PARTUUID="8aac691c-01"
/dev/sda2: LABEL="j-my-dev" UUID="b153f326-cb4e-491b-9b38-f9750dcf5165" LOGUUID="b153f326-cb4e-491b-9b38-f9750dcf5165" TYPE="jbd" PARTUUID="8aac691c-02"
/dev/sda3: UUID="a04c0b69-07d5-40e1-8c80-6914118f6df4" TYPE="swap" PARTUUID="8aac691c-03"

After investigating a little more, I also found a dangling file still mentioning the old sda2 (as this VM was migrated from a server with LVM many moons ago)

The contents of /etc/blkid.tab were:

<device DEVNO="0x0802" TIME="1414777337.116803" UUID="B24u3l-mvwB-vyxK-GRNw-vc6o-r2sS-NDgVru" TYPE="LVM2_member">/dev/sda2</device>

I deleted it, however it probably does not do any difference as the proper blkid.tab is as expected at /var/run/blkid/blkid.tab

<device DEVNO="0x0801" TIME="1487991512.317454" UUID="43dcd715-1914-4da8-8e55-27879705920a" EXT_JOURNAL="b153f326-cb4e-491b-9b38-f9750dcf5165" TYPE="ext3" PARTUUID="8aac691c-01">/dev/sda1</device>
<device DEVNO="0x0802" TIME="1487991415.63466" LABEL="j-my-dev" UUID="b153f326-cb4e-491b-9b38-f9750dcf5165" LOGUUID="b153f326-cb4e-491b-9b38-f9750dcf5165" TYPE="jbd" PARTUUID="8aac691c-02">/dev/sda2</device>
<device DEVNO="0x0803" TIME="1487991512.507280" UUID="a04c0b69-07d5-40e1-8c80-6914118f6df4" TYPE="swap" PARTUUID="8aac691c-03">/dev/sda3</device>

Running the previous dpkg-reconfigure still gives the same error.

I also managed to pinpoint the error to upgrade-grub being called in dpkg-reconfigure. Running it separately:

#update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.9.0-1-amd64
Found initrd image: /boot/initrd.img-4.9.0-1-amd64
device-mapper: reload ioctl on osprober-linux-sda2 failed: Device or resource busy
Command failed
done

stracing upgrade-grub, it is evident this happens at /etc/grub.d/30_os-prober, and reading that script the offending command is os-prober.

So running it:

#os-prober 
device-mapper: reload ioctl on osprober-linux-sda2 failed: Device or resource busy
Command failed

The error comes from os-prober calling:

#/usr/bin/linux-boot-prober /dev/sda2
device-mapper: reload ioctl on osprober-linux-sda2 failed: Device or resource busy
Command failed

Looking at 30_os-prober I also find out about GRUB_OS_PROBER_SKIP_LIST.

if [ "x${GRUB_OS_PROBER_SKIP_LIST}" != "x" ] && [ "x`echo ${GRUB_OS_PROBER_SKIP_LIST} | grep -i -e '\b'${EXPUUID}'\b'`" != "x" ] ; then
  echo "Skipped ${LONGNAME} on ${DEVICE} by user request." >&2
  continue
fi

Googling around found this article: Make grub2 ignore a certain partition, which led me to put in /etc/default/grub:

GRUB_OS_PROBER_SKIP_LIST="b153f326-cb4e-491b-9b38-f9750dcf5165@/dev/sda2"

However, the error still happens, and putting the 30_os-prober script in debug mode shows the code block responsible for handling GRUB_OS_PROBER_SKIP_LIST is not executed. e.g. it does not even reaches the if line displayed above.

My GRUB version is 2.02~beta3-5. What to do?

UPDATE: as per @GaD3R request, libmapper-dev is 1.02.1

0

2 Answers 2

4

Given GRUB_OS_PROBER_SKIP_LIST apparently not being used (bug?), I had to configure instead GRUB/os-prober for not to scan for the OS in every partition.

So it was added to /etc/default/grub the line:

GRUB_DISABLE_OS_PROBER=true

Now, the commands dpkg-reconfigure linux-image-4.9.0-1-amd64 and update-grub work properly.

The server in question was also rebooted with the kernel 4.9.0-1-amd64 with success.

A related question, that I found after all the debugging and the solution, here, also advocates removing os-prober altogether as an alternative. That solution will also work as the scripts check for the existence of the binary before invoking it.

I suspect os-prober is only needed for multi-OS grub, which is not my case.

After the comment of @Ferenc Wágner about historic problems with os-prober, and also sharing the opinion it does not hurt removing os-prober in a context of Linux-only VMs, I actually removed it from my VMs.

4
  • 1
    I actively avoid os-prober, it has a long history of corrupting VM images. Commented Feb 27, 2017 at 14:26
  • 1
    I'm not quite sure we're on the same page, though. os-prober is problematic on hosts running VMs backed by block devices, not on the VMs themselves (though it's most certainly useless there as well). Commented Mar 1, 2017 at 14:16
  • @FerencWágner Thanks for the additional comment. Actually from what I read in the scripts, they try to unmount partitions before doing the probe. That must be the reason for the corruption you talk about. Commented Mar 1, 2017 at 17:18
  • 2
    Multiple things could go wrong. You can't tell from outside of a VM whether a block device is actually mounted inside a VM (in contrast to it's just being passed to the VM). If it is, and you mount it, you usually corrupt it (even a read-only mount replays the journal unless special care is taken). Then os-prober tried to be careful, and set devices read-only beforehand, but then this led to write failures inside the VM, dropping the filesystem again... Things probably improved recently, but I don't take these risks for nothing: I know what OS's I use, thanks. Commented Mar 2, 2017 at 7:53
2

I received this error device-mapper: reload ioctl on osprober-linux-sda1 failed: Device or resource busy due to having a zfs mirror.

/etc/grub.d/30_os-prober relies on the output of os-prober for matching devices:

OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`"

devices are checked in a loop:

for OS in ${OSPROBED} ; do

& as os-prober gives an ioctl error instead of returning a device, checking $OS against $GRUB_OS_PROBER_SKIP_LIST in /etc/grub.d/30_os-prober has no effect.

The solution was to add the devices to /etc/default/grub in the form of UUID@device_path:

GRUB_OS_PROBER_SKIP_LIST="1234567899273705219@/dev/sda1 1234567899273705219@/dev/sdb1"

& edit /usr/bin/os-prober:

--- /usr/bin/os-prober  2018-10-15 17:46:19.420933449 +0100
+++ /usr/bin/os-prober.bak  2018-10-15 16:44:49.927531809 +0100
@@ -167,12 +167,6 @@ for partition in $(partitions); do
        continue
    fi

-   # Skip user defined devices in /etc/default/grub
-   if echo $GRUB_OS_PROBER_SKIP_LIST | grep -qw $partition; then
-       debug "$partition: probing disabled by user"
-       continue
-   fi
-
    # do btrfs processing here; both mounted and unmounted will
    # be handled by 50mounted-tests so we can do a subvol only once.
    type=$(blkid -o value -s TYPE $mapped || true)
  • Tested on a Windows / Arch Linux dual boot system.

BEFORE:

[stuart@manjaro ~]$ sudo update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux-hardened
Found initrd image: /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs-linux-hardened.img
Found initrd fallback image: /boot/initramfs-linux-hardened-fallback.img
Found linux image: /boot/vmlinuz-4.14-rt-x86_64
Found initrd image: /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs-4.14-rt-x86_64.img
Found initrd fallback image: /boot/initramfs-4.14-rt-x86_64-fallback.img
device-mapper: reload ioctl on osprober-linux-sda1  failed: Device or resource busy
Command failed.
device-mapper: reload ioctl on osprober-linux-sdb1  failed: Device or resource busy
Command failed.
Found Windows Boot Manager on /dev/nvme0n1p2@/EFI/Microsoft/Boot/bootmgfw.efi
###### - Grub-btrfs: Auto-detect Start - ######
# found 0 snapshot(s)
# No snapshot found 
# make sure you have at least one snapshot 
# or please file a bug report at "https://github.com/Antynea/grub-btrfs"
###### - Grub-btrfs: Auto-detect End   - ######
Found memtest86+ image: /boot/memtest86+/memtest.bin
/usr/bin/grub-probe: warning: unknown device type nvme0n1.
done

AFTER:

[stuart@manjaro ~]$ sudo update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-linux-hardened
Found initrd image: /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs-linux-hardened.img
Found initrd fallback image: /boot/initramfs-linux-hardened-fallback.img
Found linux image: /boot/vmlinuz-4.14-rt-x86_64
Found initrd image: /boot/intel-ucode.img /boot/amd-ucode.img /boot/initramfs-4.14-rt-x86_64.img
Found initrd fallback image: /boot/initramfs-4.14-rt-x86_64-fallback.img
Found Windows Boot Manager on /dev/nvme0n1p2@/EFI/Microsoft/Boot/bootmgfw.efi
###### - Grub-btrfs: Auto-detect Start - ######
# found 0 snapshot(s)
# No snapshot found 
# make sure you have at least one snapshot 
# or please file a bug report at "https://github.com/Antynea/grub-btrfs"
###### - Grub-btrfs: Auto-detect End   - ######
Found memtest86+ image: /boot/memtest86+/memtest.bin
/usr/bin/grub-probe: warning: unknown device type nvme0n1.
done
3
  • You add a device to the exception list and then drop the check of the exception list? Am I missing something? Commented Oct 15, 2018 at 17:43
  • @Rui F Ribeiro - see expanded answer Commented Oct 15, 2018 at 18:21
  • Thanks, will try to have a look at it later on after work. Commented Oct 16, 2018 at 9:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .