当前位置: 首页>>技术教程>>正文


我打破了Windows Linux子系统(Windows 10上Ubuntu上的Bash)。 Linux帮助?

, ,

问题描述

我一直在Windows上使用新的Linux子系统,并且以某种方式破坏了它,现在Ubuntu的大多数内部组件(apt-get,dpkg等)都无法正常工作。我尝试的所有事情都会得到相同的信息…

    Setting up udev (204-5ubuntu20.19) ...
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: No such file or directory
runlevel:/var/run/utmp: No such file or directory
 * udev requires devtmpfs support, not started
   ...fail!
invoke-rc.d: initscript udev, action "restart" failed.
dpkg: error processing package udev (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of systemd-services:
 systemd-services depends on udev (>= 175-0ubuntu23); however:
  Package udev is not configured yet.

dpkg: error processing package systemd-services (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of libpam-systemd:amd64:
No apport report written because the error message indicates its a followup error from a previous failure. libpam-systemd:amd64 depends on systemd-services (= 204-5ubuntu20.19); however:
  Package systemd-services is not configured yet.


dpkg: error processing package libpam-systemd:amd64 (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
 udev
 systemd-services
 libpam-systemd:amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)

任何想法如何解决这一问题?

最佳办法

警告,此过程会将Lxss恢复到初始配置

要重新安装Lxss,请以管理员身份打开Windows cmd并运行:

C:\WINDOWS\system32>LxRun.exe /uninstall

然后:

C:\WINDOWS\system32>LxRun.exe /install

次佳办法

固定它。

然:

apt-get remove upstart

然后

apt-get remove udev

然后

apt-get autoremove

一切似乎都在工作。

第三种办法

微软的官方回应

github:Microsoft/BashOnWindows

This is an issue that everyone will start seeing. We need to add something on this in our official docs.

As @nuclearmistake points out, udev is something that breaks in apt-get but the errors should not cause any issues in WSL. We have reached out to Canonical on this one asking for the best solution and they recommend the following changes:

Write the following to /usr/sbin/policy-rc.d

#!/bin/sh exit 101

chmod +x /usr/sbin/policy-rc.d

dpkg-divert –local –rename –add /sbin/initctl

ln -s /bin/true /sbin/initctl

I have tried this one myself and it looks to work quite well.

第四种办法

这是更有针对性的解决方案。创建一个名为/usr/sbin/policy-rc.d(nano /usr/sbin/policy-rc.d)的脚本,其内容如下:

#!/bin/sh
case "$1" in
    udev|systemd-logind) exit 101;;
esac

保存并退出(Ctrl + O Ctrl + X)。将脚本标记为可执行文件(chmod +x /usr/sbin/policy-rc.d)。该脚本告诉dpkg不要尝试启动udevsystemd-logind

然后,您将能够完成先前失败的dpkg配置步骤(dpkg --configure -a)。

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/9463.html,未经允许,请勿转载。