Discussion Locked

Need help on moving WSL instace to another drive

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Is anyone ever moved WSL instance to another drive or location? I might need to reformat my windows partition but I want to preserve my WSL instance. Any help or suggestions are welcome. Thanks!

3 replies

by thewelltags

Moving a WSL instance is straightforward using the built-in export and import functions. This creates a standalone compressed file that you can store on an external drive while you reformat.

1. Export your instance
Open PowerShell (as Administrator) and list your distros to get the exact name (e.g., Ubuntu):

PowerShell
wsl --list --verbose
Shut down WSL to ensure no data corruption:

PowerShell
wsl --shutdown
Export the distro to your backup drive (e.g., D: drive):

PowerShell
wsl --export Ubuntu D:\wsl_backup.tar
2. Reinstall and Import
After reformatting Windows and reinstalling WSL, you can "import" that file back to any location you want:

PowerShell
wsl --import Ubuntu-New C:\WSL-Storage D:\wsl_backup.tar
Ubuntu-New: The name you want to give the distro.

C:\WSL-Storage: The folder where the virtual disk will live.

D:\wsl_backup.tar: The path to your backup file.

3. Set the Default User
When you import, WSL often defaults to the root user. To switch back to your regular username, run:

PowerShell
Ubuntu-New config --default-user yourusername

by rproffitt edited

That's what I got from Claude the last time I asked about the export/import steps.

This discussion is closed to new replies.