Skip to main content

Command Palette

Search for a command to run...

Moving the WSL installation of Kali Linux to a different location

Moving on Up!

Published
2 min read
Moving the WSL installation of Kali Linux to a different location
  • Open PowerShell as an administrator

  • Run the following command to install Chocolatey via PowerShell (https://chocolatey.org/install)

 - Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
  • Set permissions to the target folder.
- Run the following in powershell

- whoami

example\chris

- icacls D:\<example_folder> /grant "chris:(OI)(CI)(F)"
  • Install lxrunoffline (https://github.com/DDoSolitary/LxRunOffline)
- choco install lxrunoffline
  • Find out your running linux version
- Run the following in powershell

- wsl.exe -l -v

*kali-linux running
  • If your Linux instance is running
- Run the following in powershell

- wsl --shutdown
  • Move Kali-Linux to another directory using lxrunoffline
- lxrunoffline move -n kali-linux -d d:\<example_folder>
  • Run the distribution
- Run the following in powershell

- lxrunoffline run -n kali-linux -w
  • Confirm that the instance is running
- Run the following in powershell

- wsl.exe -l -v
  • Please note: Once moving over Kali-Linux you may need to set folder exclusions so that pentesting tools would work as expected, see (https://westoahu.hawaii.edu/cyber/best-practices/best-practices-weekly-summaries/how-to-install-kali-linux-as-an-app-in-windows-10/)

  • Please note: If this a fresh install of Kali-Linux it is recommended that the WSL be upgraded to WSL 2. See (https://winaero.com/update-from-wsl-to-wsl-2-in-windows-10/)

Reasons to move the Kali-Linux install: By default the location of this application is in the root of C. If you are using the windows store to install Kali-Linux, it will use this default location. When using the lxrunoffline tool the registry keys which default the location are changed, and the application is moved without issues.

Sources: https://superuser.com/questions/1113906/can-i-move-the-linux-subsystem-to-a-different-drive