Saturday, December 21, 2024
HomeSoftware DevelopmentEasy methods to set the default consumer for a WSL distro that...

Easy methods to set the default consumer for a WSL distro that has been manually put in with wsl –import

[ad_1]


I’ve blogged earlier than on how you can simply transfer WSL distributions between Home windows 10 machines with import and export. I just lately did a full recent set up of Home windows 11 and needed to deliver my current extremely custom-made Ubuntu set up together with me.

You’ll be able to tar up (zip up) the user-mode components of your WSL2 distributions like this:

wsl --export Ubuntu-20.04 c:TempUbuntuBackup.tar

The half after –export is the distribution title that you could see from operating wsl --list -v. The final argument is a full path and filename for the archive you need created.

Subsequent, on the machine you’ve got moved to, you may do the reverse. Discover that I’ve modified the Distro title right here, and you may if you would like. Keep in mind additionally that you could have as many Linux Distros put in as you need.

wsl --import Ubuntu c:Linux c:TempUbuntuBackup.tar

The Linux file system is saved in a VHDX (digital exhausting drive), normally deep in AppData/Native/YadaYada, however this import is a chance for me to retailer it in C:Linux which may even make it simpler to do upkeep on like Compact-VHD which shrinks your WSL2 disks.

This is the bizarre half. Whenever you import a WSL2 distro manually, operating that distro on the brand new machine will find yourself logging you in as root. It is forgotten that I am “scott.”

There’s numerous methods to repair this that contain the registry or passing in arguments to wsl, however I simply need it to work once I run “wsl” or “wsl -d distroname.”

Run your distro, after which edit /and many others/wsl.conf and add a [user] part like this:

[user]
default=scott

That is the best solution to set your WSL distro’s default consumer for imported tars as a result of it is saved contained in the Linux file system and the setting will stick round once you export/import in a while.

Linux on Windows

Hope this helps!


Sponsor: Lob APIs guarantee your addresses are deliverable and every thing you ship arrives on the proper place. Add tackle autocompletion and verification in minutes utilizing React, Vue or Javascript – Strive without spending a dime!




About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, guide, father, diabetic, and Microsoft worker. He’s a failed stand-up comedian, a cornrower, and a e book writer.

facebook
twitter
subscribe
About   Publication

Internet hosting By
Hosted in an Azure App Service










[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments