DEV Community

Kshitij Raj Sharma
Kshitij Raj Sharma

Posted on • Edited on

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

1) First install Debian as by default in C

wsl --install -d Debian
Enter fullscreen mode Exit fullscreen mode

2) Shut down wsl

wsl --shutdown
Enter fullscreen mode Exit fullscreen mode

3) Export Debian to your desired location

In my case its E :

 wsl --export Debian E:\wsl_export\debian-ex.tar
Enter fullscreen mode Exit fullscreen mode

4) Now unregister your old Debian from wsl

wsl --unregister Debian
Enter fullscreen mode Exit fullscreen mode

5) Now import Debian to the Disk

wsl --import Debian "E:\wsl\Debian" "E:\wsl_export\debian-ex.tar"
Enter fullscreen mode Exit fullscreen mode

6) Cleanup
You can remove your backup now and set Debian as default

wsl --set-default Debian
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode
  • Change default user
nano /etc/wsl.conf
Enter fullscreen mode Exit fullscreen mode

Replace username with your username

[user]
default=username
Enter fullscreen mode Exit fullscreen mode

Now wsl --shutdown and login debian again you should be logged in as your default user with sudo access

Top comments (2)

Collapse
 
virla01 profile image
AspectoX

Question: Isn't there something similar but in Linux, to be able to install Windows programs?
I don't want the wine program

Collapse
 
krschap profile image
Kshitij Raj Sharma

Not that I am aware of if wine is not an option ! Wondering about the usecase though