Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't mount ext4 partition (error 0x80070020 - the file is being used by another process) #8954

Closed
1 of 2 tasks
digfish opened this issue Oct 5, 2022 · 9 comments
Closed
1 of 2 tasks

Comments

@digfish
Copy link

digfish commented Oct 5, 2022

Version

10.0.25211.1010

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.15.62.1-microsoft-standard-WSL2

Distro Version

Ubuntu 22.04

Other Software

No response

Repro Steps

Open CMD
Run --mount \\.\PHYSICALDRIVE0 --partition 2

Expected Behavior

The external partition, which is ext4, should be mounted in /mnt/ inside the WSL root

Actual Behavior

O processo não pode aceder ao ficheiro porque este está a ser utilizado por outro processo.
Error code: Wsl/Service/AttachDisk/0x80070020

Diagnostic Logs

No response

@blami
Copy link

blami commented Oct 5, 2022

Is \\.\PHYSICALDRIVE0 disk marked as Offline in Disk Management? Afaik WSL2 shares same safety mechanism as HyperV and won't allow to mount partition from drive that host Windows can access simultaneously (which is pretty limiting on laptop and would be super useful for dualboot setups).

Administrator access is required to attach a disk to WSL 2. The WSL 2 mount command does not support mounting a disk (or partitions that belong to the disk) that is currently in use.

Emphasis is mine, see: https://learn.microsoft.com/en-us/windows/wsl/wsl2-mount-disk

@digfish
Copy link
Author

digfish commented Oct 5, 2022

Is \\.\PHYSICALDRIVE0 disk marked as Offline in Disk Management? Afaik WSL2 shares same safety mechanism as HyperV and won't allow to mount partition from drive that host Windows can access simultaneously (which is pretty limiting on laptop and would be super useful for dualboot setups).

Administrator access is required to attach a disk to WSL 2. The WSL 2 mount command does not support mounting a disk (or partitions that belong to the disk) that is currently in use.

Emphasis is mine, see: https://learn.microsoft.com/en-us/windows/wsl/wsl2-mount-disk

Thanks for your quick reply,
In reality, the ext4 partition I want to mount belongs to a disk with an already existing NTFS partition in it. So that is the reason... What I wanted to do was a home partition that belonged to a physical installation of Ubuntu. But since I runned with problems (every time I booted windows the root partition of Ubuntu got damaged), so I switched to using WSL or a Ubuntu running inside VMWare. A possible alternative I'm thinking of is using a 3rd party ext driver on windows, mount the partition using the driver, and then share the new mounted drive via SMB/CIFS with WSL and the virtual machine. Let's see if that works.

@digfish
Copy link
Author

digfish commented Oct 5, 2022

For someone that found this thread through search, I found a possible solution at: https://stackoverflow.com/questions/45244306/mounting-a-windows-share-in-windows-subsystem-for-linux
it involves using the command inside WSL: mount -t drvfs 'DriveLetter:' /mnt/point with que quotes and you don't need to use CIFS/SMB. Now I have what I want !

@xiaokentrl
Copy link

I want WSL to mount NTFS format disk directly, or provide an official .exe application to solve the situation of slow IO caused by NTFS, I don't want to have to do everything by myself.

@murder
Copy link

murder commented Dec 8, 2022

https://learn.microsoft.com/en-us/windows/wsl/wsl2-mount-disk#limitations

At this time, only entire disks can be attached to WSL 2, meaning that it's not possible to attach only a partition. Concretely, this means that it's not possible to use wsl --mount to read a partition on the boot device, because that device can't be detached from Windows.`

  1. Forget about trying to mount if it's not the whole disk - --partition is cosmetic right now
  2. Forget about trying to mount your dualboot distro if they share the same disk with Windows
  3. Don't waste your thoughts on --bare

I've opened a new Feature Request - #9283

@zmz2333
Copy link

zmz2333 commented Jan 10, 2023

Try to go to the Windows Command Prompt and type:

netsh winsock reset

Then Restart your computer.

From #6415 (comment)

It works.

@Firestar-Reimu
Copy link

Firestar-Reimu commented Mar 1, 2023

Is \.\PHYSICALDRIVE0 disk marked as Offline in Disk Management? Afaik WSL2 shares same safety mechanism as HyperV and won't allow to mount partition from drive that host Windows can access simultaneously (which is pretty limiting on laptop and would be super useful for dualboot setups).

I run in the same issue. I have only one disk and I cannot mark it as Offline in Disk Management

I have 3 partitions, 2 NTFS for windows (C:\ and D:) and 1 for Linux (btrfs)

I want to mount the Linux partition

Now what can I do?

PS C:\Users\Firestar> wsl -v
WSL: 1.1.3.0
Kernel: 5.15.90.1
WSLg: 1.0.49
MSRDC: 1.2.3770
Direct3D: 1.608.2-61064218
DXCore: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows: 10.0.22623.1325

netsh winsock reset does not work

@blami
Copy link

blami commented Mar 3, 2023

Now what can I do?

Nothing. It is impossible to mount drive that is not marked offline. The only thing that can be done is to transfer btrfs partition to other drive and mark it offline or convert partition to disk image file using e.g. Disk2vhd utility from SysInternals.

As I've said its pretty limiting but HyperV is proprietary closed source software fully controlled by Microsoft and only they can change behavior and allow mounting separate partitions (as e.g. VirtualBox did).

Copy link
Contributor

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants