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

Getting Windows 10 to realize the new location for the Linux distro #4451

Closed
s-usr opened this issue Aug 29, 2019 · 7 comments
Closed

Getting Windows 10 to realize the new location for the Linux distro #4451

s-usr opened this issue Aug 29, 2019 · 7 comments

Comments

@s-usr
Copy link

s-usr commented Aug 29, 2019

After moving the Linux distro (see MicrosoftDocs/WSL#412), I got "access denied" when importing. This is probably because I do not have WSL2. I cannot get WSL2 because I have build 10.0.18362. Gettign the latest build failed because of the limited space on C.

When importing did not work, I unzipped the Linux distro at L:

I do not want to reinstall the app because the installation will again go to C:\users...\AppData\Packages\LocalState...

How do I get Windows to realize that the Linux distro is at L: (through D:\Linux.vhdx) not at C:\users... anymore? Can anybody share the Environment Variables after the distro has been moved?

As noted earlier, if I run 'bash' from the Power Shell, I get the message

bash
Windows Subsystem for Linux has no installed distributions. Distributions can be installed by visiting the Microsoft Store: https://aka.ms/wslstore

But I do not want to install again, because the installation will go to C. I already have the full distro at L.

Thanks.

@craigloewen-msft
Copy link
Member

craigloewen-msft commented Sep 4, 2019

Can you share the steps that you're taking to import your WSL distro and the exact error message you're seeing?

Have you tried re-importing the distro using the tar file?

EDIT: Looking at this again, with that build number you do have access to WSL 2. Please see our install instructions on setting it up. Since you have a .vhdx file it looks like you're importing it as a WSL 2 distro, make sure you're using WSL 1 if you don't have the Virtual Machine Platform component enabled. You can do that by running wsl --set-default-version 1 before running the import command.

@s-usr
Copy link
Author

s-usr commented Sep 5, 2019

Thanks much. I have joined the Insider program, but installation of the latest build failed twice by now. I will attempt again. Once the installation works, I will have access to WSL2, and I will post an update then.

@s-usr
Copy link
Author

s-usr commented Sep 9, 2019

*** For the benefit of others who might come across this case ***

On the fourth trial, Windws 10 update-as part of the 'Insider Program'-worked and I got build 18975. I was now able to successfully update WSL to version 2. WSL version 2 requires the 'VirtualMachine' feature. Coincidentally, I read that the VM feature might need to be enabled in the BIOS settings. I rebooted my 'Lenovo' laptop pressing F2 until I got the BIOS menu. Sure enough, under "Configuration" the "Intel Virtual Technology" was disabled. I enabled that, saved, and exited. As the laptop restarted, I went to C:\Users\user\AppData\Local\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState, highlighted and deleted the folders "rootfs" and "temp".

Open PowerShell as an Administrator:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
Pushing the Debian icon in Windows Start Menu, I got a fresh install of Debian GNU/Linux. This created "ext4.vhdx" and the folder "temp" under "C:\Users\user\AppData\Local\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState".
wsl --set-version Debian 2
wsl --set-default-version 2
wsl -l -v
This gives: Name: Debian | State: Running | Version: 2.

If you get the error message "VHD must be uncompressed", uncompress the folder "C:\Users\user\AppData\Local\Packages" and its descendants. File Explorer | Point to the folder | Properties | Attributes / Advanced | Uncheck "Compress to save disk space".

If you get the "Permission Denied" error, get permissiosn through File Explorer | Properties | Security or:

icacls "C:\Users\user\AppData\Local\Packages" /grant "user:(OI)(CI)(F)"

Open CommandPrompt as an Administrator. This is because PowerShell does not understand 'mklink'.

cd C:\Users\user\AppData\Local\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4
ren "LocalState" "Linux.bak"
robocopy "Linux.bak" "D:\Linux" /E /ZB /DCOPY:T /COPYALL /R:1 /W:1 /V (should execute wo error)
mklink /J "LocalState" "D:\Linux" (you will see "Junction created for LocalState <<===>> D:\Linux")
robocopy "D:\Linux" "LocalState" /E /COPY:SOU /xo /xn /xc /xx (should execute without errors)
bash
user@PLUTO:/mnt/c/$ exit
logout
C:>

Test also through PowerShell and the Debian icon under Windows Start. Reboot. Test one more time through the CommandPrompt, PowerShell, and the Debian icon under Windows Start. Everything should be fine. You now have a functional Linux distribtion with "C:\Users\user\AppData\Local\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalState" pointing to "D:\Linux". You can now delete "Linux.bak" under "C:\Users\user\AppData\Local\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4". In all of the above, 'user' is your username.

Hope this helps!

@s-usr
Copy link
Author

s-usr commented Sep 9, 2019

icacls "C:\Users\user\AppData\Local\Packages" /grant "user:(OI)(CI)(F)"

In the version above, "user" (that is your username) did not come out. This is meant to be "grant user (OI)(CI)(F) inheritance and full access permissions". See https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/icacls.

@ctivanovich
Copy link

I'm getting this same issue trying to import ubuntu-19.04 with the wsl command. No matter where in I try to install the distro to, I get access denied.

@AllanOricil
Copy link

AllanOricil commented Jun 7, 2020

@craigloewen-msft
These https://docs.microsoft.com/pt-br/windows/wsl/install-win10 instructions are not working for me.
After I restarted my laptop I only get
image

And Im executing powershell as an Administrator.

@iammathh
Copy link

iammathh commented Jun 8, 2021

Hello folks, here is the best solution for that issue:

Run command: wsl --shutdown

Go to : regedit

Go to Registry Path for WSL2 installation.

Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\

Find your installation folder and change the basepath to desired drive and path.

Cut and Paste your ext4.vhdx from default path to desired drive.

Video representation of solution for movement of ext4.vhdx file to other location.

https://youtu.be/ON_dPAO4KZs

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

No branches or pull requests

5 participants