DEV Community

Cover image for Move WSL2 Distro To Other Driver
Jenuel Oras Ganawed
Jenuel Oras Ganawed

Posted on • Originally published at brojenuel.com

3 1 1 1 1

Move WSL2 Distro To Other Driver

So, I get ask a lot on how to move a WSL2 distro to other drive. And this is the easiest I found.

First let us check what distros are we going to move to other drive by running this command:

wsl -l -v
Enter fullscreen mode Exit fullscreen mode

image right here

Next, we need to make sure distributions are not running by running.

wsl --shutdown
Enter fullscreen mode Exit fullscreen mode

Its optional but having a backup is important. You can create a directory where you want to put the backup on your system. In my case I will create a wsl folder iny my D drive. And then run wsl export to export the distribution.

mkdir D:/backup
wsl --export Ubuntu-20.04 D:\backup\ubuntu.tar
Enter fullscreen mode Exit fullscreen mode

Wait till the WSL export is over (it may take much time). A TAR archive with your WSL ext4 file system will appear in the target directory.

Then you may remove the WSL files on the source disk:

wsl --unregister Ubuntu-20.04
Enter fullscreen mode Exit fullscreen mode

Set up a new folder on a different drive for your Linux files and use a command to bring those files into the folder. In my case I will create WSL folder in my D drive.

mkdir D:\WSL
Enter fullscreen mode Exit fullscreen mode

Then Let us run the import to import it in our WLS directory.

wsl --import Ubuntu-20.04 D:\WSL\ D:\backup\ubuntu.tar
Enter fullscreen mode Exit fullscreen mode

There you go. You have now moved your distro to your other drive.


Donate To BroJenuel image

Retry later

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more