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

Enable complete mounting of RAID devices #5999

Open
valinet opened this issue Sep 28, 2020 · 15 comments
Open

Enable complete mounting of RAID devices #5999

valinet opened this issue Sep 28, 2020 · 15 comments
Labels
feature kconfig linux kernel configuration

Comments

@valinet
Copy link

valinet commented Sep 28, 2020

Is your feature request related to a problem? Please describe.
Recently, WSL2 got support for mounting physical disks, which is great. I have 2 disks from a previous Ubuntu server that were set up in software RAID1 in Linux (partition type "linux_drive_member"), and decided to leverage the recently added support and have them show up in Windows, instead of switching their file system to something like NTFS, which Windows supports natively (risk of losing files etc). I could mount the disks using:

wsl --mount \\.\PHYSICALDRIVE4 --bare
wsl --mount \\.\PHYSICALDRIVE5 --bare

Then, in Linux, I tried assembling the array using mdadm: sudo mdadm --assemble /dev/md0 /dev/sdc1 /dev/sdd1, but the following error is returned:

modprobe: FATAL: Module md_mod not found in directory /lib/modules/4.19.128-microsoft-standard
mdadm: Fail create md0 when using /sys/module/md_mod/parameters/new_array
mdadm: unexpected failure opening /dev/md0

That's because the wsl2 kernel is compiled without RAID support. To fix this, one has to clone the kernel from WSL2-Linux-kernel, run make KCONFIG_CONFIG=Microsoft/config-wsl menuconfig, choose "Device Drivers - Multiple devices driver support (RAID and LVM)", and from there, press y on "RAID support", and, in my case, "RAID-1 (mirroring) mode". Then, make KCONFIG_CONFIG=Microsoft/config-wsl to compile the kernel, and set it as the loaded kernel as described here: https://docs.microsoft.com/en-us/windows/wsl/wsl-config.

Now, when running mdadm, it succeeds. What remains is to mount /dev/md0 (for me, it is an ext4 partition) to some directory, in my case: sudo mount /dev/md0 /mnt. All works well, files can be accessed from wsl2. The problem is that when using File Explorer to go to "\\wsl\Ubuntu\mnt", the directory is empty. This is kind of expected, but how to go about it? How to mount things in Linux so that they get mounted in the wsl$ network share as well, and be available from Windows? I tought about specifing it in /etc/fstab and specifying the mountFsTab option in .wslconfig, but the array is not ready at boot (I have to execute those 2 "wsl.exe --mount ..." commands to mount the physical disks inside WSL).

Describe the solution you'd like
Most importantly, a way to properly mount things in WSL and have them show up in Windows, using the network share, as well. Also, you could enable RAID support for the kernel by default, although it was not that hard to compile it (took 4 minutes), and maybe that's not required for most users and you aim for a lightweight kernel after all.

Describe alternatives you've considered
For now, I'll install samba and temporarily have the folder available though that in Windows, although I do not like it as I have to spend time configuring it.

Additional context
Thanks for the great work you are doing.

@valinet
Copy link
Author

valinet commented Sep 28, 2020

Samba would work well for the moment if either:

  • wsl2 would have a fixed IP address
  • "Map Network Drive" would allow specifying a different port (ports can be changed in samba, and as Linux ports are mapped to host by wsl, we could connect to host:port_set_in_wsl_for_samba, but Windows seems to be again, the problem, in that it cannot map a network drive by port as well)

Really, really frustrating, as the performance is very good, and I avoid third party drivers which do not even exist afaik for my use case, but the inconvenience with this 'hack' is major...

Edit: for the moment, I do it using Samba and a set of scripts, I do not like it, but I wanted it now, I specifically installed 20221 just for this.

@therealkenc
Copy link
Collaborator

image

Do Samba over in discussions; you'll bury your own ask here.

@therealkenc therealkenc added the kconfig linux kernel configuration label Sep 28, 2020
@tarmacx
Copy link

tarmacx commented Oct 14, 2020

I just ran into the same issue. Building a docker container to run a custom software that requires RAID.

@OneBlue
Copy link
Collaborator

OneBlue commented Nov 2, 2020

Now, when running mdadm, it succeeds. What remains is to mount /dev/md0 (for me, it is an ext4 partition) to some directory, in my case: sudo mount /dev/md0 /mnt. All works well, files can be accessed from wsl2. The problem is that when using File Explorer to go to "\wsl\Ubuntu\mnt", the directory is empty. This is kind of expected, but how to go about it? How to mount things in Linux so that they get mounted in the wsl$ network share as well, and be available from Windows? I tought about specifing it in /etc/fstab and specifying the mountFsTab option in .wslconfig, but the array is not ready at boot (I have to execute those 2 "wsl.exe --mount ..." commands to mount the physical disks inside WSL).

The reason why you don't see the files is the Windows explorer is because wsl distros use two mount namespaces: One for admin (elevated) shells, and one for non-admin shells.

When accessing WSL$, the non-admin mount namespace is used, so what I'd guess is that the /mnt mountpoint was created in the admin mount namespace.

The simplest solution around that is to create the mountpoint under /mnt/wsl, which is shared between those two namespaces.

I also acknowledge the ask for enabling DM_RAID in the kernel.

@valinet
Copy link
Author

valinet commented Nov 2, 2020

The simplest solution around that is to create the mountpoint under /mnt/wsl, which is shared between those two namespaces.

Wow, did not know about that and the reason behind it. Excellent, that’s a pretty good workaround, thanks for letting me know, it will serve good in the mean time.

I also hope the team will notice and address the broader issue.

@botiapa
Copy link

botiapa commented Nov 14, 2020

I'm in a very similar situation as the original issuer. I mounted a 3 disk btrfs RAID5 inside a WSL2 linux instance, but in windows, it wasn't visible. (Empty directory) So, after reading what @OneBlue said, I mounted it at /mnt/wsl/RAID, and now I encountered a different problem. When trying to access the folder, I get the following error:

image

I tried changing the default login user to root, and changing the permission settings on the mount path, to no avail.

Also, the /mnt/wsl folder seems to be cleared on every wsl2 restart.

@OneBlue
Copy link
Collaborator

OneBlue commented Nov 19, 2020

@botiapa: Interesting, there might be another issue here. Can you collect logs so we can have a look ?

@botiapa
Copy link

botiapa commented Dec 1, 2020

@OneBlue I'm sorry but I'd rather not collect logs due to privacy reasons. Is there anything else I could provide you with that could help in investigating the issue?

@OneBlue
Copy link
Collaborator

OneBlue commented Dec 1, 2020

That's no problem! I do want to let you know that logs submitted via Feedback Hub adhere to Microsoft's Privacy Policy, and are not publicly available for other users to see, they can only be viewed by Microsoft employees if that helps with your decision to submit logs.

Unfortunately, I can't think of a way to diagnose the error you're seeing without looking at the logs, but if something does come up I'll be sure to ping this thread. Thank you @botiapa !

@botiapa
Copy link

botiapa commented Dec 5, 2020

@OneBlue After hesitating for a few days, I finally decided, that I'll submit feedback via the Feedback Hub. Here's the link to it: https://aka.ms/AAajdyv Tell me if you need me to include anything else.

@OneBlue
Copy link
Collaborator

OneBlue commented Dec 8, 2020

Thank you @botiapa. Unfortunately I can't see the repro logs in the feedback link you posted.

Can you confirm you did 'Recreate the problem' when creating the feedback item ?

If not, please publish another one with a problem recording so the logs are attached.

@Bilge
Copy link

Bilge commented Feb 24, 2024

FWIW, I just did the --bare mount on WSL2 on Windows 10 and everything just worked. Didn't even have to interface with mdadm, it just recognized my RAID6 immediately and it was ready to mount. After mounting, I could read everything over the WSL$ share like normal. Good job MS.

@iamhere2
Copy link

iamhere2 commented Mar 9, 2024

FWIW, I just did the --bare mount on WSL2 on Windows 10 and everything just worked. Didn't even have to interface with mdadm, it just recognized my RAID6 immediately and it was ready to mount. After mounting, I could read everything over the WSL$ share like normal. Good job MS.

Could you please elaborate? I have one of two mirrored (RAID-1) linux disks, connected (via USB-SATA connector) to Windows-11 laptop with WSL2/Ubuntu enabled. I've succeed to mount the disk to WSL with --bare option, but still can't see RAID partitions in WSL, only "sdc" as a single raw disk :(
What could be the next step?

@Bilge
Copy link

Bilge commented Mar 9, 2024

This isn't free technical support.

@valinet
Copy link
Author

valinet commented Mar 9, 2024

This isn't free technical support.

What’s the point of this comment? There’re sites like speedtest.net where you can test your Internet connection, no need to spam here with mean remarks.

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

No branches or pull requests

7 participants