Can I move the linux subsystem to a different drive?
My C: is a small solid state that's already filling up. I'd like to move WLS to my D: or E: drive. Is this possible?
I imagine I'd have to uninstall then reinstall in order to move it. I'm ok with that if it's possible.
You can move the distribution to another drive using lxRunOffline.
1. Set permissions to the target folder. First, I think you must set some permissions to the folder where the distribution will be moved. You may use icacls <dir> /grant "<user>:(OI)(CI)(F)"
to set the proper permissions.
C:\> whoami
test\jaime
C:\> icacls D:\wsl /grant "jaime:(OI)(CI)(F)"
2. Move the distribution. Using lxrunoffline move
.
C:\wsl> lxrunoffline move -n Ubuntu-18.04 -d d:\wsl\installed\Ubuntu-18.04
You may check the installation folder using
C:\wsl> lxrunoffline get-dir -n Ubuntu-18.04
d:\wsl\installed\Ubuntu-18.04
3. Run the distribution. after moving the distribution, you can run the distribution using wsl
or the same lxrunoffline
C:\wsl> lxrunoffline run -n Ubuntu-18.04 -w
user@test:~$ exit
logout
C:\wsl> wsl
user@test:/mnt/c/wsl$ exit
logout
C:\> wsl.exe -l -v
NAME STATE VERSION
* Ubuntu Running 2
docker-desktop Running 2
docker-desktop-data Running 2
C:\> wsl.exe --export Ubuntu c:\ubuntu.tar
C:\> wsl.exe --unregister Ubuntu
C:\> wsl.exe --import Ubuntu d:\wsl\UbuntuCustom c:\ubuntu.tar
Based on another answer.