Windows Linux 子系统上的 grub-pc 更新错误

Windows Linux 子系统上的 grub-pc 更新错误

之后sudo apt upgrade不断出现以下错误:

$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n]
Setting up grub-pc (2.02~beta2-9ubuntu1.11) ...
grub-probe: error: failed to get canonical path of `rootfs'.
grub-probe: error: failed to get canonical path of `rootfs'.
grub-probe: error: failed to get canonical path of `rootfs'.
/usr/sbin/grub-probe: error: failed to get canonical path of `rootfs'.
dpkg: error processing package grub-pc (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 grub-pc
E: Sub-process /usr/bin/dpkg returned an error code (1)

有办法解决吗?

Windows 10 内部版本 14393

答案1

查看这个 github 评论以及其正下方的一个(用于复制粘贴脚本)为我提供了一些有用的解决方案。

为了方便任何人访问,这里是评论的重要文本(尽管如果可以的话你应该对 github 评论中的人点赞):

(我必须在运行后sudo -s或在每行前面加上sudo

cat > /usr/sbin/policy-rc.d <<EOF
#!/bin/sh
exit 101
EOF
chmod +x /usr/sbin/policy-rc.d
dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl

答案2

这为我修复了这个问题:

sudo apt -f remove grub-pc

https://github.com/Microsoft/WSL/issues/1965#issuecomment-340132015

相关内容