Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing a WSL2 distro with wsl --imoprt --vhd doesn't set default user #12402

Open
garysassano opened this issue Dec 22, 2024 · 3 comments
Open
Labels

Comments

@garysassano
Copy link

When transferring a WSL2 Ubuntu distribution between systems, I used the following commands:

First, on the source system to export the distribution:

wsl --export --vhd Ubuntu-24.04 ubuntu-24.04.vhdx

Then, on the destination system to import it:

wsl --import --vhd Ubuntu-24.04 \ubuntu-24.04.vhdx

After importing the distribution, I noticed two configuration issues that need to be addressed to match the default setup that comes with a Microsoft Store installation.

First, the imported distribution defaults to using the root user instead of a default user account. When installing Ubuntu from the Microsoft Store, it automatically sets up and uses a default user account for all operations.

Second, the shell environment isn't initializing properly. The login shell doesn't start automatically, which means .profile and .bashrc files aren't being loaded at startup. Currently, this requires manually running bash --login to get the proper shell environment. In contrast, a Microsoft Store installation handles all of this automatically, providing a properly configured bash login shell that loads all user profile files on startup.

The goal is to replicate the Microsoft Store's automatic configuration to achieve the same seamless experience with our imported distribution.

Copy link

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The script will output the path of the log file once done.

If this is a networking issue, please use collect-networking-logs.ps1, following the instructions here

Once completed please upload the output files to this Github issue.

Click here for more info on logging
If you choose to email these logs instead of attaching to the bug, please send them to wsl-gh-logs@microsoft.com with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@garysassano
Copy link
Author

/feature

You should be able to export and import a WSL2 image along with its settings bundled together.

Copy link

Diagnostic information
Found '/feature', adding tag 'feature'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant