-
Notifications
You must be signed in to change notification settings - Fork 797
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
Share directory between distros #5177
Comments
I currently already share a directory available on the Windows platform, as my home directory for the different distros I have. This looks like what you're after:
This requires that the You could also bind this directory to any other directory (e.g. /mnt/h), and then change your |
The second option is actually implemented. You can create a directory in For example, just adding this to my Ubuntu ~/.profile it automatically mounts on launch an external Alpine /home folder that appears in every distro under # mount external /home folder from Alpine distro
if [ ! -d /mnt/wsl/Alpine ]; then
mkdir /mnt/wsl/Alpine
wsl.exe -d Alpine mount --bind /home/ /mnt/wsl/Alpine/
fi |
I was not aware of the second option, thanks @onomatopellan ! |
@beltaurus Yes, it's a WSL2 only thing, since all the distros in WSL2 are just "containers" running on a single kernel/lightweight VM. |
I was not aware of this functionality, @onomatopellan, very cool. |
@giggio : Can you use my suggestion then? Or are there other obstacles with sharing a given windows directory over the different distros? |
@giggio Correct, it's tmpfs but you only loses the folder used as mount point. In my case I can modify the Alpine home files from Ubuntu and, of course, the changes are preserved after wsl shutdown. I can understand why this feature is undocumented and so far it's only used by Docker devs. Things can become dangerous fast, especially with different user file permissions. But it's still very useful and the most important thing to know is this: Every time you launch a distro it attaches that distro's VHDX to the running WSL2 VM as a new sdx device. You can observe that with @beltaurus For WSL2 users |
Yes, I'm not using Windows because it's slow at the moment. I don't like that I have to have another distro running to be able to mount. There should be a way to mount a device to multiple distros, a device that does not belong to any of the distros. |
@onomatopellan I seem to only be able to mount a single distro with this method. Do we happen to know if this by design?
which produces the following:
|
@beardedeagle are you sure both distros are WSL2? If OldUbu is WSL1 it won't work since there is no sharing |
@onomatopellan yup, they are all wsl2:
To clarify both |
@beardedeagle I just tried with two distros and it works. I think the mount command should be called by the root user which is default in Alpine but not in Ubuntu. After that you should see if it did work with
|
The shared Creating a bind mount inside a Ubuntu-18.04 instance would look something like...
... but you can pick whatever you want for the source and target of the mount, so long as the target is under /fixed 19041 |
This bug or feature request originally submitted has been addressed in whole or in part. Related or ongoing bug or feature gaps should be opened as a new issue submission if one does not already exist. Thank you! |
@therealkenc this issue has not been addressed. Yes, you can share a drive from a distro to another, but I don't want that. I want a drive that is not part of any distros, so I can add my home directory there and use it in any distro that boots first. I don't want to have to boot them in order. Also, please see this comment with other issues: #5177 (comment) It is not possible to do what I need with today's implementation. |
That's #689. [If this issue was interpreted as "I want a drive that is not part of any distros" contrast issue title "Share directory between distros" it wouldn't have survived a dupe-closed in May.]
Yeah, there's that. Feel free to open a new feature request "persist /mnt/wsl mountpoints" or somesuch. |
In my default distro (which was upgraded from wsl1 a long time ago) I do not have the folder Simply creating the folder and then following the instructions in this thread do not seem to work, the mounted folder is not available in other distros. Is there a way to properly repair the distro such that the /mnt/wsl folder is mounted properly? |
@justinmchase Make sure you are in a WSL2 distro with |
In the end to fix it I had to completely uninstall Ubuntu and then re-install it from the store. This created a new distro which had the /mnt/wsl folder functioning correctly. I have no idea how I got in that bad state but it was possibly an error in the upgrade process and I never noticed the issue until now. |
But what if one (or both) of them are WSL1, is there a better way of sharing their filesystems. I guess mounting over network is the only option, but any suggestion on which one to use. Mounting something like a related stackexchance question Footnotes
|
I'm not very Linux saavy, so how to I make it so my home dir is shared between my WSL 2 distros? Without it being a slow windows mount? |
Describe the solution you'd like
In WSL2, I'd like to be able to share a directory between distros. I can see it is possible, as Docker for Windows is doing it by creating devices (
/dev/sdd
,/dev/sdc
on my system, using ext4) and mounting them on/mnt
.I see 2 options:
You could also try to change something on the namespaces and maybe use symbolic links between distros, that would be good enough, and wouldn't need mounting. I'm not sure how feasible that would be. I don't really care about the implementation.
Describe alternatives you've considered
I can't see a clear alternative.
Additional context
My use case it that I'd like to share
/home/user
. It would save space and help a lot.The text was updated successfully, but these errors were encountered: