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

Block devices, (i.e. /dev/sda) ? #689

Open
ScarFez opened this issue Jul 25, 2016 · 113 comments
Open

Block devices, (i.e. /dev/sda) ? #689

ScarFez opened this issue Jul 25, 2016 · 113 comments
Labels

Comments

@ScarFez
Copy link

ScarFez commented Jul 25, 2016

Is there any ETA on when we can see block devices such as sda, for tools like hdparm ?

Thanks

@sunilmut
Copy link
Member

Thanks for the feedback. @russalex or @bitcrazed might be able to comment on any ETA's (or the lack of it). Also, please also make any feature requests on our User Voice Page and help us prioritize.

@russalex
Copy link
Contributor

Unfortunately I can't give an ETA on this one. We know there is a desire to be able to access block devices from WSL but it is not terribly high on our priority list at the moment. As @sunilmut points out, the best thing to do here would be to add something to our User Voice page. Little secret, one thing that always helps the requests there is explaining the actual scenario you're looking to enable.

@fpqc
Copy link

fpqc commented Jul 31, 2016

@russalex Is there really a point to this kind of thing? It's in the nature of the thing that it is going to be served a pre-assembled abstracted filesystem. Loading up something like dd while Windows mounts the disk (in non-raw mode) seems like it could be a problem, and this kind of thing seems to require effectively writing hardware drivers that negotiate hardware access between WSL and WSWin32

@russalex
Copy link
Contributor

russalex commented Aug 1, 2016

@fpqc, While we know there is some desire for this feature, it's not been enough of a priority for us to discuss planning or implementation.

What is interesting to me is to hear what people want to do with these types of features. The users of this forum often surprise me with their creativity and the more information we get the better. I have found that it never hurts to at least hear someone out. If something is compelling enough, and enough people want it, then we should at least look into feasibility and see where we may be able to fit it into plans.

@jtherin
Copy link

jtherin commented Aug 12, 2016

I would love to have access to block devices from WSL but it would require strict restrictions (like disallow write from devices mounted from windows/wsl). There is a high risk of corruption if a peripheral is already mounted :(

@finkelamein
Copy link

Well actually, raw disk access would make it possible to leverage device-mapper, mdraid and LVM to access any existing linux disks/logical volumes in/on your system.
I agree that it should be restricted to disks not already mounted.

@fpqc
Copy link

fpqc commented Aug 12, 2016

@finkelamein idk about that, I think the LVM driver is baked into the Linux Kernel.

@finkelamein
Copy link

It's device-mapper driver that's in the kernel, but yeah, that would be needed.

~$ sudo pvs
/dev/mapper/control: mknod failed: Function not implemented
Failure to communicate with kernel device-mapper driver.
Check that device-mapper is available in the kernel.
/proc/devices: fopen failed: No such file or directory
Failed to create lvm type filter    

But there would be need of something similar anyway to support access to disks like in the original question by OP.

@jdevora
Copy link

jdevora commented Aug 23, 2016

I would love to have access to partition types that don´t have native support on Windows.( e.g. mount a ext4 partition)
Another user case is to use "parted" for modify removable disks (after desatach them from using the disk manager, of course)

@fpqc
Copy link

fpqc commented Aug 23, 2016

@jdevora This would necessarily be beyond the scope of WSL. The first thing would be the extension of WSL's ability to mount different partition types in general, maybe with a way to query the NT kernel about "FS capabilities" (which I suspect already exists, but probably does not exist with information about Linux FS feature support). Then you would also need to write a kernel-mode driver (or maybe somehow use FUSE?) supporting ext4. The first thing might be within the scope of WSL. The second probably isn't.

@ghost
Copy link

ghost commented Aug 29, 2016

At least fuse will be great. With fuse we will be able to implement\emulate somehow everything other linux specific filesystems.

@ytrezq
Copy link

ytrezq commented Sep 25, 2016

On Cygwin I can use/dev/sdXX files directly.

This allows me to manages the fileystems of embedded devices runing linux directly (for example I can run something like mkfs.ext2 /dev/sdc1or copy a firmware to the ꜱᴅ card using dd)

Would it be possible to have the same feature on Windows subsystem for Linux ?
Please note I don’t want to be able to mount the filesystems, but just read and write to their device files. That is, getting a raw access in the kiss way.

Otherwise, wsl isn’t a good platform for building and loading firmwares on the ꜱᴅ card.

@georgir
Copy link

georgir commented Nov 25, 2016

Am I understanding properly that even if MS found a way to allow the subsystem direct device access, standard linux filesystem kernel modules would not be usable with the subsystem's customized kernel?

I was hoping we could mount the foreign filesystems which windows does not support otherwise and then export them with smbd - like it was possible to do with the old colinux project - but I guess this is too far off into the future for now.

If fuse support in LXSS is easier to implement, being a single thing as opposed to the various possible linux kernel filesystem drivers, it could be pretty great - even though core linux filesystems that have kernel modules don't seem to have fuse drivers yet because there was never any need for them, they can probably be developed once there is a use-case for them in LXSS.

@jtherin
Copy link

jtherin commented Nov 25, 2016

Yes, as it's not a real kernel, filesystems included from linux kernel will not be usable (or MS have to rewrite them). But if they implement fuse, I think we will see ext2/3/4 comming to fuse :)
And yes, it would be exportable to SMB :D

@sundhaug92
Copy link

@georgir That's my general understanding. LXSS does not have a kernel and integrating linux kernel modules with the Windows security-model would be really difficult.

@aseering
Copy link
Contributor

aseering commented Nov 25, 2016

If folks here would like FUSE support (I would), you can up-vote its UserVoice:

https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/13522845-add-fuse-filesystem-in-userspace-support-in-wsl

@eeevans
Copy link

eeevans commented Apr 10, 2017

One use would be to mount micropython devices so that you can copy .py files from the local filesystem to the on-board memory without having to have another linux machine lying around.

@ghost
Copy link

ghost commented Jul 5, 2017

Pretty cool use case eevans - I haven't thought of anything like that.

FUSE in userspace is also great in general.

@sundhaug92
Copy link

@eeevans Can't you do that using the new support for removable drives?

@fpqc
Copy link

fpqc commented Jul 8, 2017

@sundhaug92 probably not. That is specifically in the case of fat32 and ntfs removable media.

@res0nat0r
Copy link

My use for such devices is to be able to use tools like cdparanoia and abcde so that I can rip my audio cds directly in Windows vs. using a Linux box.

@bitcrazed
Copy link
Contributor

@res0nat0r - as a matter of interest, if you're running on Windows, why not just use one of the multitude of audio free and/or open-source tools for Windows?

@res0nat0r
Copy link

res0nat0r commented Nov 8, 2017

@bitcrazed Honestly it was just so that I could re-use my abcde.conf. I can rip/tag everything with a simple abcde -N without doing anything else. I'm trying to rip my ~1000 cd collection without a bunch of manual intervention so that I can get rid of all of the discs and was wanting to do it without rebooting my Windows box into Ubuntu.

EAC + Picard on Windows though will also do the trick.

@bitcrazed
Copy link
Contributor

Understood. Supporting USB CD/DVD drives isn't high on our backlog - I recommend you look to other tools; there are plenty for Windows too ;)

@res0nat0r
Copy link

No problem, thanks for the feedback!

@OneBlue
Copy link
Collaborator

OneBlue commented Aug 21, 2020

@neon64 : wsl --mount isn't available anywhere at this time. It's still in the pipe :).

We'll announce publicly once it will be available in insider builds.

@espg
Copy link

espg commented Aug 22, 2020

...this is encouraging! @OneBlue do you have a rough date? Can we expect this for the Insider Preview builds for 20H2 later this year?

@lukemcdo
Copy link

lukemcdo commented Aug 27, 2020

Is there any technical reason a block level device (that is probably a disk, thanks) couldn't be mounted to WSL1? I see the docs are only for WSL2.

@yecril71pl
Copy link

Discs can be mounted in disc drives, WSL1 is not a disc drive.

@OneBlue
Copy link
Collaborator

OneBlue commented Aug 27, 2020

@espg : We've made this change and it's working its way through the Windows release pipeline. If I had to give a non-official estimate, I'd say around 3-5 weeks.

@lmcdougald : WSL2 is running in a lightweight VM and Windows already has infrastructure to attach block devices to VM's. WSL1 does not have any infrastructure for that, so that would be a completely different problem to solve.

We have no plan to implement wsl --mount for WSL1 at this time.

@lukemcdo
Copy link

Not concerned with wsl --mount being implemented, just wsl --mount --bare. Obviously that's the part you're suggesting takes the most effort though. Would it be that different than how any sort of usb image writer app takes exclusive mode of a drive? Or is it trickier because the virtual Linux file system has to map it?

@yecril71pl
Copy link

There is no block device to map, which is what this issue is about.

@OneBlue
Copy link
Collaborator

OneBlue commented Sep 10, 2020

wsl --mount is now available in the latest insider preview build (see blog post).

@lmcdougald : Making the device readable and writable in WSL1 wouldn't really be useful unless WSL1 could also parse partitions (GPT / MBR) and read filesystems. That's the reason why wsl --mount is only available in WSL2.

@lukemcdo
Copy link

lukemcdo commented Sep 10, 2020 via email

@cephas0
Copy link

cephas0 commented Oct 30, 2020

My use cases

  1. To use a single windows 10 machine with WSL enabled to complete linux imaging for a small company assembly line process with linux-illiterate assembly folks. As of now I have to provide a secondary computer with linux running in order to access the raw drives for dd imaging.

  2. If I was doing a forensic recovery with dd, testdisk, photorec it would be useful for me to stay in one OS instead of splitting myself between two so access to a raw drive again is very useful.

So at the end of the day WSL adds nothing for me that I can't get quickly from a secondary OS or from Docker for Desktop containers at this point. The differentiator for me is to be able to eliminate at least one or both of the aforementioned options.

@OneBlue
Copy link
Collaborator

OneBlue commented Oct 30, 2020

@cephas0 : You can do both of these things with wsl --mount.

wsl --mount --bare allows a physical disk to be attached to WSL2 and accessible as a block device. Once attached, tools like dd, parted & others can be used.

@ytrezq
Copy link

ytrezq commented Oct 30, 2020

@OneBlue except this don t allows partitions thus preventing it to work with one drive slot computers, whereas a Linux native system maintains full access to acl of ntfs partitions.

@OneBlue
Copy link
Collaborator

OneBlue commented Oct 30, 2020

@ytrezq that's right, but @cephas0's scenarios are about imaging disks, not accessing the boot disk.

@circussmad
Copy link

There is a workaround with StarWind VSAN. It supports whole device passthrough or partition/virtual disk block access over iSCSI. Configuration guide here - https://www.starwindsoftware.com/blog/enable-block-storage-devices-in-wsl2

@jaymemaurice
Copy link

Every version of WSL I try to like but keep going back to cygwin because stuff like this...
In this case I would like to find the offset of a pattern on an SD card so I can dump it into the memory of an embedded device...
I am root, let me do what I want!!

@richiejarvis
Copy link

It would appear that the WSL2 not having passthrough for Serial Ports is also bundled under this issue.

Please advise, as it would be nice to run WSL2 for MicroPython on my ESP32's. As it is, I will have to restart my machine in full Linux mode.

Is there any plan for passthrough for COM ports in WSL2? If not, why not? It worked fine on WSL1.

@sundhaug92
Copy link

It would appear that the WSL2 not having passthrough for Serial Ports is also bundled under this issue.

Please advise, as it would be nice to run WSL2 for MicroPython on my ESP32's. As it is, I will have to restart my machine in full Linux mode.

Is there any plan for passthrough for COM ports in WSL2? If not, why not? It worked fine on WSL1.

That sounds like a separate issue, if so you should probably create one as such

@RobertFischer
Copy link

I've just installed WSL 2 on Windows 11, and the lsblk command errors out because of a missing file, and there are no /dev/sd* files. The official instructions don't work because of this. https://docs.microsoft.com/en-us/windows/wsl/wsl2-mount-disk

@lucvdv
Copy link

lucvdv commented Feb 4, 2022

and the lsblk command errors out because of a missing file

What distro did you install? Ik have that missing file error in WSL2 on Windows 10 in Debian 11, but it works in Ubuntu 18.

@RobertFischer
Copy link

RobertFischer commented Feb 4, 2022 via email

@MolotovCherry
Copy link

MolotovCherry commented Jan 9, 2023

For me, I just want to use dd without having to go to Linux. I can't use a livecd easily because I don't have a flash drive, and my usb drive isn't recognizing on windows tools (though I can see G/: in the explorer, though it freezes). So this was hopefully my last attempt to get it to work. (Not sure it'll necessarily work, but there are similar use-cases to this)

For others, it's also useful for formatting a drive using linux, (without having to go through the trouble of a dual boot / livecd)

@ryao
Copy link

ryao commented Jan 9, 2023

For me, I just want to use dd without having to go to Linux. I can't use a livecd easily because I don't have a flash drive, and my usb drive isn't recognizing on windows tools (though I can see G/: in the explorer, though it freezes). So this was hopefully my last attempt to get it to work. (Not sure it'll necessarily work, but there are similar use-cases to this)

For others, it's also useful for formatting a drive using linux, (without having to go through the trouble of a dual boot / livecd)

Maybe Cygwin will be able to help you with that. I vaguely remember dd working there, but it has been a long time.

@hashimaziz1
Copy link

For me, I just want to use dd without having to go to Linux. I can't use a livecd easily because I don't have a flash drive, and my usb drive isn't recognizing on windows tools (though I can see G/: in the explorer, though it freezes). So this was hopefully my last attempt to get it to work. (Not sure it'll necessarily work, but there are similar use-cases to this)
For others, it's also useful for formatting a drive using linux, (without having to go through the trouble of a dual boot / livecd)

Maybe Cygwin will be able to help you with that. I vaguely remember dd working there, but it has been a long time.

Can confirm that it works fine, I've been using it for half a decade. I tried my best to move to WSL2 but it has too many failings compared to Cygwin, so I'll probably stay on Cygwin for at least another 5 years.

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

No branches or pull requests