Move WSL from C Drive to Other Drive
Table of Contents
Move WSL from C Drive to Other Drive
Move WSL in \\wsl$
to W:\WSL
.
- Open PowerShell as Administrator
- Shutdown WSL
wsl --shutdown
- Check wsl version
wsl --list --verbose
- Create a new directory on the target drive
mkdir W:\WSL
- Export the WSL distribution
Ubuntu-22.04
to the new directory as a tar filewsl --export Ubuntu-22.04 W:\WSL\Ubuntu-22.04.tar
- Unregister the WSL distribution
wsl --unregister Ubuntu-22.04
- Import the WSL distribution from the tar file to the new directory
wsl --import Ubuntu-22.04 W:\WSL\Ubuntu-22.04 W:\WSL\Ubuntu-22.04.tar --version 2
- Set the default WSL distribution to the newly imported one
wsl --set-default Ubuntu-22.04
Login User Settings
The new WSL distribution’s login user is set to the root user by default. To change it to your user:
- Open the WSL distribution
wsl -d Ubuntu-22.04
- Change the login user to your user
vim /etc/wsl.conf
and add the following lines:
[user]
default=your_username
- Save and exit the editor
- Restart the WSL distribution
wsl --shutdown
and thenwsl -d Ubuntu-22.04