WSL: WSL2: Process cannot access the file because it is being used by another process
Environment
Windows build number: 10.0.21277.1000
Your Distribution version: Ubuntu-20.04
Whether the issue is on WSL 2 and/or WSL 1: WSL2
Steps to reproduce
After upgrading processor in system, WSL2 no longer starts with the error “The process cannot access the file because it is being used by another process.” I have ensured that virtualization is enabled and the WSL Windows Features are there.
WSL logs: Logs will be in Win+F Feedback per instructions.
C:\Users\marius>wmic diskdrive get Availability,Capabilities,CapabilityDescriptions,DeviceID,InterfaceType,MediaLoaded,MediaType,Model,Name,Partitions
Availability Capabilities CapabilityDescriptions DeviceID InterfaceType MediaLoaded MediaType Model Name Partitions
{3, 4} {"Random Access", "Supports Writing"} \\.\PHYSICALDRIVE2 SCSI TRUE Fixed hard disk media NVMe Samsung SSD 970 SCSI Disk Device \\.\PHYSICALDRIVE2 1
{3, 4} {"Random Access", "Supports Writing"} \\.\PHYSICALDRIVE0 IDE TRUE Fixed hard disk media WDC WD4005FZBX-00K5WB0 \\.\PHYSICALDRIVE0 1
{3, 4} {"Random Access", "Supports Writing"} \\.\PHYSICALDRIVE1 SCSI TRUE Fixed hard disk media NVMe Samsung SSD 970 SCSI Disk Device \\.\PHYSICALDRIVE1 3
Expected behavior
WSL2 Starts up.
Actual behavior
WSL2 does not start.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 19
- Comments: 25
Try to check if you had accidently mounted virtual disk to the window system. Check disk management and if you see virtual disk ,just detach it from the system.
This worked magic! Go to the Windows Command Prompt and type:
netsh winsock resetThen Restart your computer. NB: Don’t Shutdown since it did not work for me. Instead, Restart!
Same error, and https://github.com/microsoft/WSL/issues/5092#issuecomment-615545141 saves me.
I’ve been fighting this issue for months and nothing has been working, so I switched back to WSL 1. Very frustrating.
Today I found out that if I kill every non essential process with task manager, it works. What I find frustrating is: There is no way to tell which file can’t be accessed, and which process is using this “file”
All the “fixes” are just random solutions by random people running random commands that happened to work for them. Is there a sane and civilized way to figure out what resource is being used and how to release it, or are developers on Microsoft’s platforms just satisfied with random trial and error to solve their problems?
The VHDX that WSL2 uses is being locked by another application. It should be located at:
C:\Users\[user]\AppData\Local\Packages\[distro]\LocalState\[distroPackageName]Use an application like the Sysinternals handle utility to search for lock handles on VHDX files: (note: run this in an elevated terminal)
In my case, it was Backblaze trying to back it up, so I added VHDX to the list of excluded file extensions in Backblaze.
As a side note, it appears that if you have the virtual drive saved to a location that syncs using OneDrive, if OneDrive starts the sync then you have to kill OneDrive before being able to access WSL.
You cannot do that. When you use
--importyou are going to create a file calledext4.vhdxin the mentioned directory (E:\wsl), and what you are doing is this:Just rename
E:\wsl\ext4.vhdxtoE:\wsl\ext4-source.vhdxfor example, and do the same, like:I had this error : “The process cannot access the file because it is being used by another process. Error code: Wsl/0x80070020” because I was moving my wsl2 from c: to d: with the
wsl --importcommand.Try to run (win + r)
diskmgmt.mscin windows to see the disk manager. I had the same problem and windows had automatically mount my ext4.vhdx, it was listed as a unidentified virtual drive of 256G, just right click on it and selectUnmount diskordetachnot sure. After that thewsl --importcommand worked for me.How To solve errors in ext4.vhdx while moving or mounting WSL2 distro (docker-desktop-data in my case)
WSL2: Process cannot access the file because it is being used by another process
Can’t mount ext4 partition (error 0x80070020 - the file is being used by another process)
Error code: Wsl/Service/AttachDisk/WSL_E_ELEVATION_NEEDED_TO_MOUNT_DISK
wsl --shutdownD:\Docker\wsl\distro>wsl -l -vNAME STATE VERSION* Ubuntu Stopped 2docker-desktop-data Stopped 2docker-desktop Stopped 2d:/docker/wsl/distrowsl --unregister docker-desktop-data ext4.vhdxwsl --import-in-place docker-desktop-data ext4.vhdxD:\Docker\wsl\distro> wsl -l -vNAME STATE VERSION* Ubuntu Running 2docker-desktop-data Running 2docker-desktop Running 2Thanks a lot, this worked for me ❤️
Try starting LxssManager service:

Set it to run on boot.
It gives same error when LxssManager is set to manual and is stopped
feedback link: https://aka.ms/AAarxss