WSL custom distribution import¶
WSL custom distribution import refers to the process of manually creating a new WSL instance from a tarball archive. This allows users to deploy specific Linux environments or duplicate existing configurations to a new location on their system.^[600-developer__tools__windows__wsl-command.md]
Import Command¶
To create a custom distribution, the wsl --import command is used. This command requires specifying the distribution name, the target installation path, and the source of the tar file.^[600-developer__tools__windows__wsl-command.md]
Syntax Example:
wsl --import <DistributionName> <InstallLocation> <TarFileName>
Example usage:
wsl --import U20.04-tommy D:\install\wsl-work\storage\Ubuntu-20.04-tommy D:\install\wsl-work\image\Ubuntu-20.04-20220121.tar
Post-Import Configuration¶
After importing a distribution, immediate configuration steps are often necessary to set up user accounts and privileges.
Terminating the Instance¶
To apply configuration changes or safely modify the instance, it may be necessary to stop the WSL service for that specific distribution.^[600-developer__tools__windows__wsl-command.md]
wsl --terminate U20.04-tommy
Setting Root and User Passwords¶
Configuration typically starts by accessing the instance as the root user to set passwords and create a default user.^[600-developer__tools__windows__wsl-command.md]
-
Login as root:
[600-developer__tools__windows__wsl-command.md]wsl -d U20.04-tommy -u root -
Configure root password and default user: Once inside the shell, update the root password and define a default user in
/etc/wsl.conf.^[600-developer__tools__windows__wsl-command.md][600-developer__tools__windows__wsl-command.md]passwd root $myUsername=tommy echo -e "[user]\ndefault=$myUsername" >> /etc/wsl.conf passwd $myUsername
Note: On some distributions, you may need to install necessary utilities first:
yum update -y && yum install passwd sudo -y
Related Concepts¶
- [[WSL]]
- [[WSL export]]
- [[WSL unregister]]
Sources¶
600-developer__tools__windows__wsl-command.md