Skip to main content
Home
Techies Briefcase
~ by Hari Venu

Main navigation

  • Home
  • Tools
    • Placeholder Image
    • JSON Diff
    • QR Code Generator
    • Random String Generator
    • HTML to PDF Generator
  • About me
  • Photos
  • Search

Breadcrumb

  1. Home
  2. How To Backup, Unregister, and Import a WSL Distribution

How to Backup, Unregister, and Import a WSL Distribution

By hari, 23 September, 2024

Windows Subsystem for Linux (WSL) allows you to run Linux distributions on your Windows machine. Over time, you may want to back up or migrate your WSL distributions to another location or device. In this article, we will guide you through the steps to export, unregister, and import a Linux distribution in WSL.

Step-by-Step Guide:

1. Check WSL Versions and Installed Distributions

Before making any changes, you can check the current state of your installed distributions by using the wsl -l -v command:
wsl -l -v

This command lists all installed distributions, their states (Running or Stopped), and their versions.

In the example image, two distributions were listed: Ubuntu and Debian, both using version 2 of WSL and currently stopped.

2. Exporting a WSL Distribution

To create a backup of a WSL distribution, the --export option is used. This will export the distribution into a .tar file, which can be restored later.

wsl --export Debian c:\wsl\backups\debian.tar

- Debian: The name of the WSL distribution to export.
- c:\wsl\backups\debian.tar: The location where the backup is stored as a tar file.

The output indicates the operation completed successfully, meaning the Debian distribution has been exported and backed up.

3. Unregister a WSL Distribution

If you want to remove the distribution from WSL after exporting (for example, to migrate or free up space), you can unregister it using the --unregister command:

wsl --unregister Debian

This command removes the distribution from WSL. However, the actual files on your filesystem are not affected by this step if you have previously exported the distribution.

4. Importing a WSL Distribution

To restore or migrate a distribution from a previously exported .tar file, the --import option is used. This re-imports the distribution into WSL at a specified location.

wsl --import Debian c:\wsl\installs\debian c:\wsl\backups\debian.tar

- Debian: The name to assign to the imported distribution.
- c:\wsl\installs\debian: The directory where the root filesystem of the imported distribution will be stored.
- c:\wsl\backups\debian.tar: The path of the tar file to be imported.

Once the operation completes successfully, the distribution is reinstalled and ready for use. You can verify it by checking the list of installed distributions again:

wsl -l -v

The output shows that Debian has been successfully re-imported.

5. Accessing the Filesystem

Once the import is complete, you can access the WSL distribution by specifying the distribution name in the wsl -d command:

wsl -d debian

In the image, the user navigated into the Debian filesystem and listed files like NTUSER.DAT, Pictures, and others, indicating access to the user directory after the import.

Summary of Commands:

1. List installed distributions:  
  wsl -l -v
  
2. Export a WSL distribution:  
  wsl --export <DistroName> <BackupPath.tar>
  
3. Unregister a WSL distribution:  
  wsl --unregister <DistroName>
  
4. Import a WSL distribution:  
  wsl --import <DistroName> <InstallPath> <BackupPath.tar>
  
5. Run a specific WSL distribution:  
  wsl -d <DistroName>

These commands are useful for managing, migrating, or backing up WSL distributions on your Windows system.

Tags

  • Windows
  • WSL2
 

Topics

  • Form API
  • Windows
  • Drupal AI
  • Field API
  • Multilingual
  • JavaScript
  • Errors
  • professional development
  • Entity Query API
  • Mac OS
  • Drush
  • URL
  • Webform
  • Cache
  • Solar Power
  • RSA
  • Moderation
  • Coder
  • Bower
  • WSL2
  • Macbook
  • Lando
  • Permission
  • Bash Script
  • PHPSeclib
  • Articles
  • VSCode
  • Taxonomy
  • Drupal Behavior
  • Ajax API
  • Codesniffer
  • Drupal Console
  • phpcs
  • Solar Panel
  • Composer
  • Docker
  • jQuery
  • SEO
  • NPM
  • Workflow
  • Ubuntu
  • Views
  • Jellyfin
  • SSH
  • PHP
  • Android
  • Git
  • Twig
  • website
  • Neuron AI
  • MySQL
  • OOPs
  • kali
  • Commad Line Tools
  • Commad Line
  • Libraries
  • File API
  • Learning
  • Nginx
  • phpcbf
  • Drupal
  • Distribution
  • Linux
RSS Feed

Who am I !!!

Hari Venu V
harivenu.v1992@gmail.com
Mobile : +91 9895164181
Whatsapp : +91 9895164181
Linkedin
Drupal.org
Github

Document
Resume.pdf (114.38 KB)

Online Resume : Online Resume

Work !!!

Fulltime Developer @ QED42
hari.venu@qed42.com
Linkedin

Powered by Drupal & Maintained by Hari