Debian:升级内核(至 4.9)时出现新错误消息 - 重新加载 ioctl 错误

Debian:升级内核(至 4.9)时出现新错误消息 - 重新加载 ioctl 错误

我正在将 Debian 9.0 Stretch 中的内核升级到 4.9.0-1-amd64。

该软件包已安装,但是在过程结束时我收到了神秘的错误:

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

我还担心重新启动它,它无法正常启动。

运行dpkg-reconfigure linux-image-4.9.0-1-amd64也会产生相同的错误。

奇怪的是,在/etc/fstab我没有sda2分区的情况下,该过程一直有效到现在。它在上次软件包升级后停止工作(事实上,我可以发誓在上次软件包升级到 232-18 后我首先看到了错误udev)。带有 Jessie 的虚拟机仍然工作正常。

也是如此fstab

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

但是,运行时blkid,我记得现在/dev/sda2是 ext3 日志分区:

/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"

经过更多调查后,我还发现一个悬空文件仍然提到旧的sda2(因为这个虚拟机是在很多个月前从具有 LVM 的服务器迁移而来的)

内容为/etc/blkid.tab

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

我删除了它,但是它可能没有任何区别,因为正确的blkid.tab内容与预期的一样/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>

运行前一个dpkg-reconfigure仍然会出现相同的错误。

upgrade-grub我还设法查明了被调用的错误dpkg-reconfigure。单独运行:

#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

跟踪upgrade-grub,很明显这发生在/etc/grub.d/30_os-prober,并且读取该脚本,有问题的命令是os-prober

所以运行它:

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

错误来自于os-prober调用:

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

看着30_os-prober我也发现了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

谷歌一圈发现了这篇文章:让grub2忽略某个分区,这导致我输入/etc/default/grub

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

但是,错误仍然发生,并且将30_os-prober脚本置于调试模式显示负责处理的代码块GRUB_OS_PROBER_SKIP_LIST未执行。例如,它甚至没有到达if上面显示的线。

我的 GRUB 版本是2.02~beta3-5.该怎么办?

更新:根据 @GaD3R 请求,libmapper-dev 是 1.02.1

答案1

鉴于GRUB_OS_PROBER_SKIP_LIST显然没有被使用(bug?),我不得不配置 GRUB/os-prober 来不扫描每个分区中的操作系统。

所以它被添加到/etc/default/grub行中:

GRUB_DISABLE_OS_PROBER=true

现在,命令dpkg-reconfigure linux-image-4.9.0-1-amd64可以update-grub正常工作了。

有问题的服务器也4.9.0-1-amd64成功地使用内核重新启动。

经过所有调试和解决方案后我发现了一个相关问题, 这里,还主张os-prober完全删除作为替代方案。该解决方案也将起作用,因为脚本在调用二进制文件之前检查它是否存在。

我怀疑os-prober只需要多操作系统 grub,这不是我的情况。

在 @Ferenc Wágner 发表评论后历史问题os-prober,并且还分享了在仅 Linux 虚拟机的上下文中删除 os-prober 并没有什么坏处的观点,我实际上从我的虚拟机中删除了它。

答案2

device-mapper: reload ioctl on osprober-linux-sda1 failed: Device or resource busy由于有镜子,我收到此错误zfs

/etc/grub.d/30_os-proberos-prober依赖于匹配设备的输出:

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

设备在以下位置检查loop

for OS in ${OSPROBED} ; do

& asos-prober给出ioctl错误而不是返回设备,检查$OSin$GRUB_OS_PROBER_SKIP_LIST无效/etc/grub.d/30_os-prober

/etc/default/grub解决方案是以以下形式添加设备UUID@device_path

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

& 编辑/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)
  • 在 Windows 上测试 /架构Linux双启动系统。

前:

[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

后:

[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

相关内容