Get-ChildItem "HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss" -Recursewsl --export Ubuntu .\Ubuntu\ext4.vhdx --vhd
wsl --unregister Ubuntu
wsl --import-in-place Ubuntu .\Ubuntu\ext4.vhdxAfter export and import, the new instance will use root by default. If you want to continue to use that user, please configure it via registry table.
Find the directory in registry HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss which DistributionName is “Ubuntu”. Set its DefaultUid to decimal 1000 (or hex 3e8).
/etc/wsl.con
[user]
default=username