Install Debian in Different Location -WSL Windows

I was trying to install Debian in different location rather than the C drive . Sharing the steps I took .
OS : Windows 11 WSL Version : Wsl 2
- First install Debian as by default in C
wsl --install -d Debian
- Shut down wsl
wsl --shutdown
- Export Debian to your desired location
In my case its E :
wsl --export Debian E:\wsl_export\debian-ex.tar
- Now unregister your old Debian from wsl
wsl --unregister Debian
- Now import Debian to the Disk
wsl --import Debian "E:\wsl\Debian" "E:\wsl_export\debian-ex.tar"
- Cleanup You can remove your backup now and set Debian as default
wsl --set-default Debian
Extra tips
- To make your user in debian superuser : After migrating you might loose your default login using username you created before .
Login to Debian , By default you will be logged in as root and hit following
sudo usermod -aG sudo username
- Change default user
nano /etc/wsl.conf
Replace username with your username
[user]
default=username
Now wsl --shutdown
and login debian again you should be logged in as your default user with sudo access