简体   繁体   English

如何从我本机安装的 Ubuntu 访问我的 WSL2 文件?

[英]How can I access my WSL2 files from my natively installed Ubuntu?

I'm really new to Ubuntu and WSL.我真的是 Ubuntu 和 WSL 的新手。 My problem is simple: I want to access from Ubuntu which I have installed in my computer (dual boot alongside with Windows) to my WSL2 filesystem that I have in Windows. I located a file named ext4.vhdx which I suppose is my entire wsl drive, but I'm not really sure, it is in c:\Users\USER\Appdata\Local\Packages\CanonicalGroupLimited.Ubuntu20.04o...\LocalState\我的问题很简单:我想从我安装在我的计算机中的 Ubuntu(与 Windows 一起双启动)访问我在 Windows 中的 WSL2 文件系统。我找到了一个名为 ext4.vhdx 的文件,我想这是我的整个 wsl驱动器,但我不太确定,它在c:\Users\USER\Appdata\Local\Packages\CanonicalGroupLimited.Ubuntu20.04o...\LocalState\

I'm currently into web development and I want to share that environment within WSL2 and Ubuntu, I noticed that using the linux fs is way faster than windows fs and it works better with things like watchers.我目前正在进行 web 开发,我想在 WSL2 和 Ubuntu 中共享该环境,我注意到使用 linux fs 比 windows fs 快得多,而且它更适合观察者之类的东西。 So, is it possible?那么,有可能吗? I'm currently running Windows 10 19041 (2004), Ubuntu LTS 20.04我目前正在运行 Windows 10 19041 (2004)、Ubuntu LTS 20.04

I've also encountered similar issues when doing this WSL Ubuntu sharing thing, and I've finally found a solution on the inte.net that works out perfectly.我在做这个 WSL Ubuntu 分享的时候也遇到过类似的问题,我终于在 inte.net 上找到了一个完美的解决方案。

Reference Link: https://www.nicholasmelnick.com/2020/07/sharing-your-wsl2-environment-with-linux/参考链接: https://www.nicholasmelnick.com/2020/07/sharing-your-wsl2-environment-with-linux/

So basically these are the steps,所以基本上这些是步骤,

  1. First of all, the WSL's "ext4.vhdx" file should be accessible inside your Ubuntu system (So you must mount your windows drive inside your linux OS)首先,WSL 的“ext4.vhdx”文件应该可以在您的 Ubuntu 系统中访问(因此您必须在您的 linux 操作系统中安装您的 windows 驱动器)
  2. Install libguestfs-tools package with APT使用 APT 安装libguestfs-tools package
  3. And finally just create a folder and guestmount the drive with following commands.最后只需创建一个文件夹并使用以下命令来宾挂载驱动器。
$ sudo mkdir -p /mnt/wsl
$ sudo guestmount -o allow_other \
--add /mnt/c/Users/username/AppData/Local/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/ext4.vhdx \
-i /mnt/wsl

And done.并做了。 Hope this would solve your problem: :)希望这能解决您的问题::)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM