-
Notifications
You must be signed in to change notification settings - Fork 823
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
How to attach other vhdx files to WSL2? #4574
Comments
To mount an extra vhdx file (and read ext4,etc filesystems from within Windows 10:
|
Thanks, this is a potential stop-gap but I believe it mounts over 9p, which I don't want to do -- see #4556 (comment) for more details. |
There is a line in the 18970 release notes about allowing cross-distro mounts. I haven't played with it yet personally, but that appears to be intended for your use case. Duping because mounting an arbitrary vhd is the same ask, regardless of the use. |
Thanks for your reply! |
Thanks for you reply. This is not what I want. I want to use WSL2 VM like a real VM can mount multple VHDX via /etc/fstab etc. |
It is likely until there is some official word over in #4556 you want a real VM, because it is the right tool for the job. I believe one the goals of WSL (both 1 and 2) is not to have to futz with VHDs and configuration thereof. The disk image is an implementation detail, just like the hidden don't touch lxfs was in WSL1. Everyone is welcome to off-road it to greater or lesser success, of course. A lot here is going to depend on your specific use-case and the motivation behind wanting a VHDX, specifically, what you intend to do with said VHDX on the Windows side. If what you are just looking for a separate filesystem, you can create an ext4 image over loopback (rando google hit guide here no warranties). |
This thought is just for safe: keep thing isolated from system disk. Just like in Windows, I never save work files in C:. Because things like re-install or system crash maybe fatal. |
Okay that's the nuance I missed. It isn't that you want it on a VHD, somuch as you don't want it on your physical system disk (or at least, not the system partition thereof). And you sure don't want to go through a 9p bottleneck to do that. Okay, that's not a crazy ask. Subscribe #4556. |
OK, here's a hackaround for this that does seem to provide speedy access, if you don't mind having 1/2G of extra stuff in your VHDX. You can load in a lightweight WSL 2 distro, like Alpine and then put your files in there-- let's call it One way to make sure
or even
Even though it's done with an exec, the "light context" will stay around until you exit the shell or command you invoked. The exec just removes a bit of overhead from the light session. As long as you have at least one Another way to "keep the light on" is to use the latest Docker Desktop with the "WSL 2 backend" and activate docker in |
This doesn't work for me. I installed Alpine from here: https://github.com/yuk7/AlpineWSL
gets me to my Ubuntu (Default), but there's no mounted The only folders I can see there, are the ones that docker created.
I also activated docker to run in the |
I think I may have left out a couple key pieces. Apparently WSL 2 no longer mounts into /mnt/wsl by default but it DOES make /mnt/wsl available in all of the WSL 2 containers. I put this in my Alpine dist's /root/.profile (my home directory is in
and I put this into my Ubuntu dist's /root/.profile:
When I start my machine, I do this dance from a power shell prompt (I should also mention that Ubuntu is my default WSL environment so
That sets up my environment. Next, I start a wsltty and do this (maybe a Windows Terminal would work as well, not sure): Once my start-tmux script has run, I can close the power shell prompt because I know this is elaborate and should be automated but once we can attach regular VHDX files, I (and maybe others) won't need to do this anymore :). Here is my start-tmux script:
Here is my .wsl.tmux script:
I should probably clean all this up but I'm really hoping we just get the option to mount VHDXs soon so I don't have to think about maintaining this stuff :) |
I'm still using this fairly broken setup, starting an alpine instance, waiting 5 seconds, then starting the ubuntu instance I actually work in. Is anyone working on letting us attach vhdx files in WSL2? |
I know this doesn't create a new vhdx but makes you feel like you better "own" that file: For example if you "embrace" developing inisde WSL, your source files will likely live in this vhdx (with Docker): C:\Users\YourName\AppData\Local\Docker\wsl\data\ext4.vhdx How about you move the data folder wherever you want that is not C partition, and then symlink it back to C? So if your main system SSD crashes or you reinstall windows you just re-create the symlink. This is also the file I'd back up as the ultimate form of backup (yes it'll grow big, but squashable while wsl is shut down) as on windows it's not much different from a VM's disk in VMware. At least it's a single file which is fast to transfer. |
With What I like to do is similar to the OP's question. I'd like to have a |
WSL2 looks very good for developing Linux realted project (embeded linux & android etc).
But when we do our dev works, we always put code in another different disk from the sys(/).
How to achieve this?
The text was updated successfully, but these errors were encountered: