DEV Community

AW A RE
AW A RE

Posted on • Edited on

Installing WSL on another drive in Windows

The only way to do that is to move the linux distrubition you installed on wsl. I installed Ubuntu on windows as wsl and I showed how to move it step by step.

1.Check WSL 2 installations that are already installed in your computer.

wsl --list -v

If the installation you want to move to another drive is still running we have to stop it with following command. In my case, I want to move Ubuntu, so I am terminating Ubuntu.

wsl -t Ubuntu

2.Export to a folder. (Here exporting Ubuntu as ubuntu-ex.tar to D:\wsl\wsl_export)

wsl --export Ubuntu "D:\wsl_export\ubuntu-ex.tar"

3.Unregister previous WSL installation. When you unregister it will remove Ubuntu from the wsl2 list that we saw earlier.

wsl --unregister Ubuntu

4.import your WSL installation to a folder. This step also re-registers the ubuntu.
wsl --import Ubuntu "D:\wsl_import\ubuntu" "D:\wsl_export\ubuntu-ex.tar"

Here’s a breakdown of the command:

  • wsl --import: The base command to import a new Linux distribution.
  • Ubuntu: The name you are giving to the new imported distribution.
  • D:\wsl_import\ubuntu: The directory where the new distribution will be stored.
  • D:\wsl_export\ubuntu-ex.tar: The tar file containing the exported distribution that you want to import.

Latest comments (24)

Collapse
 
nguyentai2002 profile image
NguyenTai2002

saved my life, thank you so much, 2025 check

Collapse
 
mamad_jufry_1a31b40d48a95 profile image
mamad jufry

thank you

Collapse
 
funny2code profile image
Dejan

That works fine for me. Thank you a lot.

Collapse
 
sb_tv profile image
Sokhib Tukhtaev

If I want to move my ubuntu distro on wsl from C drive to say, F, does the F drive have to be empty? I have nearly half of it used on my native Windows OS.

Collapse
 
cristianorc profile image
Cristiano Raffi Cunha

Thank You! <3

Collapse
 
alexisnorthcoders profile image
Alexis Creoulo

2 years later still useful. Legend.

Collapse
 
loribas profile image
Luis Otavio Ribas

Thank you !

Collapse
 
shilohooo profile image
shiloh

Great Post!!!

Collapse
 
federicoromeo profile image
Federico Romeo

Amazing thanks! Just want to point out:

2.0: Go to D:\ and create a directory wsl_export

Collapse
 
marvinxu profile image
Marvin

Can I set path on initial install?