Month: August 2021

Move WSL to another drive

I use a shared windows system at work and developers keep on filling the C drive where we keep our WSL installations. We were constantly reminded of moving our WSL data to a persistent D drive to avoid these space issues.

Initially I too ignored the messages but soon I too started to hit the quota limits. Last week I had install Terratest for the atomated testing and installing it along with golang filled my disk and started giving the quota full messsgaes.

Finally I decided to move my WSL installation to D drive. I was looking for the easiest options to move the data and stumbled up on a tool named LxRunOffline. I will list out the steps quickly, if you are interested to learn more please check the git page.

Git Repo: https://github.com/DDoSolitary/LxRunOffline

Step 1: Download and unzip latest version of the utility : https://github.com/DDoSolitary/LxRunOffline/releases

Step 2. Add the utility directory path to the path variable so that you can call it from anywhere.

Step 3: Open a new power shell window with admin privileges.

Step 4: Use the utility to list all WSL distributions installed on your machine

wslconfig.exe /list /all
or
lxrunoffline list

Step 5: Grant full privileges to destination directory where you want to move the files

whoami
icacls D:\N123231\WSL /grant "N123231:(OI)(CI)(F)"

Step 6: run the bellow command to move the distribution

lxrunoffline move -n Ubuntu-20.04 -d D:\N123231\WSL

Step 7 : Wait for sometime to move the data and once the command completes, make sure the new path is reflected in WSL configuration.

lxrunoffline get-dir -n Ubuntu-20.04