· 1 min read
Move a WSL 2 distribution to another drive
Export, unregister, import — and restore the default user, which the import quietly resets to root.
WSL 2 keeps each distribution in a single virtual disk, by default on C:. When the disk fills up, moving Ubuntu to another drive is a three-command job with one easy-to-miss detail: after the import, the default user is root again.
Before you start
wsl -l -v
Note the exact distribution name (Ubuntu, not Ubuntu-22.04 unless that is what is listed). The tar archive will be roughly the size of the disk you are exporting, so make sure the destination has room for the archive and the imported disk.
1. Export
mkdir D:\backup
wsl --export Ubuntu D:\backup\ubuntu.tar
2. Unregister
wsl --unregister Ubuntu
This deletes the distribution from C:. The export is now the only copy — check that the tar file exists and has a sensible size before running this.
3. Import
mkdir D:\wsl
wsl --import Ubuntu D:\wsl D:\backup\ubuntu.tar
The second argument is the directory that will hold the new virtual disk; the third is the archive. Keep the archive until you have logged in and confirmed everything survived.
4. Restore the default user
The imported distribution starts as root. The launcher binary in WindowsApps sets the default user back:
cd %userprofile%\AppData\Local\Microsoft\WindowsApps
ubuntu config --default-user james
Use the launcher that matches the distribution name (ubuntu, ubuntu2204, and so on). If your name is not in the list, wsl --import created a distribution without a launcher and you have to set the user through /etc/wsl.conf.
5. Verify
whoami
df -h /
The first command should print your normal user, the second should show the new mount.
Once you are happy, delete D:\backup\ubuntu.tar.
Source: Super User — move the WSL 2 file system to another drive.