WSL Migration
After using WSL for a while, it can become bloated as more packages are installed. Since the C drive on my current computer is relatively small, I need to move WSL from its default location.
WSL Location
Run this command in PowerShell to find the WSL virtual machine file. Replace <name> with the name of your WSL distribution, mine is Ubuntu:
(Get-ChildItem -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss | Where-Object { $_.GetValue("DistributionName") -eq '<name>' }).GetValue("BasePath") + "\ext4.vhdx"
Migration
Based on this post by jayesh-vachhani, I confirmed that this method works.
Export Ubuntu
|
|
Unregister Existing WSL
|
|
Import
|
|
WSL migration is complete, and you can now start it!
Change Default User
WSL is now usable, but you may notice that the default login user is root. You need to change it:
|
|