Jump to content

WSl

goatedpenguin

So I got a new laptop with windows on it and I have a wsl installation with all my data for that distro on my pc. Is there a way I could move the folder from the pc to the laptop and WSL can detect the files etc. automatically on the laptop?

Thanks in advance.

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, goatedpenguin said:

Is there a way I could move the folder from the pc to the laptop and WSL can detect the files etc. automatically on the laptop?

Yes wsl instances can be moved. Check this guide out

https://github.com/LpCodes/Moving-WSL-Distribution-to-Another-Drive

for Step 4 copy the exported file to your new machine and change the paths to match yours.

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, goatedpenguin said:

can you be more specific?

Just to be sure I understand you. Where did you place your files? Under WSL or outside WSL?
WSL2 (I'll focus on "v2" of WSL), can be seen as a fancy VM (specialized for Linux based OSs) where it has deep ties with the OS, allowing you to cross both Linux based OS world and Windows. That said, it is still a VM.

 

If you have files IN WSL2 environment, you can access them through File Explorer, by clicking on the "Linux" item on the navigation bar.

If you don't have it, then you are probably under Windows 10. Under which case, you can type "explorer.exe ." (notice the space and the "." after "explorer.exe") under your WSL2 environment, and you'll open File Explorer exactly at that location. It should be a network location.

 

WSL2, as mentioned, is really a VM at the end of the day, that means it has a VHD of some kind. It means that you can export it and import the envirement. This avoids reinstalling/reconfiguring everything.

You can use these commands which you execute under Windows (Command Prompt or PowerShell) to do this: https://learn.microsoft.com/en-us/windows/wsl/basic-commands

 

If your files are outside of WSL2 envirement, meaning not under your Linux based distro env, then you can just treat them as any files of your system. The other system WSL envirement will see them just fine. You can view your Windows files under Linux via /mnt/ folder, where you'll have, your drive letters. So, if your files are under Documents, assuming a starts Windows install, it can be accessed via: /mnt/c/Users/<account name>/Documents

 

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Sorry I should have been more specific. I am running wsl 2 which has kali linux on it. The folder is on a secondary drive in my PC and inside it is just a .vhdx file.

Link to comment
Share on other sites

Link to post
Share on other sites

 wsl --import kali C:\wsl\kali-linux\ ext4.vhdx
The system cannot find the file specified.
Error code: Wsl/ERROR_FILE_NOT_FOUND

 

I have no idea whats happening now.

Link to comment
Share on other sites

Link to post
Share on other sites

12 hours ago, goatedpenguin said:

I have no idea whats happening now.

Specify the full path to where ext4.vhdx is located (if your file path contain spaces wrap the path in double quotes like "C:\Users\user\folder with spaces\ext4.vhdx"

Link to comment
Share on other sites

Link to post
Share on other sites

no I know that but the syntax of the command from microsoft's website was:

wsl --import <Distribution Name> <InstallLocation> <FileName>

but it simply did not work

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, goatedpenguin said:

but it simply did not work

Where is your command prompt running from (path before the >). And where is the .vhdx file located?

Link to comment
Share on other sites

Link to post
Share on other sites

I know windows cli. I am not a beginner. All I was asking why it is not working, my path does not matter since I provided the absolute path

Link to comment
Share on other sites

Link to post
Share on other sites

21 hours ago, goatedpenguin said:

 wsl --import kali C:\wsl\kali-linux\ ext4.vhdx
The system cannot find the file specified.
Error code: Wsl/ERROR_FILE_NOT_FOUND

 

I have no idea whats happening now.

 

As per documentation:

wsl --import Kali --vhd "C:\wsl\kali-linux\ext4.vhdx" --version 2
Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, goatedpenguin said:

Nope not working just returns me the the wsl man page

Sounds like you don't have the latest version of WSL.

It should be fetched from the Store app.

 

OR, this is the first distro that you are installing on the system and so:

--import-in-place should be used.

wsl --import-in-place Kali "C:\wsl\kali-linux\ext4.vhdx"

 

Link to comment
Share on other sites

Link to post
Share on other sites

ITS NOT WORKING. it imported it but when I went on to isntall it my data was not there luckily I still have a copy on my pc.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×