Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm really new to Ubuntu and 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\

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. So, is it possible? I'm currently running Windows 10 19041 (2004), Ubuntu LTS 20.04

like image 239
pianoman Avatar asked Jun 19 '20 17:06

pianoman


1 Answers

I've also encountered similar issues when doing this WSL Ubuntu sharing thing, and I've finally found a solution on the internet that works out perfectly.

Reference Link: 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)
  2. Install libguestfs-tools package with APT
  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. :)

like image 95
Chaoannricardo Avatar answered Nov 18 '22 23:11

Chaoannricardo