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 under windows using WSL2. Fails to mount with error code: -1 #6319

Closed
IAmV0id opened this issue Dec 7, 2020 · 13 comments
Assignees

Comments

@IAmV0id
Copy link

IAmV0id commented Dec 7, 2020

Environment

Windows build number: Microsoft Windows [Version 10.0.20270.1]
Your Distribution version: Ubuntu 20.04
Problem is on WSL2

Steps to reproduce

Open powershell with administrative privileges
run 'wsl --mount \.\PHYSICALDRIVE2'
Powershell will say The disk \\.\PHYSICALDRIVE2 was attached from WSL2, but failed to mount (error code: -1). For more details, run 'dmesg' inside WSL2.

Expected behavior

The EXT4 partition to mount correctly allowing me to access it.

Actual behavior

EXT4 partition is attached but not mounted, causing me to not be able to access the contents.

image

The dmesg output is [ 0.008340] Microsoft 4.4.0-20270.1-Microsoft 4.4.35

@IAmV0id
Copy link
Author

IAmV0id commented Dec 7, 2020

Nevermind, solved it by adding --partition 1 to the end. A bit odd considering the disk only has one partition though.

@IAmV0id IAmV0id closed this as completed Dec 7, 2020
@IAmV0id IAmV0id reopened this Dec 7, 2020
@IAmV0id
Copy link
Author

IAmV0id commented Dec 7, 2020

The mounted partition does not show up under /mnt, reopening this issue.
image

@OneBlue
Copy link
Collaborator

OneBlue commented Dec 9, 2020

Thanks for reporting this @A-Random-Lantern.

Also, to give some context on --partition: by default WSL attempts to mount the entire block device as if it was unpartitioned (ex: mount /dev/sda)

Can you please follow 7) and 8) in these instructions so we can have a look at the logs ?
Also, what if you try to access to access /mnt from wsl ? What's the output of ls /mnt/wsl ?

@IAmV0id
Copy link
Author

IAmV0id commented Dec 9, 2020

Here's my logs
https://pastebin.com/nju2mxaM

And my feedback report.
https://aka.ms/AAaklz4

I tried ls /mnt/wsl to check earlier, all I got was "c" and "d"

@IAmV0id IAmV0id closed this as completed Dec 9, 2020
@IAmV0id
Copy link
Author

IAmV0id commented Dec 9, 2020

Sorry, accidentally closed the issue.

@IAmV0id IAmV0id reopened this Dec 9, 2020
@OneBlue
Copy link
Collaborator

OneBlue commented Dec 15, 2020

Thanks @A-Random-Lantern .
Unfortunately I don't see any repro logs in the feedback hub item.

Can you confirm that you followed the Start recording steps in the 'Recreate your problem' section, and if not, can you please publish another entry with a problem recording ?

@IAmV0id
Copy link
Author

IAmV0id commented Dec 15, 2020

Sorry, here's the new link.

The G drive is my NTFS external drive by the way. https://aka.ms/AAamd0c

@OneBlue
Copy link
Collaborator

OneBlue commented Dec 17, 2020

Thanks @A-Random-Lantern .

So if you're disk is ntfs, it's expected that wsl --mount --partition 1 fails because ntfs isn't supported by the linux kernel we ship.
From the documentation:

Only filesystems that are natively supported in the kernel can be mounted by wsl --mount. This means that it's not possible to use installed filesystem drivers (such as ntfs-3g for example) by calling wsl --mount.

In your case, the way to mount this disk would be to first attach it to WSL2 with: wsl --mount \\.\PHYSICALDRIVE2 --bare, and then mount it manually inside WSL2: mkdir -p /mnt/wsl/PHYSICALDRIVE2p1 && mount /dev/sdX1 /mnt/wsl/PHYSICALDRIVE2p1 (replace sdX1 with the block device matching your disk. You can use lsblk to view available block devices).

Also ntfs-3g needs to be installed in your distro for this to work.

What's interesting though, is that if your disk is ntfs, you should get an error message if you try to mount it. Can you show the output of wsl --mount \\.\PHYSICALDRIVE2 --partition 1 ? And, after running that, the output of dmesg and mount inside WSL2 ?

@IAmV0id
Copy link
Author

IAmV0id commented Dec 17, 2020

Ah, the ntfs drive isn't the one I'm trying to mount. I was just clarifying that to avoid confusion, as there was no G drive in the original image above.

Sorry for any confusion caused by this, the current drive I'm trying to mount is EXT4

@OneBlue
Copy link
Collaborator

OneBlue commented Dec 17, 2020

No problems. Can you share the output of the above three commands then ? That would help us locate the source of the issue.

@IAmV0id
Copy link
Author

IAmV0id commented Dec 17, 2020

Sure, here you go.

Here's the output for powershell:
The disk \\.\PHYSICALDRIVE2 was successfully mounted under the name 'PHYSICALDRIVE2p1'. The mountpoint can be found under the path pointed to by the automount setting (default: /mnt/wsl). To unmount and detach the disk, run 'wsl --unmount \\.\PHYSICALDRIVE2'.

And here's the outputs in WSL:
[ 0.005170] Microsoft 4.4.0-20279.1-Microsoft 4.4.35 dmesg command

rootfs on / type wslfs (rw,noatime) none on /dev type tmpfs (rw,noatime,mode=755) sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime) proc on /proc type proc (rw,nosuid,nodev,noexec,noatime) devpts on /dev/pts type devpts (rw,nosuid,noexec,noatime,gid=5,mode=620) none on /run type tmpfs (rw,nosuid,noexec,noatime,mode=755) none on /run/lock type tmpfs (rw,nosuid,nodev,noexec,noatime) none on /run/shm type tmpfs (rw,nosuid,nodev,noatime) none on /run/user type tmpfs (rw,nosuid,nodev,noexec,noatime,mode=755) binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,relatime) tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,relatime,mode=755) cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices) C:\ on /mnt/c type drvfs (rw,noatime,uid=1000,gid=1000,case=off) D:\ on /mnt/d type drvfs (rw,noatime,uid=1000,gid=1000,case=off) G:\ on /mnt/g type drvfs (rw,noatime,uid=1000,gid=1000,case=off) mount command

@OneBlue
Copy link
Collaborator

OneBlue commented Dec 18, 2020

Interesting. Based on those logs, it looks like you're using WSL1, but wsl --mount is only supported in WSL2.

Do you have distros in both WSL1 and WSL2 ? (you can find that out by running wsl -l -v) ?

If you mount a disk, it's only accessible in WSL2 distros.

@IAmV0id
Copy link
Author

IAmV0id commented Dec 19, 2020

Yeah, found the problem thanks to you. I installed the linux distro under WSL 1 since I haven't set the default to WSL 2. I just tried mounting again, the drive mounts correctly now and I can access it.

Closing the issue, sorry if this was a time waste haha.

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

2 participants