22

I have been playing with the new linux subsystem on Windows and somehow i have broken it and now most of Ubuntu's internals (apt-get,dpkg, etc) don't work. Everything i try something i get the same message...

    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)

Any ideas how to fix this?

Mike Pengelly
  • 595
  • 2
  • 5
  • 15
  • Is there a "reset" or uninstall/reinstall option? That's probably the easiest & fastest. Any idea what you did to have this happen? Erase root (`/`) or something? – Xen2050 Apr 13 '16 at 02:47
  • 1
    Per [AskUbuntu](http://askubuntu.com/questions/614970/vivid-failed-to-connect-to-upstart-connection-refused), try: `sudo apt-get install upstart-sysv` for a quick fix - that post has a link to the "recommended" fix as well. Not sure it's the same problem, but it looks like it _might_ be related. – tanner Apr 13 '16 at 04:03
  • I was trying to get xserver to work after reading that someone got it working on windows... i think i might have installed to new of a version. But not entirely sure what caused it. Apt-get wont install anything with out giving me that error. I tried removing the feature from windows and re adding it but it just loads the same subsystem configuration as before; can't find a way to reload default anywhere. – Mike Pengelly Apr 13 '16 at 04:26
  • 1
    Possible duplicate of [How to remove/reset to factory Ubuntu in Windows 10 Insider Preview 14316](http://superuser.com/questions/1065569/how-to-remove-reset-to-factory-ubuntu-in-windows-10-insider-preview-14316) – Ramhound Apr 15 '16 at 12:56
  • 1
    @ Ramhound I did not ask how to reinstall Bash on Ubuntu on Windows 10, i asked how to fix the problem. I have never had this problem in actually Ubuntu. If going Nuclear is fixing problems, then i don't want to be around when they fix global warming – Mike Pengelly Apr 15 '16 at 20:19
  • @MikePengelly - What order a question is asked, doesn't decide if it can or cannot be a duplicate of another question, its the order they were answered in even then its just a matter of saying the answer of an existing answer also answers this question. – Ramhound Apr 15 '16 at 20:21
  • 1
    @Ramhound But i doesn't answer my question. That's like saying "reinstall windows every time you get an error message" or "buy a new car every time you hear a noise".... It solves to problem but its not a practical solution. – Mike Pengelly Apr 15 '16 at 20:26
  • You can blame Jonas for submitting an identical answer as another question, only reason I flagged it, to be honest. – Ramhound Apr 15 '16 at 20:28

4 Answers4

34

Warning, this process will restore Lxss to initial config

To reinstall the Lxss open Windows cmd as administrator and run:

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

Then:

C:\WINDOWS\system32>LxRun.exe /install
Jonas
  • 349
  • 1
  • 2
  • 3
  • 1
    I did not mark this as the answer because it is a nuclear approach to the problem i was having. Yes it would fix it (in theory, i did not try), but the way i fixed it correct my exact problem with out going nuclear. But if i continue to have problem i would recommend this approach if you want to save hours. In the future though i doubt people would want to reconfigure there Linux Subsystem every time something goes wrong. – Mike Pengelly Apr 15 '16 at 20:09
  • The problem is with the Ubuntu subsystem itself. Reinstalling it won't fix anything – Panagiotis Kanavos Apr 22 '16 at 06:44
  • 2
    @PanagiotisKanavos for those of us finding the question via google (having made a mess in our installs): I can assure you the answer is still very much appreciated! – Marc Gravell Apr 30 '16 at 20:15
  • 2
    You guys are right, this isn't the answer and we should use this as last option. – Jonas May 05 '16 at 02:41
  • I'm getting a `Access is denied.` when I run `C:\WINDOWS\system32>LxRun.exe /uninstall` even if the cmd session is being run "as Administrator". Any ideas? – fredrik May 17 '16 at 13:16
  • runing `lxrun /uninstall /full` will remove the Ubuntu environment as well as any modifications, new applications, and user data. After successful uninstalling run `lxrun /install` command to install subsystem. http://superuser.com/a/1065579/373485 – Mirjalal Aug 08 '16 at 06:02
18

Fixed it.

Ran:

apt-get remove upstart

then

apt-get remove udev

then

apt-get autoremove

and it all seems to be working now.

Mike Pengelly
  • 595
  • 2
  • 5
  • 15
  • 1
    Must have installed when i installed x11 (a too new version) ... btw x server has to run in windows not in the linux subsystem. and then you forward the application by running DISPLAY=0: firefox – Mike Pengelly Apr 13 '16 at 04:50
9

The official response from microsoft

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.

oxenfree
  • 191
  • 3
7

Here is a more targeted solution. Create a script named /usr/sbin/policy-rc.d (nano /usr/sbin/policy-rc.d) with the following contents:

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

Save and exit (Ctrl+O Ctrl+X). Mark the script as executable (chmod +x /usr/sbin/policy-rc.d). This script tells dpkg not to attempt to start udev or systemd-logind.

You will then be able to complete the previously failing dpkg configuration step (dpkg --configure -a).

  • 2
    This is an answer that could be improved by _explaining what happened_, what the "somehow" in the question actually was and how this series of steps addresses it. [Here is one pointer](https://news.ycombinator.com/item?id=11488599) to use. [Here is another](https://github.com/Microsoft/BashOnWindows/issues/143). – JdeBP Apr 19 '16 at 12:30