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

Want to use previous installed wsl in new windows user. #4312

Closed
WoeiSheu opened this issue Jul 17, 2019 · 16 comments
Closed

Want to use previous installed wsl in new windows user. #4312

WoeiSheu opened this issue Jul 17, 2019 · 16 comments
Labels

Comments

@WoeiSheu
Copy link

Please fill out the below information:

  • Your Windows build number: ver17763.615

  • What you're doing and what's happening:
    I created a new user in windows, and i cannot use wsl any more, which requires wsl to be installed again. But the computer cannot connect to internet now, because it has been in the enterprise lan.

  • What's wrong / what should be happening instead:
    I want to know how can I move the previous installed wsl to a new user folder. I tried just to copy and paste c:/users/username/appdata/local/packages/canonicalgrouplimited.ubuntu18.04… to new user folder, it seems no effect.
    SO how need i do? i cannot find any instructions on google.

@craigloewen-msft
Copy link
Member

To clarify, when you say 'I cannot use wsl any more' do you mean that you can't access the same Linux files as you had in your other user account? When you open up your distro app or run wsl.exe it shows you the new user creation screen correct?

If that is the case, then this is done by design. WSL stores Linux files on a per user basis.

If that is not the case and you're running into a technical issue when running as a new Windows user could you explain the issue you're facing a little more? Like the error codes you see, etc.

@WoeiSheu
Copy link
Author

WoeiSheu commented Jul 17, 2019

Yeah, it shows the new user creation screen correct.
And I know that "this is done by design" and "WSL stores Linux files on a per user basis".

The problem is whether I can reuse the wsl files that have installed by another user.
That is to say, is it possible to make the folder "C:\Users<Username>\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc" reusable without reinstalling wsl for the new user?

I tried move/copy the folder to the new user folder, but it didn't work.

@Biswa96
Copy link

Biswa96 commented Jul 17, 2019

Can you log in that previous user? If yes then you can create a tarball from root folder and then install it in new user using wslapi.

@craigloewen-msft
Copy link
Member

As @Biswa96 mentioned you can use wsl --export and wsl --import to export and import the WSL distribution to another user.

As well, you can put any files that you would like shared in places on the Windows hard drive where both users can access them (like the C drive etc.)

But for your specific ask, it's not possible to copy and paste the files in AppData and move them over, and in general Linux files in WSL from one user's account are inaccessible from another user's account. If I was trying to replicate setups, I would use wsl --export and wsl --import. If you run wsl --help it'll show you the arguments for those commands.

@therealkenc
Copy link
Collaborator

As @Biswa96 mentioned you can use wsl --export and wsl --import to export and import the WSL distribution to another user.

That, or probably a more fluent solution (and I think what Biswa96 was suggesting), would be to tar up / from inside the old user's installation, and then restore it after installing a fresh Ubuntu from the Store. A walkthrough of how to do that can be found here. Ref #4268.

But for your specific ask, it's not possible to copy and paste the files in AppData and move them over

[Related: unfortunately there just isn't any supported way that I know of, if you go out and buy a shiny new SSD and migrate your Microsoft User to your new D: drive, to bring your Store apps with you. The scenario doesn't matter much to folks with most other Store apps (Candy Crush Saga), because all the user's "data" is in the cloud. With Ubuntu-18.04 from the Store, your "data" is your whole distribution.]

@WoeiSheu
Copy link
Author

WoeiSheu commented Jul 24, 2019

Thank you very much. @Biswa96 @mscraigloewen @therealkenc
I cannot log in the previous user due to the low access permissions, and I finally gave up using wsl on the computer...

@craigloewen-msft
Copy link
Member

craigloewen-msft commented Jul 24, 2019

I've marked this as 'bydesign' and closed it out since WSL is designed such that different users can not access other user's Linux files. I'm sorry it didn't work out for you in this case, if you have any more WSL questions please feel free to follow up!

@krisavi
Copy link

krisavi commented Dec 3, 2019

I had the same issue due to company split and had to migrate portion of users from one company into new one. Even though I kept all the appdata, the WSL for some reason was reset and I guess I lost all the files saved in WSL, which is not great. If it is by design, then it is flawed design. It is for sure an edge-case, not a common thing to happen. But unfortunately it seems there is no way for me to export or import anything as wslconfig /l is empty while in Windows store I have Debian still installed.

@Tyrben
Copy link

Tyrben commented Jan 2, 2020

It's a shame that WSL is not pure file based. Like @WoeiSheu , I haven't access to the first user (it was a Domain migration).

@Falconx1000
Copy link

I know this is closed but the way I have been able to set myself up again after a forced migration is

  1. Install the same distro on the new user account
  2. Configure the same user (not sure if the same password is required but I have used the same password)
  3. use WSL to shutdown the distro
  4. copy the distro folder into the new users appdata where the distro is installed
    Then I was able to open up the distro again and all the files were back where they were. Hope this helps

@Gregory-N-able
Copy link

I had the same issue due to company split and had to migrate portion of users from one company into new one. Even though I kept all the appdata, the WSL for some reason was reset and I guess I lost all the files saved in WSL, which is not great. If it is by design, then it is flawed design. It is for sure an edge-case, not a common thing to happen. But unfortunately it seems there is no way for me to export or import anything as wslconfig /l is empty while in Windows store I have Debian still installed.

I am in the same boat. Company split and the WSL install wasn't migrated to the new AzureAD account on my system. I get this is by design, but maybe use One Drive for Business like so many other aspects of Windows these days, and store the WSL image there, such that after a migration (and once One Drive is migrated), it is ready to go in the new account.

@dsech
Copy link

dsech commented Sep 17, 2021

In my case the wsl files are already outside the old user folder: D:\wsl\ubuntu-20.04\ext4.vhdx, but it's still not clear how to tell wsl on my new user to use this file :(

@Biswa96
Copy link

Biswa96 commented Sep 17, 2021

One of the shortest way:

  1. Install a dummy distribution with wsl --import command at your preffered path.
  2. Shutdown WSL2 VM with wsl --shutdown. This is important because WSL2 VM and its infrastructure holds a lock of that file.
  3. Replace the current ext4.vhdx file with your previous one.

@mihaiiorga
Copy link

I had the issue that the default user was root, so I had to go to \HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss and change the DefaultUid under the distro installed to my user in the WSL distro, which was 1000. Now everything is like before.

@sameert89
Copy link

sameert89 commented Sep 17, 2024

Here is what worked for me in 2024:

  1. From the Old user export the wsl distro to a file using wsl --export <DistributionName> <OutputLocation>
  2. Also copy the .vhdx file from the old user, it can be found in %userprofile%\AppData\Local\Packages\<VariesWithDistro>\LocalState
  3. Transfer these files to the new user.
  4. On the new user import the tar file using wsl --import <DistroName> <InstallLocation> <InstallTarFile>
  5. Run wsl --shutdown, now go to the location you chose for installation, and replace the vhdx file with the backup from earlier.
  6. Open registry editor, navigate to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrenrVersion\Lxss.
  7. There will be a number of folders with names as GUIDs of your installed distros and users in them, ideally if you don't have multiple installations you should only see one, click on it and change the DefaultUid key to 1000 in decimal.

@cawoodm
Copy link

cawoodm commented Sep 25, 2024

It's fine that WSLs are user specific. What's not fine is that when User 1 installs WSL+Ubuntu, User 2 (admin) can start wsl but they don't see Ubuntu and WS claims no distros are installed. When you then download and launch Ubuntu .AppxBundle the app store says it's already installed. So User 2 can't use WSL. wsl --install not respecting any proxy settings (or env variables) makes this even harder.

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