Installing WSL on another drive in Windows
AW A RE

AW A RE @mefaba

About: Follow me on github. Lets talk projects! Prefer to build with golang or javascript

Location:
Toronto, CA
Joined:
Mar 28, 2020

Installing WSL on another drive in Windows

Publish Date: May 9 '22
105 24

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.

Comments 24 total

  • Guto
    GutoOct 1, 2022

    life saver

  • Diwakar dayal
    Diwakar dayalOct 29, 2022

    thank you!!

  • Kauê Fraga Rodrigues
    Kauê Fraga RodriguesNov 17, 2022

    Kinda useful! 🔥 Thanks for sharing!!!

  • Iretioluwa Olawuyi
    Iretioluwa OlawuyiDec 4, 2022

    Thanks very much for sharing. This is super helpful!

  • Maintain
    MaintainDec 10, 2022

    Thank you for sharing

  • Ahmed Mohamadeen
    Ahmed MohamadeenFeb 4, 2023

    Thanks!
    I'd like to add a reference to some steps mentioned in the default documentation like setting up a default user, because by default --import always starts the image in the root user.
    learn.microsoft.com/en-us/windows/...

  • Milinda Barua
    Milinda BaruaFeb 6, 2023

    if you get a root user after exporting and if you happen to make a user or had a user already before exporting then go to settings and at the profile of the exported linux distro in the command line tab add the line : wsl.exe -d -u . the part till distro name will be same but pass the -u flag with your username and you will get the previous user that was being used

  • Zenit Kovačević
    Zenit KovačevićFeb 7, 2023

    That worked, mostly. The WSL2 distro that I imported can't run GUI application anymore for some reason.

  • kogordev
    kogordevFeb 24, 2023

    Thank you very much.

  • George Leão
    George LeãoMar 21, 2023

    Thanks my friend!!

  • Asad
    AsadMar 24, 2023

    Can wsl_export be deleted after running the last command?

    • GuTheR
      GuTheRJun 13, 2023

      No!! Don't do that!

  • wheatfox
    wheatfoxAug 15, 2023

    THANK YOU!!!!

  • Alan Ma
    Alan MaOct 10, 2023

    Super solution! Thank you @mefaba
    Image description

  • Marvin
    MarvinNov 2, 2023

    Can I set path on initial install?

  • Federico Romeo
    Federico RomeoMar 13, 2024

    Amazing thanks! Just want to point out:

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

  • shiloh
    shilohApr 1, 2024

    Great Post!!!

  • Luis Otavio Ribas
    Luis Otavio RibasJun 8, 2024

    Thank you !

  • Alexis Creoulo
    Alexis CreouloJun 20, 2024

    2 years later still useful. Legend.

  • Cristiano Raffi Cunha
    Cristiano Raffi CunhaAug 4, 2024

    Thank You! <3

  • Sokhib Tukhtaev
    Sokhib TukhtaevAug 21, 2024

    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.

  • Dejan
    DejanOct 2, 2024

    That works fine for me. Thank you a lot.

  • mamad jufry
    mamad jufryJan 14, 2025

    thank you

  • NguyenTai2002
    NguyenTai2002Jul 16, 2025

    saved my life, thank you so much, 2025 check

Add comment