How can I import a vhdx image on Windows 11 that I exported from another broken WSL2 on a Windows 10 PC?

Mky 0 Reputation points
2023-08-18T17:40:41.85+00:00

I want to import a vhdx image on windows 11 that I exported from another broken WSL2 on a Windows 10 PC. I try to excute

Mount-VHD -Path "D:\wsl\docker-desktop-data\ext4.vhdx"
wsl --mount "D:\wsl\docker-desktop-data\ext4.vhdx"

but error "The process cannot access the file because it is being used by another process(transrated from japanese)". I think the old WSL2 is still using the vhdx. how can I cut the connection? The old PC is already broken, but the vhdx is on an external hard drive, so I can still access the vhdx file.

Windows for business | Windows Client for IT Pros | Storage high availability | Virtualization and Hyper-V
Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 44,766 Reputation points
    2023-08-21T13:03:26.2933333+00:00

    Hello there,

    Open PowerShell or Command Prompt and list all the currently running WSL instances to identify the one that's using the VHDX image. Run the following command:

    wsl --list --verbose

    This command will display a list of all installed WSL instances, their status, and the paths to their root file systems.

    1. Stop the Old WSL Instance:

    Identify the old WSL2 instance that's using the VHDX image. It will likely have the same name you used when importing the VHDX image in the previous steps.

    To stop the WSL2 instance, run the following command, replacing your_distro_name with the name of the old instance:

    wsl --terminate your_distro_name

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer–


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.