-
Notifications
You must be signed in to change notification settings - Fork 588
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
how to move the vhdx of wsl2 to other disk #412
Comments
You exported Alpine2 but imported Alpine3. Could you please clarify? |
@s-usr I exported my current running version of Alpine called |
Thanks. It will be nice if we could keep the name as is, because this is not a filename; it is a distribution name. |
Hello... I got "Access is denied" on import. I checked the "Security" for the 'source' and 'destination'. I have administrator priviliges. There should be a trick to handle this. Please advise if you came across this error. Thanks. |
See microsoft/WSL#4451 as an update. |
@craigloewen-msft I have compeletely follow the way you provide, however it seems i lost personal files in my WSL2 distro. Is it a expected behavior or just a bug? :( |
I'm sorry, the distro's default user was changed to root, may i bring it back to old user? |
Hello @craigloewen-msft , there is already a way to install Ubuntu distro or any other distro directly on another hard disk, and I have to follow the |
Easiest way to do it right now is using the import method. Adding the ability to install to another drive, or move to another drive is something we're tracking here: microsoft/WSL#449 |
Thank you, but call me a fool. Because once exported, I don't know what to do anymore. I checked the wsl -l -v versions and now I have 2:
So I have unregister the previous version (Ubuntu-18.04) with Now what do I have to do? I've tried this
but I get the message:
If I search for So I don't understand very well, can you help me? Okay, I just rebooted Windows, and now I can get in. I had to install Windows Terminal(Preview) to be able to enter the distro more easily. |
Yes you can run Glad that terminal resolved your probelm! |
Here is exactly what I did on 19035.1 and it worked without a reboot or errors.
PS C:\WINDOWS\system32> wsl -l
Windows Subsystem for Linux Distributions:
Ubuntu (Default)
# mkdir S:\ISOs\
PS C:\WINDOWS\system32> wsl --export Ubuntu S:\ISOs\ubuntu-wsl.tar
# mkdir w:\VMs
PS C:\WINDOWS\system32> cd w:\VMs
PS W:\VMs> mkdir ubuntu-wsl
PS W:\VMs> wsl --unregister Ubuntu
Unregistering...
PS W:\VMs> wsl --import Ubuntu W:\VMs\ubuntu-wsl S:\ISOs\ubuntu-wsl.tar
PS W:\VMs> wsl -l
Windows Subsystem for Linux Distributions:
Ubuntu (Default) |
If anybody is interested: I wrote a little bash and batch script for automating these steps. |
If allowed, you can do it with just one |
The instructions that @mxplusb provided worked really well for me, thanks! I had to add a Also, the default username that WSL uses needs to be reconfigured, otherwise it tries to log in as root with the command Hoping this gets included in the docs since this is extremely useful for SSDs especially. |
I saw a lot of scary answers with many steps and possible errors here, so I decided to just cut and paste the folder to a bigger HD. Then I told windows to link both of the folders: The second folder can have any name. No errors. No reboot. My SSD can breath again. Btw, don't use powershell, use cmd for this one. |
wsl --import --export command made a lot of disk io, can I just modify the registry of lxss?
from default to |
My steps is a combination of @rekaerst, @Neurrone, and @mxplusb
|
@banyh Any side effects or do you lose any data? |
You can unregister the original distribution before import.
|
I have tried to follow these steps, but I got |
@iegorval Try checking file permission of ext4.vhdx in case you run those commands as the superuser. Also, don't forget to try to turn it on and off again. From my experience changing |
Hi All, I have found different approach for this problem for moving existing installation to different drive. Shutdown all VMs by following command 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. |
This is very helpful, thanks so much. However, I'm getting NTFS errors due to illegal characters, even if the vhdx file is an ext4 one. Is anyone else experiencing this issue? |
Not Really sure if this is the proper solution. But for anyone looking, simply move it to another drive and not really care about the directories, I tried moving the ubuntu app(simply select move and chane the location ) in Windows App settings. It sort of worked and my ext4.vhd file got moved from C to D:/ drive ! (Correct me if am doing wrong!) |
Does the |
Nope. At least it did not in my case 😜 |
This has worked perfectly for me. So I guess the export import is not required. Or is there some other considerations in this regard? |
I only would like to know if it is possible to perform this for an ext4 pen drive, or if it is exclusive for NTFS drives. |
This helped me out! Thank you so much! |
I wrote some PowerShell automation for @sonook's registry-based WSL2 disk move. https://github.com/Jammrock/Move-WSL2NewDrive Tested locally on Win11 using PowerShell 7. YMMV on Win10 and/or Windows PowerShell 5.1. |
Hey, can you please tell me if I can delete mine tar file, Almost 60 gb has been freedup from my main drive. Can I now delete the .tar file after importing? |
Sure, you can. |
It's could be better if we can specify the path to store disk image when install WSL. The registry mod work well but you need to touch it everytime you install a new distro. |
Thanks! |
create |
Testing on Current Windows 11, This is most simple way without needing to change config and default user. |
What should I do if the registry is lost? I only have VHDX and exe files, and I have customized a rag.
But it prompts an error
These are all valid environment paths How to find or restore the correct |
Short answer:
For the DefaultUid, edit the /etc/wsl.conf add [user] |
I install wsl2 , i learn that wsl2 use vhdx as store file, because C disk is small, so I want to move the vhdx file to other disk.
please tell me how to do it. thx
The text was updated successfully, but these errors were encountered: