By Default the WSL distribution will be installed to the default C drive
. But it is possible to move the installation to be on another drive.
-
Step 1
cd D:\ mkdir WSL cd WSL wsl --export kali-linux kali-linux.tar wsl --unregister kali-linux mkdir kali-linux wsl --import kali-linux kali-linux kali-linux.tar
explanation:
wsl --export kali-linux kali-linux.tar
copy the content of the current kali-linux image to a tar file that you will get in your D: drive.wsl --unregister kali-linux
remove the current active distributionwsl --import kali-linux kali-linux unbuntu.tar
import the distribution from the tar file. The 1st kali-linux is the name of the distribution (follow the name of the old distribution name). The 2nd kali-linux is the directory of folder where instance should be.kali-linux.tar
is the compressed distribution from the previous copy.
-
Step 2
In Step 1, you have created a user for kali-linux. After export and import, the new instance will use root by default. If you want to continue to use that user, please configure it via registry table. Find the directory in registry HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss which DistributionName is “kali-linux”. Set its DefaultUid to decimal 1000 (or hex 3e8).
-
Step 3
Set the WSL to use the new distribtion via the following
wsl set-version kali-linux 2 # Set the default WSL to version 2 for the distribution wsl -d kali-linux # Start the distribution
If you want to automate the process of Step 1
, there's a script made that will allow you to do just that.
.\scripts\moving-dist.ps1