microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.52k stars 822 forks source link

bash fails on WSL2: filesystem mounting error #5923

Open fonnesbeck opened 4 years ago

fonnesbeck commented 4 years ago

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
WSLUser commented 4 years ago

Try using wslcommand instead.

fonnesbeck commented 4 years ago

This gives me the same error, unfortunately.

fonnesbeck commented 4 years ago

If I do open a Debian instance directly, it does start up without error, and everything appears to be mounted correctly, so its curious why wsl and bash fail as they do.

WSLUser commented 4 years ago

Bash command is deprecated so if it breaks, no big deal. But wsl command should work. Try re-installing the VMM feature and see if that helps

fonnesbeck commented 4 years ago

Are you referring to HyperV?

WSLUser commented 4 years ago

No. That is the feature that enables WSL2.

blackliner commented 4 years ago

I have that quite frequently, especially if i start WSL very quickly after a reboot. What helps usually: wsl --shutdown

kevin-david commented 3 years ago

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.

PatrickGhosn commented 3 years ago

@kevin-david Your way fixed it for me as well. Thanks!

stevegore commented 3 years ago

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

therobyouknow commented 2 years ago

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:

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] 
LikeGhost commented 2 years ago

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!

diman82 commented 2 years ago

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

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

marvin-hris commented 1 year ago

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

totszwai commented 1 year ago

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
Chuukwudi commented 1 year ago

@totszwai , I was having the same error. Even after applying the solutions found here, I still had the same error as you. I solved it by uninstalling and reinstalling the WSL extension from VScode. I discovered that VScode was still pointing to the distro created by docker-desktop, despite changing it as stated here, so uninstalling and reinstalling corrected this. Also, restart vscode. or even your entire system. I hope this works.

Kilvny commented 1 year ago

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

then exit and rerun wsl

I hope you find this helpful

loweffort-alt commented 1 year ago

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.

Thanks, I installed wsl2 with Docker and forgot install distro directly. Make wsl --install to install Ubuntu latest version by default.

fredmo commented 1 year ago

On my side, the error is linked to the multipartition on the HDD usb :

[ 1350.756536] scsi 0:0:0:3: Direct-Access Seagate BUP RD 0108 PQ: 0 ANSI: 6 [ 1350.763093] sd 0:0:0:3: Attached scsi generic sg3 type 0 [ 1350.764411] sd 0:0:0:3: [sdd] 7814037167 512-byte logical blocks: (4.00 TB/3.64 TiB) [ 1350.764911] sd 0:0:0:3: [sdd] 4096-byte physical blocks [ 1350.765980] sd 0:0:0:3: [sdd] Write Protect is off [ 1350.766278] sd 0:0:0:3: [sdd] Mode Sense: 0f 00 00 00 [ 1350.767942] sd 0:0:0:3: [sdd] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA [ 1350.768448] sd 0:0:0:3: [sdd] Optimal transfer size 33553920 bytes not a multiple of physical block size (4096 bytes) [ 1350.859538] sdd: sdd1 sdd2 [ 1350.891833] sd 0:0:0:3: [sdd] Attached SCSI disk [ 1350.993263] WSL (2377): Detected (null) filesystem for device: /dev/sdd [ 1350.994116] WSL (2377) ERROR: UtilMount:1626: mount(/dev/sdd, /mnt/wsl/PHYSICALDRIVE1, (null) [ 1350.994118] , 0x0, ) failed 22

I must do a manual mount in WSL2.

milosrs commented 1 year ago

For me, restarting the subsystem did the job

  1. Run wsl -l -v to find the default distro:
    Ubuntu                 Running         2
    * docker-desktop         Stopped         2
    docker-desktop-data    Stopped         2
  2. For me, first error was that docker-desktop was set as default. Run wsl --set-default {YOUR_DISTRO}
  3. If you still get errors, that may be because YOUR_DISTRO is running like in my case.
  4. Run wsl -t YOUR_DISTRO
  5. Reconnect. Everything should work now.
DonGuillotine commented 1 year ago

Here's how I fixed mine:

osl-masum commented 11 months ago

yes, if you have Docker installed in your OS, then docker-desktop-data becomes the default distro which does not work with bash or wsl. It works fine after making Ubuntu the default distro by command wsl -d Ubuntu.

mahsammalik commented 10 months ago

After switching the default WSL to Ubuntu, everything is functioning properly now. Thank you very much!

adesokan247 commented 6 months ago

wsl -d

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.

please how do i use ''' wsl -d ''' its showing me error