DEV Community

loading...

Discussion on: How to get started with Web Development on Windows with the WSL in 2021

Collapse
frag0r profile image
Marcel

Can I somehow export the wsl image to another system ?
Occasionally I have to switch systems, but reconfiguring third party libs can be a pain in the ass sometimes...

Collapse
citizen428 profile image
Michael Kohl • Edited

Yes, you can, WSL2 has export and import options (maybe version 1 did too but I never used that):

wsl --terminate <distribution> # just in case 
wsl --export <distribution> <file>
wsl --import <distribution> <installdir> <file>
Enter fullscreen mode Exit fullscreen mode

I use --export to regularly back up my WSL2 Ubuntu installation to an external disk and also used --import to create WSL installations for distros not available in the app store from custom root filesystems (make a root fs any way you want, turn it into a tarball, then import it).

Collapse
codingcastle profile image
Patrick Göler von Ravensburg Author

Uh, that's a though one, I don't think so. Only thing I can think of to write a bash script yourself which installs everything you need. You would have to set that up once, host on Github and then you can run that if you change to a new system. 🤷‍♂️

Collapse
hekonsek profile image
Henryk Konsek

Actually it might be possible! You can create custom WSL distribution from a Docker image - medium.com/@hoxunn/wsl-docker-cust... . So technically it should be possible to export your current distro as Docker image and re-import it.

This is theoretical take however - I didn't try it myself :) .

Great article man! Keep'em coming!