Jump to content

Can you Side load your Linux distro from your HDD using WSL2

Go to solution Solved by throttlemeister,
On 6/16/2020 at 6:36 PM, Joe Jackman said:

 

Basically i don't wanna do all my Configure from the beginning and i really don't wanna delete (dual booting) it to make way.

Actually, you can (I think).

 

On your Linux system:

$ sudo su -
# cd /
#  tar -cpzf backup.tar.gz --exclude=/backup.tar.gz --exclude=/proc --exclude=/tmp --exclude=/mnt --exclude=/dev --exclude=/sys /

 

Then copy the backup.tar.gz to your windows system. Now, here's the thing I am not entirely sure. I know for a fact you can import this file into a docker container and run it. I also know for a fact you can export a docker container and sideload it as a distribution into WSL2. So my assumption is you can import this directly into WSL2 as well.

 

gunzip the file so you end up with the file backup.tar (you can also omit the z flag in the tar command above, but you will end up with a huge file to move around)

 

Then open a CMD window and issue:

wsl --import "<Your_Distro_Name>" "<Location_to_store_your_Distro>" "PATH/TO/<archive.tar>" --version 2

 

This _should_ work. If it doesn't, the quick solution would be to import the tar.gz into a new Docker container, en then export it from Docker so you can then import the resulting file into WSL2.

 

Hope this helps. I have no tested this, but I have used Docker exports to create and sideload my own Slackware distribution for WSL2 that is not available otherwise.

 

 

slack.png

What is Windows Subsystem for Linux (WSL and WSL2)? -- Linux in ... 

Basically i don't wanna do all my Configure from the beginning and i really don't wanna delete (dual booting) it to make way.

Link to comment
Share on other sites

Link to post
Share on other sites

No. You can do that with a virtual machine though.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

7 minutes ago, Sauron said:

No. You can do that with a virtual machine though.

oh that would work too, my work is very minimal tbh. guess VM can do the trick.

Link to comment
Share on other sites

Link to post
Share on other sites

15 hours ago, Sauron said:

No. You can do that with a virtual machine though.

Can you tell me how to though, i really cannot find any tutorials to do that.

 

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, Joe Jackman said:

Can you tell me how to though, i really cannot find any tutorials to do that.

 

https://www.serverwatch.com/server-tutorials/using-a-physical-hard-drive-with-a-virtualbox-vm.html

 

If you already have a Linux installation you can literally just point VirtualBox to that hard drive and it will boot.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

But who in their right mind would want to do that? Running Win-OS as a VM on a Linux machine is industry-wide accepted as a much more stable solution.

 

Having said that, each use-case is different, really. So, YMMV!

"You don't need eyes to see, you need vision"

 

(Faithless, 'Reverence' from the 1996 Reverence album)

Link to comment
Share on other sites

Link to post
Share on other sites

10 hours ago, Sauron said:

https://www.serverwatch.com/server-tutorials/using-a-physical-hard-drive-with-a-virtualbox-vm.html

 

If you already have a Linux installation you can literally just point VirtualBox to that hard drive and it will boot.

my home is in extHDD and root in my SSD(and also windows).. "Warning: Do not attempt to mount or boot the partition that runs the host OS with a VM, as that can lead to severe data corruption. And no matter which drive or partition you want to mount, it's always a good idea to back up any existing data on it before continuing." is it saying i shouldnt mount windows while running windows or u cant mount partition that has another OS on the same drive but on a different partition.

 

Link to comment
Share on other sites

Link to post
Share on other sites

22 minutes ago, Joe Jackman said:

my home is in extHDD and root in my SSD(and also windows).. "Warning: Do not attempt to mount or boot the partition that runs the host OS with a VM, as that can lead to severe data corruption. And no matter which drive or partition you want to mount, it's always a good idea to back up any existing data on it before continuing." is it saying i shouldnt mount windows while running windows or u cant mount partition that has another OS on the same drive but on a different partition.

That's a problem... obviously you can't pass the entire drive to the VM if Windows is also running off of it... either install Linux on a second drive or run a normal virtual machine.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

  • 2 months later...
On 6/16/2020 at 6:36 PM, Joe Jackman said:

 

Basically i don't wanna do all my Configure from the beginning and i really don't wanna delete (dual booting) it to make way.

Actually, you can (I think).

 

On your Linux system:

$ sudo su -
# cd /
#  tar -cpzf backup.tar.gz --exclude=/backup.tar.gz --exclude=/proc --exclude=/tmp --exclude=/mnt --exclude=/dev --exclude=/sys /

 

Then copy the backup.tar.gz to your windows system. Now, here's the thing I am not entirely sure. I know for a fact you can import this file into a docker container and run it. I also know for a fact you can export a docker container and sideload it as a distribution into WSL2. So my assumption is you can import this directly into WSL2 as well.

 

gunzip the file so you end up with the file backup.tar (you can also omit the z flag in the tar command above, but you will end up with a huge file to move around)

 

Then open a CMD window and issue:

wsl --import "<Your_Distro_Name>" "<Location_to_store_your_Distro>" "PATH/TO/<archive.tar>" --version 2

 

This _should_ work. If it doesn't, the quick solution would be to import the tar.gz into a new Docker container, en then export it from Docker so you can then import the resulting file into WSL2.

 

Hope this helps. I have no tested this, but I have used Docker exports to create and sideload my own Slackware distribution for WSL2 that is not available otherwise.

 

 

slack.png

Link to comment
Share on other sites

Link to post
Share on other sites

  • 2 weeks later...

I can actually now confirm above procedure works, as I found it interesting enough to try and test my hypophysis. :)

 

What I did:

1) installed Deepin Linux distribution from ISO in a virtual machine. I used Hyper-V, but it can be any or it can be installed on the physical machine.

2) after installation and initial configuration, dumped the entire system into a tar file like above. Due to the specifics of Deeping I had to include /run and /media in the excluded directories. Make sure you have enoug space to store the file on the location you are saving too. It can get quite big, depending on the size of your system.

3) ran the WSL --import with the resulting tar file from the previous step

4) fired up wsl with a fully configured and working version of Deepin Linux 

 

Including the base install of the system, the whole process took less than 30 minutes to complete. So whether you want a Linux distribution that's not available in the MS Store, you have a VM you want to run in WSL instead or even a complete running system, this is a very quick and easy way to being able to run those inside WSL and not having to dual boot to access or use certain tools/files or have the overhead of a full-blown VM.

 

Obviously the architecture needs to match. This before anyone tries to dump his Raspberry Pi install into a tar file and attempts to run it in WSL on an x86 PC. :P 

Link to comment
Share on other sites

Link to post
Share on other sites

On 9/3/2020 at 3:12 PM, throttlemeister said:

I can actually now confirm above procedure works, as I found it interesting enough to try and test my hypophysis. :)

 

What I did:

1) installed Deepin Linux distribution from ISO in a virtual machine. I used Hyper-V, but it can be any or it can be installed on the physical machine.

2) after installation and initial configuration, dumped the entire system into a tar file like above. Due to the specifics of Deeping I had to include /run and /media in the excluded directories. Make sure you have enoug space to store the file on the location you are saving too. It can get quite big, depending on the size of your system.

3) ran the WSL --import with the resulting tar file from the previous step

4) fired up wsl with a fully configured and working version of Deepin Linux 

 

Including the base install of the system, the whole process took less than 30 minutes to complete. So whether you want a Linux distribution that's not available in the MS Store, you have a VM you want to run in WSL instead or even a complete running system, this is a very quick and easy way to being able to run those inside WSL and not having to dual boot to access or use certain tools/files or have the overhead of a full-blown VM.

 

Obviously the architecture needs to match. This before anyone tries to dump his Raspberry Pi install into a tar file and attempts to run it in WSL on an x86 PC. :P 

Bro i am really sorry that i didnt check in LTTf , DUDE this is soo awesome. I really love Linux and main it actually and would prefer over windows anyday. I logged in today just to ask for a laptop under 350$ (linux friendly i mean) and i found another Gem in the Linux community. Love you man, will try this.

Link to comment
Share on other sites

Link to post
Share on other sites

On 8/19/2020 at 4:28 PM, throttlemeister said:

Actually, you can (I think).

 

On your Linux system:


$ sudo su -
# cd /
#  tar -cpzf backup.tar.gz --exclude=/backup.tar.gz --exclude=/proc --exclude=/tmp --exclude=/mnt --exclude=/dev --exclude=/sys /

 

Then copy the backup.tar.gz to your windows system. Now, here's the thing I am not entirely sure. I know for a fact you can import this file into a docker container and run it. I also know for a fact you can export a docker container and sideload it as a distribution into WSL2. So my assumption is you can import this directly into WSL2 as well.

 

gunzip the file so you end up with the file backup.tar (you can also omit the z flag in the tar command above, but you will end up with a huge file to move around)

 

Then open a CMD window and issue:

wsl --import "<Your_Distro_Name>" "<Location_to_store_your_Distro>" "PATH/TO/<archive.tar>" --version 2

 

This _should_ work. If it doesn't, the quick solution would be to import the tar.gz into a new Docker container, en then export it from Docker so you can then import the resulting file into WSL2.

 

Hope this helps. I have no tested this, but I have used Docker exports to create and sideload my own Slackware distribution for WSL2 that is not available otherwise.

 

 

slack.png

also this should back up the home dir right?

 tar -cpzf backup.tar.gz --exclude=/backup.tar.gz --exclude=/proc --exclude=/tmp --exclude=/mnt --exclude=/dev --exclude=/sys /

so my home partition in the exHDD is not a problem here.

Link to comment
Share on other sites

Link to post
Share on other sites

Yes, anything that is mounted and not explicitly excluded with the --exclude= statement will be included in the tar archive, wether is on an internal disk, external disk, or network. If it is mounted, accessible on the filesystem, it will include it. This can be good, or bad so pay attention to what you need and what you do not need. :)

Link to comment
Share on other sites

Link to post
Share on other sites

15 minutes ago, throttlemeister said:

Yes, anything that is mounted and not explicitly excluded with the --exclude= statement will be included in the tar archive, wether is on an internal disk, external disk, or network. If it is mounted, accessible on the filesystem, it will include it. This can be good, or bad so pay attention to what you need and what you do not need. :)

i guess so, Honestly the only thing that holding me from nuking windows is valorant and LoL, and a renaming tool called Bulk rename Utility. so idk if this will even be needed but nothing wrng with gaining abit of knowledge.

Link to comment
Share on other sites

Link to post
Share on other sites

On 9/10/2020 at 4:23 PM, Joe Jackman said:

i guess so, Honestly the only thing that holding me from nuking windows is valorant and LoL, and a renaming tool called Bulk rename Utility. so idk if this will even be needed but nothing wrng with gaining abit of knowledge.

That's very much true. Never stop learning. That said, I am an old UNIX guy and I run Windows. In the end it is just a GUI and a means to run the software you want to use. They're all good, they're all stable these days. Objectively, there is no good or bad just personal preference. And Windows lets me run all the software I want to use, while Linux doesn't. But! Having Linux inside my Windows through WSL let's me fall back to the commandline and do certain things faster and easier because I am so used to them there that it really gives me best of both worlds. And by using X410 I can even use the GUI software froim Linux if I want to.

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

×