Skip to content

Instantly share code, notes, and snippets.

@ryumada
Last active April 1, 2024 10:50
Show Gist options
  • Save ryumada/b8b7ce6ebf40736d3746e80c424c90a5 to your computer and use it in GitHub Desktop.
Save ryumada/b8b7ce6ebf40736d3746e80c424c90a5 to your computer and use it in GitHub Desktop.
Prepare your WSL's Debian for development.

Export, Import, and then Prepare your imported Debian Distribution

In this section, I want to copy the cleaned version of Debian distribution. I want to separate the development of my softwares. So, I will create one WSL distribution for one software project.

1. List your WSL Distributions

Look at the name of your distribution you want to export.

wsl -l -v

As you can see in this screenshot, we want to export the clean version of Debian distribution:

2. Export Debian distribution

You can run this command below to export the distribution.

  • Command:
wsl --export <distribution-name> <exported-file-name>.tar
  • Example:
wsl --export Debian debian-clean.tar

The example command above will place the debian-clean.tar file inside your %USERPROFILE% directory.

3. Import your exported Debian distribution

Import your exported distribution from the tar file into WSL.

  • Command:
wsl --import <new-distribution-name> <path-where-to-save-distribution> <exported-file-name>.tar
  • Example:
wsl --import debian-laravel C:\Users\kith\wsl-distributions\debian-laravel .\debian-clean.tar

4. Set default of WSL distribution to the new one

Setting the default distribution to the new one will make your new distribution easier to activate by calling the wsl command in your terminal.

  • Command:
wsl --setdefault <distribution-name>
  • Example:
wsl --setdefault debian-laravel

5. Get inside to the distribution

Type this command to get inside to your WSL terminal.

  • Command:
wsl 

6. Set your previous Debian user instead of Root and Enable system.md

Notice that debian uses root user instead your user. add this to /etc/wsl.conf

[network]
generateResolvConf = false

[boot]
systemd = true

[user]
default = ryumada

7. Restart your Debian distribution

you can terminate your Debian distribution by typing these commands

  • command
wsl --terminate your-debian-distribution
wsl -d your-debian-distribution
  • example
wsl --terminate debian-experiment
wsl -d debian-experiment

8. Install Basic packages for your Debian

Sometimes the basic command in default Debian distribution is missing its dependencies. That's why we need to reinstall this packages.

  • command
sudo apt install gnupg2 curl wget vim 

9. Install apt-fast to make the installing packages faster

See this to see the command to install in a quick way. https://github.com/ilikenwf/apt-fast#quick-install

10. Add ask-to-actions on files

This step will be useful for you to reduce mistakes. It will always ask you when you want to remove, copy, or move file.

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

source: https://serverfault.com/a/373162

11. Done

Your Debian distribution is ready to use for development. 😁👍

sources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment