<!--
  canonical-url: https://www.avonture.be/blog/move-wsl-to-another-location
  published:     2023-11-03
  This is a static plain-Markdown mirror generated at build time.
  Visit the canonical URL above for the fully rendered page, with images and interactive components.
-->

# Move WSL to another location

> Running low on C drive space? Follow this step-by-step guide to safely move your WSL (Windows Subsystem for Linux) distribution and Docker data to a new drive location using the wsl --export and wsl --import commands.

---
![Move WSL to another location](/img/v2/wsl.webp)

> <https://dev.to/mefaba/installing-wsl-on-another-drive-in-windows-5c4a>

**TL;DR**

This article shows how to move a WSL2 distribution off the C: drive to free up space, using `wsl --shutdown`, `wsl --export` to a `.tar` file, `wsl --unregister` to remove the original, and `wsl --import` to recreate it on another drive — the same export/unregister/import pattern also works to relocate the Docker Desktop WSL partition.

By default, the Linux distribution is installed on your C: drive. If, like me, you have a D: drive with almost nothing on it, it can be really interesting to move Linux to that second drive.

*Once moved, nothing else changes: your distribution keeps working exactly as before, [including opening your Linux folders in Windows Explorer](/blog/wsl-windows-explorer).*

To do this:

* Run `wsl --list --verbose` from a **PowerShell** console; you will get the name of your distribution (`Ubuntu` in my case),
* From an **administrator PowerShell** console,
  * Run `wsl --shutdown` to shutdown WSL,
  * On your second drive, create a temporary folder like `d:\wsl`,
  * Run `wsl --export Ubuntu d:\wsl\ubuntu.tar`,
  * When finished, run `wsl --unregister Ubuntu` and then,
  * Run `wsl --import Ubuntu d:\wsl\ubuntu d:\wsl\ubuntu.tar --version 2`
  * Run `del d:\wsl\ubuntu.tar`

You will need to do this for every distribution you have installed that you want to move.

> **Information:**
>
> If you have Docker, you can do the same and move the Docker partition to your second disk.
>
> ```bash
> $ wsl --export docker-desktop d:\wsl\docker-desktop.tar
> ...
> $ wsl --export docker-desktop-data d:\wsl\docker-desktop-data.tar
> ...
> $ wsl --unregister docker-desktop
> ...
> $ wsl --unregister docker-desktop-data
> ...
> $ wsl --import docker-desktop d:\wsl\docker-desktop d:\wsl\docker-desktop.tar --version 2
> ...
> $ wsl --import docker-desktop-data d:\wsl\docker-desktop-data d:\wsl\docker-desktop-data.tar --version 2
> ...
> $ del d:\wsl\docker-desktop.tar
> ...
> $ del d:\wsl\docker-desktop-data.tar
> ...
> ```

Once done, restart your computer to finalize the move.
