WSL: bash fails on WSL2: filesystem mounting error

Environment

Windows build number: 10.0.20211.1000
Your Distribution version: Buster 10.5
Linux version 4.19.128-microsoft-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Tue Jun 23 12:58:10 UTC 2020

Steps to reproduce

After installing Ubuntu or Debian on WSL2, attempt to use bash by running bash from powershell.

Expected behavior

This should start up bash and return a bash prompt.

Actual behavior

The bash command fails with the following error:

An error occurred mounting one of your file systems. Please run 'dmesg' for more details.

Following these instructions, here is the relevant output from dmesg:

[   73.412597] scsi 0:0:0:2: Direct-Access     Msft     Virtual Disk     1.0  PQ: 0 ANSI: 5
[   73.413019] sd 0:0:0:2: Attached scsi generic sg2 type 0
[   73.413792] sd 0:0:0:2: [sdc] 536870912 512-byte logical blocks: (275 GB/256 GiB)
[   73.413793] sd 0:0:0:2: [sdc] 4096-byte physical blocks
[   73.413873] sd 0:0:0:2: [sdc] Write Protect is off
[   73.413874] sd 0:0:0:2: [sdc] Mode Sense: 0f 00 00 00
[   73.414166] sd 0:0:0:2: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[   73.416782] sd 0:0:0:2: [sdc] Attached SCSI disk
[   73.433954] EXT4-fs (sdc): mounted filesystem with ordered data mode. Opts: discard,errors=remount-ro,data=ordered
[   73.445959] init: (1) ERROR: ConfigApplyWindowsLibPath:2259: open /etc/ld.so.conf.d/ld.wsl.conf
[   73.445961]  failed 2
[   73.448223] init: (2) ERROR: UtilCreateProcessAndWait:627: /bin/mount failed with 2
[   73.448290] init: (1) ERROR: UtilCreateProcessAndWait:647: /bin/mount failed with status 0x
[   73.448291] ff00
[   73.448295] init: (1) ERROR: ConfigMountFsTab:2314: Processing fstab with mount -a failed.
[   73.454506] hv_pci 5ff70487-d970-4734-9a18-b73b0a85682b: PCI VMBus probing: Using version 0x10002
[   73.465479] WARNING: /usr/share/zoneinfo/America/Chicago not found. Is the tzdata package installed?
[   73.497468] hv_pci 5ff70487-d970-4734-9a18-b73b0a85682b: PCI host bridge to bus 9a18:00
[   73.497470] pci_bus 9a18:00: root bus resource [mem 0xe00008000-0xe0000afff window]
[   73.497969] pci 9a18:00:00.0: [1af4:1049] type 00 class 0x010000
[   73.499651] pci 9a18:00:00.0: reg 0x10: [mem 0xe00008000-0xe00008fff 64bit]
[   73.500513] pci 9a18:00:00.0: reg 0x18: [mem 0xe00009000-0xe00009fff 64bit]
[   73.501407] pci 9a18:00:00.0: reg 0x20: [mem 0xe0000a000-0xe0000afff 64bit]
[   73.505420] pci 9a18:00:00.0: BAR 0: assigned [mem 0xe00008000-0xe00008fff 64bit]
[   73.505917] pci 9a18:00:00.0: BAR 2: assigned [mem 0xe00009000-0xe00009fff 64bit]
[   73.506369] pci 9a18:00:00.0: BAR 4: assigned [mem 0xe0000a000-0xe0000afff 64bit]
[   73.524925] init: (8) ERROR: CreateProcessEntryCommon:427: getpwuid(0) failed 2
[   73.524929] init: (8) ERROR: CreateProcessEntryCommon:430: getpwuid(0) failed 2
[   73.529364] init: (8) ERROR: CreateProcessEntryCommon:593: execvpe /bin/bash failed 2

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 7
  • Comments: 25 (1 by maintainers)

Most upvoted comments

In my case, this was caused by having the “experimental” WSL2 + Docker Desktop integration enabled.

The “default distro” was one of the “distros” Docker installs. wsl -l to discover this and wsl -d <myDistro>to explicitly select the distro “fixed” my problem. I will be changing the default and seeing how that goes too.

For everyone’s convenience, the command to set the default is wsl -s <myDistro>.

Success for me:

Credit to @kevin-david for pointing out that the default distro needed setting

In my case, this was caused by having the “experimental” WSL2 + Docker Desktop integration enabled.

The “default distro” was one of the “distros” Docker installs. wsl -l to discover this and wsl -d <myDistro> (should be: wsl -s <myDistro> - this actually set the distro in my case ) to explicitly select the distro “fixed” my problem. I will be changing the default and seeing how that goes too.

Credit to @stevegore for advising on the wsl option switch -s to use to set the default distro:

command to set the default is wsl -s <myDistro>.

Summary

Yes this helped me. My “default distro” was docker-desktop-data of all things! What the hell is docker-desktop-data and why would WSL2 think that was a distro?! So I changed it to Ubuntu and this solved the issue.

Detail

See my Windows PowerShell (PS) terminal excerpts below.

PS > wsl -l
Windows Subsystem for Linux Distributions:
docker-desktop-data (Default)
Ubuntu
docker-desktop

So I changed this to Ubuntu

PS > wsl -s Ubuntu

Then I verified that the default was now still Ubuntu, and it was:

PS > wsl -l
Windows Subsystem for Linux Distributions:
Ubuntu (Default)
docker-desktop-data
docker-desktop
PS >

Then I quit any VSCode windows running, deleted .vscode-server in Ubuntu terminal (so it would rebuild it cleanly on rerunning vscode later after the above fix) And then I shutdown WSL2:

wsl --shutdown

Then following this, as expected, I got a notification from Docker Desktop about unexpectedly closed and would I like to restart, with a button to restart. This was to be expected following the shutdown command above. So I did this - clicked restart for docker desktop and waited for the little docker whale and cargo to stop animating and then ran Ubuntu again.

And now successful: Then I typed code in the Ubuntu terminal. Visual Studio Code fired up and in the bottom left corner, reassuringly: “WSL: Ubuntu” showed.

image

Background

Before this solution I had seen this error in the terminal log in vscode:

VS Code Server for WSL closed unexpectedly and couldn’t determine if the vscode server running.

Other things I had done to resolve this issue:

  • I had checked that WSL integration was enabled for my default distro “Ubuntu” (but funny how wsl -l had reported the default as not is but docker-desktop-data ! )
  • I had installed the ca cert as the vscode official troubleshooting advised.

Including vscode log output for informational purposes and seo to help others get to this issue solutions to help them:

[2022-08-15 14:54:13.410] Resolving wsl+docker-desktop-data, resolveAttempt: 1
[2022-08-15 14:54:13.744] Starting VS Code Server inside WSL (wsl2)
[2022-08-15 14:54:13.744] Extension version: 0.66.3
[2022-08-15 14:54:13.744] Windows build: 22000. Multi distro support: available. WSL path support: enabled
[2022-08-15 14:54:13.744] No shell environment set or found for current distro.
[2022-08-15 14:54:13.871] WSL daemon log file: 
[2022-08-15 14:54:13.872] Probing if server is already installed: C:\WINDOWS\System32\wsl.exe -d docker-desktop-data -e sh -c "[ -d ~/.vscode-server/bin/6d9b74a70ca9c7733b29f0456fd8195364076dda ] && printf found || ([ -f /etc/alpine-release ] && printf alpine-; uname -m)"
[2022-08-15 14:54:13.988] Unable to detect if server is already installed: Error: Command failed: C:\WINDOWS\System32\wsl.exe -d docker-desktop-data -e sh -c "[ -d ~/.vscode-server/bin/6d9b74a70ca9c7733b29f0456fd8195364076dda ] && printf found || ([ -f /etc/alpine-release ] && printf alpine-; uname -m)"
[2022-08-15 14:54:13.988] 
[2022-08-15 14:54:13.989] Launching C:\WINDOWS\System32\wsl.exe -d docker-desktop-data sh -c '"$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh" 6d9b74a70ca9c7733b29f0456fd8195364076dda stable code-server .vscode-server --host=127.0.0.1 --port=0 --connection-token=455946950-893323131-2587450687-799670964 --use-host-proxy --without-browser-env-var --disable-websocket-compression --accept-server-license-terms --telemetry-level=all'
[2022-08-15 14:54:14.107] VS Code Server for WSL closed unexpectedly.
[2022-08-15 14:54:14.107] For help with startup problems, go to https://code.visualstudio.com/docs/remote/troubleshooting#_wsl-tips
[2022-08-15 14:54:14.118] WSL Daemon exited with code 0
[2022-08-15 14:54:21.089] Resolving wsl+docker-desktop-data, resolveAttempt: 2
[2022-08-15 14:54:21.149] Starting VS Code Server inside WSL (wsl2)
[2022-08-15 14:54:21.149] Extension version: 0.66.3
[2022-08-15 14:54:21.149] Windows build: 22000. Multi distro support: available. WSL path support: enabled
[2022-08-15 14:54:21.150] No shell environment set or found for current distro.
[2022-08-15 14:54:21.323] WSL daemon log file: 
[2022-08-15 14:54:21.325] Probing if server is already installed: C:\WINDOWS\System32\wsl.exe -d docker-desktop-data -e sh -c "[ -d ~/.vscode-server/bin/6d9b74a70ca9c7733b29f0456fd8195364076dda ] && printf found || ([ -f /etc/alpine-release ] && printf alpine-; uname -m)"
[2022-08-15 14:54:21.470] Unable to detect if server is already installed: Error: Command failed: C:\WINDOWS\System32\wsl.exe -d docker-desktop-data -e sh -c "[ -d ~/.vscode-server/bin/6d9b74a70ca9c7733b29f0456fd8195364076dda ] && printf found || ([ -f /etc/alpine-release ] && printf alpine-; uname -m)"
[2022-08-15 14:54:21.470] 

None of the above work… is there any more recent workaround for 2023? I’ve build an image off ubi8 or rockylinux8 but I am getting the same error after importing it into WSL2.

FROM rockylinux/rockylinux:8.8

ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;
VOLUME [ "/sys/fs/cgroup" ]
CMD ["/usr/sbin/init"]

RUN <<EOF cat >> /etc/wsl.conf
[boot]
systemd=true
EOF

Yield:

<3>WSL (11) ERROR: CreateProcessEntryCommon:370: getpwuid(0) failed 2
<3>WSL (11) ERROR: CreateProcessEntryCommon:374: getpwuid(0) failed 2
<3>WSL (11) ERROR: CreateProcessEntryCommon:577: execvpe /bin/sh failed 2
<3>WSL (11) ERROR: CreateProcessEntryCommon:586: Create process not expected to return

i’ve doing something wrong command that delete docker-desktop-data

  1. wsl --unregister docker-desktop-data

but i found solution fot this prolem. do this :

  1. wsl --install Ubuntu
  2. wsl -s Ubuntu
  3. wsl -d Ubuntu
  4. exit
  5. turn off auto start docker-desktop
  6. restart your computer

And start docker-desktop manually and the docker-desktop will using Ubuntu for wsl

hope this help

在我的情况下,这是由于启用了“实验性”WSL2 + Docker 桌面集成而导致的。 “默认发行版”是 Docker 安装的“发行版”之一。 以发现这一点并明确选择发行版“修复”我的问题。我将更改默认值,看看情况如何。 wsl -lwsl -d <myDistro> ``

Oh!After change the defaluft wsl to ububtu,it works well now .Thank you so much!

That was the problem on my side as well! To fix: wsl -l wsl -s Ubuntu wsl -l

Here’s how I fixed mine:

  • Run wsl -l to find which distro is currently the default distro
  • For me it was docker-desktop
  • Then run wsl --set-default Ubuntu as the default WSL distribution
  • That’s it, it should work for you

In my case, this was caused by having the “experimental” WSL2 + Docker Desktop integration enabled.

The “default distro” was one of the “distros” Docker installs. wsl -l to discover this and wsl -d <myDistro>to explicitly select the distro “fixed” my problem. I will be changing the default and seeing how that goes too.

Oh!After change the defaluft wsl to ububtu,it works well now .Thank you so much!

For everyone struggling, I’ve been in this place, and the steps I followed:

  1. wsl --shutdown
  2. first of all make sure you have wsl -s <myDistro> by running wsl -l (e.g. Ubuntu you should fond the default set to Ubuntu)
  3. wsl ~ -e zsh
  4. sudo nano /etc/pam.d/chsh
  5. Replacing
  • auth required pam_shells.so with
  • auth sufficient pam_shells.so

then exit and rerun wsl

I hope you find this helpful

Try using wsl command instead.