My C: drive was screaming for help. Between Docker, several Linux distros, and general dev bloat, the ext4.vhdx file had ballooned to nearly 600GB. Since Windows 11 doesn’t have a “move” button for WSL, I had to do it the manual way.
Here is how I moved my Ubuntu instance to my D: drive. All terminal commands are executed in a PowerShell terminal running as Administrator.
1. The Prep
First, shut down WSL completely so the disk file isn’t locked.
wsl --shutdown
Create a destination folder on the target drive, for example D:\WSL\Ubuntu.
2. Export and Unregister
We need to create a backup of the current state, then wipe the version living on the C: drive.
# Export the distro to a tar file
wsl --export Ubuntu D:\WSL\ubuntu-backup.tar
# Unregister the old instance (this deletes the C: files!)
# Make sure that he ubuntu-backup.tar is finished and complete.
wsl --unregister Ubuntu
3. The Import
Now, import the backup into the new location.
wsl --import Ubuntu D:\WSL\Ubuntu D:\WSL\ubuntu-backup.tar
4. Fixing the Default User (The Registry Way)
After an import, WSL defaults to the root user. The usual ubuntu config --default-user command often fails because the app metadata is lost during the move.
To fix this, I used the Registry Editor:
- In Ubuntu, find your UID:
id -u louie(usually 1000). - Open
regeditand navigate to:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss - Find the folder with the
DistributionName“Ubuntu”. - Double-click
DefaultUID, switch the base to Decimal, and enter your UID.
5. Cleanup
Once you’ve verified that everything works and your files are intact, delete the D:\WSL\ubuntu-backup.tar file to reclaim that space.
Done. My C: drive has some breathing room, and my dev environment is exactly where I left it.