WSL instance lifecycle management¶
WSL instance lifecycle management refers to the administrative tasks involved in creating, configuring, and removing WSL (Windows Subsystem for Linux) distributions.
Importing instances¶
New instances can be created by importing a tar archive. This requires specifying the distribution name, the installation path for storage, and the source location of the image file.^[600-developer__tools__windows__wsl-command.md]
wsl --import <DistroName> <InstallLocation> <FileName>
User configuration¶
After importing a base image, the instance typically requires configuration to define the default user and set access credentials.^[600-developer__tools__windows__wsl-command.md]
You can launch a specific distribution as the root user to perform initial system setup, such as changing the root password or creating a new user.^[600-developer__tools__windows__wsl-command.md]
wsl -d <DistroName> -u root
To ensure the system boots into a specific non-root user automatically, the wsl.conf file must be edited to append the default user configuration.^[600-developer__tools__windows__wsl-command.md]
echo -e "[user]\ndefault=$myUsername" >> /etc/wsl.conf
Maintenance¶
Termination¶
Instances can be stopped manually if they need to be restarted or to release system resources.^[600-developer__tools__windows__wsl-command.md]
wsl --terminate <DistroName>
Listing and verification¶
To verify the state of installed distributions or to view their names (required for other management commands), you can list all distributions with their verbose details.^[600-developer__tools__windows__wsl-command.md]
wsl --list --verbose
Removal¶
To permanently delete a WSL instance from the machine, the instance must be unregistered.^[600-developer__tools__windows__wsl-command.md] Before removal, you may wish to export the instance to a tar archive to preserve the data.^[600-developer__tools__windows__wsl-command.md]
wsl --unregister <DistroName>
Sources¶
^[600-developer__tools__windows__wsl-command.md]
Related¶
- [[Windows]]
- [[Linux]]
- [[Virtualization]]