microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.34k stars 814 forks source link

Please support mounting NBD disks #5968

Open joshtriplett opened 4 years ago

joshtriplett commented 4 years ago

The Linux kernel supports Network Block Device (NBD) disks. I'd like to be able to mount such disks, containing any filesystem Linux supports, and access them from both Linux and Windows.

This is a capability easily available on a native Linux system, and it would be helpful to have the same capability on WSL2.

guilt commented 4 years ago

Please enable it. I use BUSE for testing block corruption, and this would be very helpful.

CONFIG_BLK_DEV_NBD=y needs to be set, so that needs to go in for nbd-client and nbd-server to work. I've manually put together a kernel so I can do this, but would really appreciate this to be out of the box.

pojntfx commented 3 years ago

I second this. Docker now uses WSL2 by default, and tools such as alpimager start to fail on Docker for Windows because nbd support is lacking.

samliddicott commented 3 years ago

This was going to be my way to get around wsl --mount limitation:

I want to access my dual-boot linux /home partition

Am I now going to have to somehow map the partition as a file under windows and then use that via 9p + losetup?

samliddicott commented 3 years ago

Work-around in the meantime; build your own kernel: https://blog.dan.drown.org/replacing-the-wsl-kernel/

guilt commented 3 years ago

I've been building my own for a while now. This is about really enabling NBD out of the box; Same with EBPF; Would like both out of the box.

samliddicott commented 3 years ago

It ought the be practically the same as the Ubuntu kernel right out of the box.

I'm now stuck on accessing the windows NBD server from Ubuntu.

NathanNZ commented 3 years ago

Any progress on this? Would be great to have CONFIG_BLK_DEV_NBD set to "y" by default!

Biswa96 commented 3 years ago

You can compile and use your own Linux kernel in WSL2 with that config enabled.

joshtriplett commented 3 years ago

Building a custom kernel has been mentioned multiple times in this issue, and people asking for this know that that's an option. It would be helpful to have NBD work out of the box.

samliddicott commented 3 years ago

Slightly (very?) off topic, but I found it much simpler to switch to native linux. With outlook and office being online anyway, it wasn't too hard a switch. It's much faster too. It's not the answer you want, and it's not the one I wanted, but it's a lot less faff all round.

ShadowJonathan commented 2 years ago

Why is this not yet supported? Today i had to quickly verify a qcow2 image on a WD Passport disk (which only supports windows or mac), which is only mountable via nbd, and I couldn't do this, because WSL2 doesn't support this.

matt-psaltis commented 2 years ago

Just adding the annual +1 :)

drew-viles commented 2 years ago

I came here hoping to find, well, some movement of any kind on this since it's been open for 2 years 😞

I guess it's back to dual-booting or running Linux in a VM until Microsoft add some basic features that most Linux admins would love to see in WSL to prevent said dual booting &/or VMs.

It was nice knowing ya WSL, but you ain't quite what I'm looking for in a partner.

¯\_(ツ)_/¯

okibcn commented 1 year ago

Why does changing the default config file for building the wsl2 kernel take that long?

That setting works and it is handy for mounting qcow2 images quickly.

guilt commented 1 year ago

Why does changing the default config file for building the wsl2 kernel take that long?

If only the world 😒 worked this way, we'd all be in the year 3000 🚀

okibcn commented 1 year ago

If you are interested in having the latest kernel with nbd enabled and always updated to the latest release, you can get it from https://github.com/okibcn/WSL2-linux-kernel/releases/latest

I have added another configuration for enabling settings to run Anbox. The Zip includes all the 3 kernels and an installer/uninstaller. I created this for myself so I didn't have to manually build it after each update. I also created a scoop manifest to help me get it updated easily. Just search for wsl2kernel in scoop.sh.

It is sad Microsoft didn't have it enabled and I had to do this.

guilt commented 1 year ago

It is sad Microsoft didn't have it enabled and I had to do this.

We really just wish this is out of the box. I've tested this before. There is another chance we could get NBD working with the new IO Uring code and there's a full userspace only implementation of the NBD driver available. Anyway, this ticket is as good as dead now 😵

okibcn commented 1 year ago

It works quite well: ses

drew-viles commented 1 year ago

This is it, it's absolutely doable - I presume this is your own from your GitHub repo linked above?

Ideally this should be implemented in the standard one so we don't have to go adding basic features into the kernel and then be responsible for manually upgrading every time a new one rolls out. Microsoft could easily enable this for use but for some reason, don't.


~# uname -a
Linux Drew-PC 5.15.79.1-microsoft-standard-WSL2 #1 SMP Wed Nov 23 01:01:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

~# ls /dev/nbd*
ls: cannot access '/dev/nbd*': No such file or directory`
``
okibcn commented 1 year ago

@drew-viles yes, it is my repo. I automated a workflow to build a new nbd version of the kernel as soon as official sources are released by Microsoft. I have been doing it manually before. I can now mount qcow2 images with qemu-nbd in WSL without any issues and without having to manually compile the kernel.

It is just a setting, nothing complicated. Really, MS could enable this as it works with WSL without any side effects.