Last active
February 9, 2023 22:57
-
-
Save zahna/59fb516285d9295025463d4c96720950 to your computer and use it in GitHub Desktop.
WSL2 distro stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Related Links: | |
https://docs.microsoft.com/en-us/windows/wsl/use-custom-distro | |
http://cloud-images.ubuntu.com/wsl/ | |
https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/x86_64/ | |
https://cloudlinuxtech.com/install-linux-on-windows-10-wsl/ | |
https://docs.microsoft.com/en-us/windows/wsl/install-manual#downloading-distributions | |
To install WSL2: | |
https://docs.microsoft.com/en-us/windows/wsl/install-win10 | |
To import a distro: | |
* Make a directory "wsl2" in your Windows home directory | |
* Download a Linux WSL root filesystem tar.gz file | |
* Copy it to your WSL2 directory | |
* Make a directory under WSL2 for your distro (ex. c:\Users\<user>\wsl2\Ubuntu-22.04) | |
* Import the tar.gz file into WSL2 using "wsl --import" | |
example: | |
> New-Item -ItemType directory C:\Users\<username>\wsl2\alpine-<date>\ (or specify alternate path) | |
> cd C:\Users\<username>\wsl2\alpine-<date>\ | |
> iwr https://dl-cdn.alpinelinux.org/alpine/v3.15/releases/x86_64/alpine-minirootfs-<version>-x86_64.tar.gz -OutFile alpine-minirootfs-<version>-x86_64.tar.gz | |
> wsl --import Alpine-<date> C:\Users\<user>\wsl2\alpine-<date>\ C:\Users\<user>\wsl2\alpine-3.15\alpine-minirootfs-<version>-x86_64.tar.gz | |
> wsl -d Alpine-<date> | |
After importing, configure the new distro. | |
Alpine: | |
> apk add sudo bash vim openssh-client | |
> addgroup -g 1000 <user> | |
> adduser -S -u 1000 -G <user> -s /bin/bash <user> | |
> adduser <user> wheel | |
> update /etc/sudoers | |
Ubuntu: | |
> groupadd -g 1000 <user> | |
> useradd -r -m -u 1000 -g 1000 -s /bin/bash <user> | |
> visudo (add your user to sudoers file) | |
> exit | |
> wsl -d <distro> -u <user> | |
Notes: | |
Specifying a date with the distro allows for more flexability when having multiple distros or performing distro re-installs. | |
migrating files from one wsl2 distro to another: | |
* sending side: tar cvpf - /full/path | nc -w 3 localhost 1234 | |
* recving side: nc -l -p 1234 | tar xhpf - -C / | |
Export distro: | |
> wsl -l -v | |
> wsl -t <distro_name> | |
> wsl --export <distro_name> <destination> | |
Import distro: | |
> wsl --import wsl --import <distro_name> <destination> <tar_file> | |
Remove distro: | |
> wsl --unregister <distro_name> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment