WSL: ls: cannot access '/mnt/c': Input/output error

  • Your Windows build number: (Type ver at a Windows Command Prompt) Microsoft Windows [Version 10.0.18950.1000]

  • What you’re doing and what’s happening: (Copy&paste the full set of specific command-line steps necessary to reproduce the behavior, and their output. Include screen shots if that helps demonstrate the problem.) Trying to access /mnt/c/ from inside WSL 2

  • What’s wrong / what should be happening instead: Should be able to list files and dirs from /mnt/c/

  • Strace of the failing command, if applicable: (If some_command is failing, then run strace -o some_command.strace -f some_command some_args, and link the contents of some_command.strace in a gist here).

https://gist.github.com/scrossan-crown/827948cabed828a2e040e62fc816d181

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 21
  • Comments: 118 (10 by maintainers)

Most upvoted comments

That error occurs if the hidden wslhost.exe process is died/killed. Just use wsl.exe --shutdown and restart it.

That error occurs if the hidden wslhost.exe process is died/killed. Just use wsl.exe --shutdown and restart it.

this fixes it for me

Essentially, when an operation is interrupted by a signal (e.g. CTRL-C), the 9p client in the Linux kernel will send a “flush” message to cancel the pending request. Our server did not support cancellation, so it would return an error in response to the cancellation attempt.

It turns out the Linux client ignores the response from flush, and assumes that the request has been cancelled as soon as it receives such a response (regardless of whether it’s success or error). Since we didn’t actually cancel the message, we will still send the real response. When the Linux client receives this response, it thinks it’s an invalid message and disconnects from the server, and will return EIO to all requests after that.

This wouldn’t always happen, since if the real response came before the “flush” response, there’s no issue.

One could argue that the Linux client is wrong to consider a request cancelled if the “flush” message returned an error. However, as Ben said, we’ll fix this by handling “flush” correctly in our server. I’m currently testing the fix and we hope to get it into an insider build soon.

Since the server is fine and it’s only the client that’s disconnected, you can actually recover from this without restarting WSL, by just unmounting (sudo umount /mnt/c) and remounting (sudo mount C:\\ /mnt/c; adjust for the appropriate drive letter as needed), but you’d have to make sure that you match the right mount options too (especially the automatically added ones, such as the default owner uid and gid).

Any update on this ? Having to use powerhsell to wsl.exe --shutdown each time I want to open VSCode in WSL mode is exhausting This happens on both of my computer (work and home).

As for me the problem still exists with 90% certainty after every reboot. I always check cd /mnt/c if it is accessible. If not wsl --shutdown and start again. But recenty I installed Ubuntu 18.04 LTS package from Store (alongside with default Ubuntu with this problem). And it occured that this Ubuntu 18.04 doesn’t have this problem at all. It starts always in windows user folder (/mnt/c/Users/<user>).

Some good news: @SvenGroot has identified the issue and is working on a fix.

A +1 on this issue : My wsl always starts in this error state too when i boot windows, no exception. It’s consistently fixed by doing wsl.exe --shutdown. I’m using WSL2 with Ubuntu 18.04.4 LTS on win 10.0.19041.264

you can actually recover from this without restarting WSL, by just unmounting (sudo umount /mnt/c) and remounting (sudo mount C:\\ /mnt/c)

I get this when remounting:

mount: /c: bad option; for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program.

There is no mount.9p under /sbin. This is on a distro migrated from WSL1.

EDIT: adding -t drvfs to the mount command fixed it. So sudo mount -t drvfs C:\\ /mnt/c

I see this issue is closed, yet I’m getting this every day (literally) on Windows 11. Is there any other issue where someone is working on it?

I also use BitLocker as someone mentioned here. The workaround with wsl --shutdown is not so great as I have to reopen everything and also Docker Desktop just dies…

before image

after (what ???) image

yeah you need to restart WSL2 by going to powershell, typing wsl.exe --shutdown and re-open WSL. This has been the case for me for more than 1.5 years now…

Disabling Fast Startup completely resolved the issue for me, though it’s not a feasible solution for everyone.

Yeah there’s still an issue here.

I have a fresh install of the latest stable Windows 10 (19041.329), installed VS code, wsl2 and docker (wsl2 engine). Every time I boot Windows I have to restart WSL2 (wsl --shutdown) otherwise it’s broken.

I’ve got an issue which seems from reading this seems to stem from the same thing. If it’s of any help, I’ve got Docker Technical Preview installed.

Windows Version: 10.0.18980.1

Ubuntu 18.04 WSL2

Steps to reproduce:

  1. Start with a shutdown pc. Turn it on.
  2. Once signed in, open up Windows Terminal(Preview)
  3. Open an Ubuntu tab.
  4. Try running any windows command, such as code or explorer.exe
  5. Terminal will output command not found

To resolve the issue:

  1. Close the Ubuntu session, open a new powershell session and run the command wsl --shutdown
  2. Open up Ubuntu again, run the command code, it should work as expected, by opening vscode in windows, connected to WSL2 Ubuntu.

OR

Simply restart pc. After opening up Ubuntu, code, explorer.exe, and other commands will work as usual.

However, after a restart, any transparency effects (Such as the Windows Terminal’s Acrylic background and the start menu color, will be shut off, with no way of turning them back on again. But I’m sure this has nothing to do with WSL.

@craigloewen-msft @benhillis Could we get this reopened?

Also still experiencing this, intermittently though. Win10 Pro 10.0.19041.264 && Ubuntu 18.04

Just hit this again with:

Version 10.0.19041 Build 19041

NAME STATE VERSION

* Ubuntu-18.04    Running         2

I believe it may have to do with putting windows to sleep.

I’m also seeing this issue periodically, and I agree that it seems to be triggered by putting the PC to sleep. If I leave my WSL2 terminal open, sleep, and wake the computer again, I often have the input/output error.

Windows build 19041.207, Ubuntu 18.04

If I then shut down the WSL2 terminal and try to restart it, the terminal will appear for a moment and then disappear. I have to manually restart the LxssManager service to get things working properly again.

This was supposedly fixed 6 months ago , I encountered the same problem today. I had luck with the following

    sudo umount /mnt/c
    sudo mount -t drvfs C:\\ /mnt/c

Fixed in 18995.

  1. mk the local folder shared
  2. edit the fstab in wsl to mount this folder //DEVICE_NAME/shared_folder /mnt/shared_folder cifs username=xxxx,password=xxxx,iocharset=utf8,sec=ntlm 0 0 the fstab should be like this, I can’t remember clearly. I configured it on the previous computer, but it broke down and I can’t remember the details clearly.

@stoperro @Kumen

wsl.exe --shutdown works, but the problem persists upon restart with any significant I/O (in my case saving ML models and weights using Python).

The simplest solution now is restarting LxssManager in services.msc.

What do we have at the moment? Uncontrolled memory increasing of Vmmem and “cannot access ‘/mnt/c’: Input/output error”. I got the last error when using WSL2’s git inside PHPStorm. If you need to shutdown WSL every time when memory is out of comfort work or wslhost.exe is died, you should find a new environment to do your job. But I don’t want to do this! I’m really happy that I have so powerful tool like WSL. Windows is becoming something really cool for working. But these lacks have been existed for ONE YEAR with no solution.

I’m sorry for non-constructive speech. Just scream of soul. Problem is still here.

Can confirm, just had the same issue after getting windows out of sleep. Edit: Now also after a restart

Just hit this again with:

Version 10.0.19041 Build 19041

NAME STATE VERSION

  • Ubuntu-18.04 Running 2

I believe it may have to do with putting windows to sleep.

@allwelldotdev could you please open a new issue for the error you’re seeing? And could you please include WSL logs in it? That would allow us to determine what could be going on! Thank you!

In case it helps others at all - the solution described here https://superuser.com/a/1747876 worked for me:

In WSL, Use sudo mount -t drvfs DRIVE: /mnt/DRIVE E.g. sudo mount -t drvfs D: /mnt/d

I have discovered a factor that triggers an “Input/output error”. After using a portable hard drive on my computer, when I tried to eject it, it prompted me that it was occupied. I used PowerToys and found that it was dllhost, so I turned off dllhost so that the portable hard drive could be ejected. But immediately, the drive letter mounted under/mnt cannot be accessed in WSL. I repeated the operation and it was indeed triggered by turning off dllhost.

I also encountered this problem. When using rsync to synchronize files, compile projects, and so on, as long as there is a large amount of file IO, it will definitely get stuck

I had this problem, but restarting didn’t work for me…

Bonus: It seems that the filename is too long. windows has a longer maximum filename length than linux

This worked for me wsl.exe --shutdown In my case I think it has to do with the computer suspend/sleep cycle.

@jmtornetta we already know this but we want a real stable solution

wsl --shutdown fixes for me as well

New tracking issue for this seems to be over here: https://github.com/microsoft/WSL/issues/6174

This started happening to me after I installed Docker Desktop, very annoying!

As for me, I reverted back and removed WSL completely. Installed VirtualBox + headless Ubuntu server. Works like a charm (VS Code with Remote SSH extension, working systemd(!), shared folders). Startup time is 5 seconds.

That error occurs if the hidden wslhost.exe process is died/killed. Just use wsl.exe --shutdown and restart it.

this fixes it for me too

Same error, had to wsl --shutdown

+1 with ubuntu 20.04 & win pro .19041.264

This has happened twice for me on 2004 (19041.264) right after a shutdown + reboot, but I cannot consistently reproduce it. It also prevents wsltty from starting up at all as it tries to read its config from drvfs. wsl --shutdown fixes it.

Just had this issue as well:

Distributor ID: Ubuntu Description: Ubuntu 18.04.3 LTS Release: 18.04 Codename: bionic

4.19.84-microsoft-standard

When I tried to remount C drive, I got: umount: /mnt/c: target is busy.

Worked around it with:

lsof | grep "/mnt/c"
killall <processes that appear in list>

I’m hitting this on 18956 - the pattern seems to be doing significant file I/O on the mounted NTFS+BitLockered filesystem. (for example, I’ve got a directory with a few thousand files on it. I can reliably repro this by grep’ing across the files)