There are different reasons to change WSL install directory. WSL (Windows Subsystem for Linux) can take a considerable amount of space on the system drive. One of the reason is many of the WSL users from windows 10 have a small system drive. There is a way to change the WSL installation drive after the initial installation.
To follow this tutorial you will require the following software installed:
Note: I am using Scoop for installing LxRunOffline on my pc. More details for Scoop installation can be found here: Chocolatey Open Source Alternative Scoop
- Scoop or Chocolatey
- LxRunOffline installed from Scoop / Chocolatey: You can install LxRunOffline via Scoop
scoop bucket add extras
,scoop install lxrunoffline
More details can be found here: https://github.com/DDoSolitary/LxRunOffline - Wsl Installed from Windows store
At first, execute wsl -l
command on your command prompt. you will see all of your installed wsl .
Now you can create a directory on your local drive where you want to move your WSL installation. I have added following on my local drive:
Now you can use this command to move your installation : lxrunoffline move -n
<distro Name> <directory path>
For example, to change WSL install directory of ubuntu, I issued lxrunoffline move -n Ubuntu-18.04 -d d:\wsl\installed\Ubuntu-18.04
command.
It will take some time depending on image size. After lxrunoffline
is done, you can execute the following command to check that the directory of wsl installation has changed.
C:\wsl> lxrunoffline get-dir -n Ubuntu-18.04
d:\wsl\installed\Ubuntu-18.04
Now you can enjoy installing multiple WSl distros without worrying about storage drive issues.