Skip to content

Dear Internet Explorer user: Your browser is no longer supported

Please switch to a modern browser such as Microsoft Edge, Mozilla Firefox or Google Chrome to view this website's content.

Back-up and restore a Linux distro in WSL2

If you need to upgrade a Windows machine, set-up a new PC or restore a broken system, there’s a fairly straightforward method for backing-up and restoring WSL distros.

Windows Subsystem for Linux (WSL) allows users to run a complete Linux environment on their Windows machines. The installation of WSL is managed via Windows Powershell (PS).

Here is a list of useful commands for backing-up and restoring WSL:

Check which Linux distros you have installed

To generate a list of installed Linux distributions in WSL, open PowerShell and enter the following command.

wsl -l -v

Make a backup of a WSL distro

Backups of WSL distros are stored as .tar files. To backup a distro, you need to use the wsl --export command, which is followed by:

wsl --export Ubuntu-20.04 c:\users\adamdimech\UbuntuBackup.tar

Restore a WSL distro from a backup

To restore a WSL distro from a back-up, use the wsl –import command in PS followed by:

wsl --import Ubuntu-22.04 D:\wsl2 D:\wsl_backups\Ubuntu_22_04.tar

When a WSL distro is installed from a backup, the default user will be root. If you want to change this (or restore the default username to what it was), use the wsl --manage in PS followed by:

wsl --manage Ubuntu-22.04 --set-default-user adamdimech

   

Comments

No comments have yet been submitted. Be the first!

Have Your Say

The following HTML is permitted:
<a href="" title=""> <b> <blockquote cite=""> <code> <em> <i> <q cite=""> <strike> <strong>

Comments will be published subject to the Editorial Policy.