├── .github ├── ISSUE_TEMPLATE │ ├── Bug_Report.yaml │ └── config.yml └── workflows │ └── stale-issues.yml ├── LICENSE ├── Makefile ├── README.md ├── archlinux.ico ├── bash_profile ├── setcap-iputils.hook ├── wsl-distribution.conf ├── wsl.conf └── wslg-init.service /.github/ISSUE_TEMPLATE/Bug_Report.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: "ArchWSL2 - Bug Report" 3 | description: Report a bug on ArchWSL2 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | Please [search for existing issues](https://github.com/sileshn/ArchWSL2/issues) before creating a new one. 9 | 10 | - type: checkboxes 11 | attributes: 12 | label: Requirements 13 | description: | 14 | Tell us whether you have checked and completed the [prerequisite](https://github.com/sileshn/ArchWSL2#requirements) 15 | options: 16 | - label: "Yes" 17 | - label: "No" 18 | 19 | - type: checkboxes 20 | attributes: 21 | label: CPU Architecture 22 | description: | 23 | Tell us whether you are running the x64 or the arm64 version. 24 | options: 25 | - label: "arm64" 26 | - label: "x64" 27 | 28 | - type: checkboxes 29 | attributes: 30 | label: WSL Version 31 | description: | 32 | Tell us whether you are running WSL 2 and/or WSL 1. You can tell your WSL version by running `wsl -l -v`. ArchWSL2 needs wsl2 to work. 33 | options: 34 | - label: "WSL 2" 35 | - label: "WSL 1" 36 | 37 | - type: input 38 | attributes: 39 | label: Version 40 | description: | 41 | Please run `cmd.exe /c ver` to get the build of Windows you are on. 42 | If you are running Windows Subsystem for Linux from the Microsoft Store, please run `wsl.exe --version` 43 | placeholder: "Microsoft Windows [Version 10.0.19042.867]" 44 | validations: 45 | required: true 46 | 47 | - type: input 48 | attributes: 49 | label: Kernel Version 50 | description: | 51 | Please tell us what version of the Linux kernel you are using, or if you are using a custom kernel. 52 | You can run `wsl.exe --status` if that command is available to you, or by running `cat /proc/version` in your distro. 53 | placeholder: "5.4.72" 54 | validations: 55 | required: false 56 | 57 | - type: textarea 58 | attributes: 59 | label: Repro Steps 60 | description: Please list out the steps to reproduce your bug. 61 | placeholder: Your steps go here. Include relevant environmental variables or any other configuration. 62 | validations: 63 | required: true 64 | 65 | - type: textarea 66 | attributes: 67 | label: Expected Behavior 68 | description: What were you expecting to see? Include any relevant examples or documentation links. 69 | placeholder: If you want to include screenshots, paste them into the text area or follow up with a separate comment. 70 | validations: 71 | required: true 72 | 73 | - type: textarea 74 | attributes: 75 | label: Actual Behavior 76 | description: What happened instead? 77 | placeholder: Include the terminal output, straces of the failing command, etc. as necessary. 78 | validations: 79 | required: true -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | -------------------------------------------------------------------------------- /.github/workflows/stale-issues.yml: -------------------------------------------------------------------------------- 1 | name: Close inactive issues 2 | on: 3 | schedule: 4 | - cron: "30 1 * * *" 5 | 6 | jobs: 7 | close-issues: 8 | runs-on: ubuntu-latest 9 | permissions: 10 | issues: write 11 | pull-requests: write 12 | steps: 13 | - uses: actions/stale@v4 14 | with: 15 | days-before-issue-stale: 7 16 | days-before-issue-close: 7 17 | stale-issue-label: "stale" 18 | stale-issue-message: "This issue is stale because it has been open for 7 days with no activity." 19 | close-issue-message: "This issue was closed because it has been inactive for 14 days with no activity." 20 | days-before-pr-stale: -1 21 | days-before-pr-close: -1 22 | repo-token: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017-2019 yuk7, 2019-2021 Silesh K Nair 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | OUT_ZIP=ArchWSL2.zip 2 | LNCR_EXE=Arch.exe 3 | 4 | DLR=curl 5 | DLR_FLAGS=-L 6 | LNCR_ZIP_URL=https://github.com/yuk7/wsldl/releases/download/`curl https://api.github.com/repos/yuk7/wsldl/releases/latest -s | jq .name -r`/icons.zip 7 | LNCR_ZIP_EXE=Arch.exe 8 | 9 | all: $(OUT_ZIP) 10 | 11 | zip: $(OUT_ZIP) 12 | $(OUT_ZIP): ziproot 13 | @echo -e '\e[1;31mBuilding $(OUT_ZIP)\e[m' 14 | cd ziproot; bsdtar -a -cf ../$(OUT_ZIP) * 15 | 16 | ziproot: Launcher.exe rootfs.tar.gz 17 | @echo -e '\e[1;31mBuilding ziproot...\e[m' 18 | mkdir ziproot 19 | cp Launcher.exe ziproot/${LNCR_EXE} 20 | cp rootfs.tar.gz ziproot/ 21 | 22 | exe: Launcher.exe 23 | Launcher.exe: icons.zip 24 | @echo -e '\e[1;31mExtracting Launcher.exe...\e[m' 25 | unzip icons.zip $(LNCR_ZIP_EXE) 26 | mv $(LNCR_ZIP_EXE) Launcher.exe 27 | 28 | icons.zip: 29 | @echo -e '\e[1;31mDownloading icons.zip...\e[m' 30 | $(DLR) $(DLR_FLAGS) $(LNCR_ZIP_URL) -o icons.zip 31 | 32 | rootfs.tar.gz: rootfs 33 | @echo -e '\e[1;31mBuilding rootfs.tar.gz...\e[m' 34 | cd rootfs; sudo bsdtar -zcpf ../rootfs.tar.gz `sudo ls` 35 | sudo chown `id -un` rootfs.tar.gz 36 | 37 | rootfs: base.tar 38 | @echo -e '\e[1;31mBuilding rootfs...\e[m' 39 | mkdir rootfs 40 | sudo bsdtar -zxpf base.tar -C rootfs 41 | @echo "# This file was automatically generated by WSL. To stop automatic generation of this file, remove this line." | sudo tee rootfs/etc/resolv.conf > /dev/null 42 | sudo cp wsl.conf rootfs/etc/wsl.conf 43 | sudo cp wsl-distribution.conf rootfs/etc/wsl-distribution.conf 44 | sudo cp archlinux.ico rootfs/usr/lib/wsl/archlinux.ico 45 | sudo cp -f setcap-iputils.hook rootfs/etc/pacman.d/hooks/50-setcap-iputils.hook 46 | sudo cp bash_profile rootfs/root/.bash_profile 47 | sudo cp wslg-init.service rootfs/usr/lib/systemd/system/wslg-init.service 48 | sudo chmod +x rootfs 49 | 50 | base.tar: 51 | @echo -e '\e[1;31mExporting base.tar using docker...\e[m' 52 | docker run --net=host --ulimit nofile=1024:10240 --name archwsl archlinux:base-devel /bin/bash -c "pacman-key --init; pacman-key --populate; sed -ibak -e 's/#Color/Color/g' -e 's/CheckSpace/#CheckSpace/g' /etc/pacman.conf; sed -ibak -e 's/IgnorePkg/#IgnorePkg/g' /etc/pacman.conf; echo | tee -a /etc/pacman.conf >/dev/null 2>&1; echo '#[multilib]' | tee -a /etc/pacman.conf >/dev/null 2>&1 && echo '#Include = /etc/pacman.d/mirrorlist' | tee -a /etc/pacman.conf >/dev/null 2>&1; sed -i '/usr\/share\/man/d' /etc/pacman.conf; pacman --noconfirm -Syyu; pacman --noconfirm --needed -Sy aria2 aspell autoconf-archive bc ccache dconf dbus dnsutils docbook-xsl dos2unix doxygen figlet git grep hspell hunspell inetutils iputils iproute2 keychain libva-mesa-driver libva-utils libvoikko libxcrypt-compat linux-tools lolcat man-db man-pages mesa-vdpau nano ntp nuspell openssh procps socat sudo usbutils vi vim wget xdg-utils xmlto yelp-tools; wget https://pkg.wslutiliti.es/public.key && pacman-key --add public.key && rm ./public.key && pacman-key --lsign-key 2D4C887EB08424F157151C493DD50AA7E055D853; echo '[wslutilities]' | sudo tee -a /etc/pacman.conf >/dev/null 2>&1; echo 'Server = https://pkg.wslutiliti.es/arch/' | sudo tee -a /etc/pacman.conf >/dev/null 2>&1; pacman -Sy wslu; mkdir -p /etc/pacman.d/hooks; echo '%wheel ALL=(ALL) ALL' > /etc/sudoers.d/wheel; useradd -m -g users -G wheel builduser; passwd -d builduser; git clone https://aur.archlinux.org/yay-bin.git /home/builduser/yay-bin && git clone https://aur.archlinux.org/rate-mirrors.git /home/builduser/rate-mirrors; sudo chown -R builduser /home/builduser/yay-bin /home/builduser/rate-mirrors; cd /home/builduser/yay-bin && sudo -u builduser makepkg -si --noconfirm; cd /home/builduser/rate-mirrors && sudo -u builduser makepkg -si --noconfirm; cd && userdel -r builduser; sed -i 's/#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen && locale-gen; systemd-machine-id-setup; rm /var/lib/dbus/machine-id; dbus-uuidgen --ensure=/etc/machine-id; dbus-uuidgen --ensure; yes | LC_ALL=en_US.UTF-8 pacman -Scc; mkdir -p /usr/lib/wsl" 53 | docker export --output=base.tar archwsl 54 | docker rm -f archwsl 55 | 56 | clean: 57 | @echo -e '\e[1;31mCleaning files...\e[m' 58 | -rm ${OUT_ZIP} 59 | -rm -r ziproot 60 | -rm Launcher.exe 61 | -rm icons.zip 62 | -rm rootfs.tar.gz 63 | -sudo rm -r rootfs 64 | -rm base.tar 65 | -docker rmi archlinux:base-devel -f 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ArchWSL2 2 | Archlinux on WSL2 (Windows 10 FCU or later) based on [wsldl](https://github.com/yuk7/wsldl). 3 | 4 | [![Screenshot-2022-07-26-064739.png](https://i.postimg.cc/wBzRfFbg/Screenshot-2022-07-26-064739.png)](https://postimg.cc/sMn21PrN) 5 | [![Github All Releases](https://img.shields.io/github/downloads/sileshn/ArchWSL2/total?logo=github&style=flat-square)](https://github.com/sileshn/ArchWSL2/releases) [![GitHub release (latest by date)](https://img.shields.io/github/v/release/sileshn/ArchWSL2?display_name=release&label=latest%20release&style=flat-square)](https://github.com/sileshn/ArchWSL2/releases/latest) 6 | [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![License](https://img.shields.io/github/license/sileshn/ArchWSL2.svg?style=flat-square)](https://github.com/sileshn/ArchWSL2/blob/main/LICENSE) 7 | 8 | ## Features and important information 9 | ArchWSL2 may not properly load the Intel WSL driver by default which makes it impossible to use the D3D12 driver on Intel graphics cards. This is because the Intel WSL driver files link against libraries that do not exist in Archlinux. You can manually fix this issue using `ldd` to see which libraries they are linked, eg: `ldd /usr/lib/wsl/drivers/iigd_dch_d.inf_amd64_49b17bc90a910771/*.so`, and then try installing the libraries marked `not found` from the Archlinux package repository. If the corresponding library file is not found in the package repository, it may be that the version suffix of the library file is different, such as `libedit.so.0.0.68` and `libedit.so.2`. In such a case, you can try to create a symlink. 10 | 11 | ArchWSL2 has the following features during the installation stage. 12 | * Increase virtual disk size from the default 256GB 13 | * Create a new user and set the user as default 14 | * ArchWSL2 Supports systemd natively if you are running wsl v0.67.6 (more details here) and above. For earlier versions of wsl, systemd is supported using diddledani's one-script-wsl2-systemd. This is done automatically during initial setup. 15 | * ArchWSL2 includes a wsl.conf file which only has [section headers](https://i.postimg.cc/MZ4DC1Fw/Screenshot-2022-02-02-071533.png). Users can use this file to configure the distro to their liking. You can read more about wsl.conf and its configuration settings [here](https://docs.microsoft.com/en-us/windows/wsl/wsl-config). 16 | 17 | ## Requirements 18 | * For x64 systems: Version 1903 or higher, with Build 18362 or higher. 19 | * For ARM64 systems: Version 2004 or higher, with Build 19041 or higher. 20 | * Builds lower than 18362 do not support WSL 2. 21 | * If you are running Windows 10 version 2004 or higher, you can install all components required to run wsl2 with a single command. This will install ubuntu by default. More details are available [here](https://devblogs.microsoft.com/commandline/install-wsl-with-a-single-command-now-available-in-windows-10-version-2004-and-higher/). 22 | ```cmd 23 | wsl.exe --install 24 | ``` 25 | * If you are running Windows 10 lower then version 2004, follow the steps below. For more details, check [this](https://docs.microsoft.com/en-us/windows/wsl/install-manual) microsoft document. 26 | * Enable Windows Subsystem for Linux feature. 27 | ```cmd 28 | dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart 29 | ``` 30 | * Enable Virtual Machine feature 31 | ```cmd 32 | dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart 33 | ``` 34 | * Download and install the latest Linux kernel update package from [here](https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi). 35 | 36 | ## How to install 37 | * Make sure all the steps mentioned under "Requirements" are completed. 38 | * [Download](https://github.com/sileshn/ArchWSL2/releases/latest) installer zip 39 | * Extract all files in zip file to same directory 40 | * Set version 2 as default. Note that this step is required only for manual installation. 41 | ```dos 42 | wsl --set-default-version 2 43 | ``` 44 | * Run Arch.exe to extract rootfs and register to WSL 45 | 46 | **Note:** 47 | Exe filename is using the instance name to register. If you rename it you can register with a diffrent name and have multiple installs. 48 | 49 | ## How to setup 50 | ArchWSL2 will ask you to create a new user during its first run. If you choose to create a new user during the first run, the steps below are not required unless you want to create additional users. 51 | 52 | Open Arch.exe and run the following commands. 53 | ```dos 54 | passwd 55 | useradd -m -g users -G wheel -s /bin/bash 56 | echo "%wheel ALL=(ALL) ALL" >/etc/sudoers.d/wheel 57 | passwd 58 | exit 59 | ``` 60 | 61 | You can set the user you created as default user using 2 methods. 62 | 63 | Open Arch.exe, run the following command (replace username with the actual username you created). 64 | ```dos 65 | sed -i '/\[user\]/a default = username' /etc/wsl.conf 66 | ``` 67 | 68 | Shutdown and restart the distro (this step is important). 69 | 70 | (or) 71 | 72 | Execute the command below in a windows cmd terminal from the directory where Arch.exe is installed. 73 | ```dos 74 | >Arch.exe config --default-user 75 | ``` 76 | 77 | ## How to use installed instance 78 | #### exe Usage 79 | ``` 80 | Usage : 81 | 82 | - Open a new shell with your default settings. 83 | Inherit current directory (with exception that %%USERPROFILE%% is changed to $HOME). 84 | 85 | run 86 | - Run the given command line in that instance. Inherit current directory. 87 | 88 | runp 89 | - Run the given command line in that instance after converting its path. 90 | 91 | config [setting [value]] 92 | - `--default-user `: Set the default user of this instance to . 93 | - `--default-uid `: Set the default user uid of this instance to . 94 | - `--append-path `: Switch of Append Windows PATH to $PATH 95 | - `--mount-drive `: Switch of Mount drives 96 | - `--wsl-version <1|2>`: Set the WSL version of this instance to <1 or 2> 97 | - `--default-term `: Set default type of terminal window. 98 | 99 | get [setting [value]] 100 | - `--default-uid`: Get the default user uid in this instance. 101 | - `--append-path`: Get true/false status of Append Windows PATH to $PATH. 102 | - `--mount-drive`: Get true/false status of Mount drives. 103 | - `--wsl-version`: Get the version os the WSL (1/2) of this instance. 104 | - `--default-term`: Get Default Terminal type of this instance launcher. 105 | - `--wt-profile-name`: Get Profile Name from Windows Terminal 106 | - `--lxguid`: Get WSL GUID key for this instance. 107 | 108 | backup [file name] 109 | - `*.tar`: Output backup tar file. 110 | - `*.tar.gz`: Output backup tar.gz file. 111 | - `*.ext4.vhdx`: Output backup ext4.vhdx file. (WSL2 only) 112 | - `*.ext4.vhdx.gz`: Output backup ext4.vhdx.gz file. (WSL2 only) 113 | - `*.reg`: Output settings registry file. 114 | 115 | clean 116 | - Uninstall that instance. 117 | 118 | help 119 | - Print this usage message. 120 | ``` 121 | 122 | #### Run exe 123 | ```cmd 124 | >Arch.exe 125 | [root@PC-NAME user]# 126 | ``` 127 | 128 | #### Run with command line 129 | ```cmd 130 | >Arch.exe run uname -r 131 | 4.4.0-43-Microsoft 132 | ``` 133 | 134 | #### Run with command line using path translation 135 | ```cmd 136 | >Arch.exe runp echo C:\Windows\System32\cmd.exe 137 | /mnt/c/Windows/System32/cmd.exe 138 | ``` 139 | 140 | #### Change default user(id command required) 141 | ```cmd 142 | >Arch.exe config --default-user user 143 | 144 | >Arch.exe 145 | [user@PC-NAME dir]$ 146 | ``` 147 | 148 | #### Set "Windows Terminal" as default terminal 149 | ```cmd 150 | >Arch.exe config --default-term wt 151 | ``` 152 | 153 | ## How to update 154 | Updating Archlinux doesn't require you to download and install a newer release everytime. Usually all it takes is to run the command below to update the instance. 155 | ```dos 156 | $sudo pacman -Syu 157 | ``` 158 | 159 | Sometimes updates may fail to install. You can try the command below in such a situation. 160 | ```dos 161 | $sudo pacman -Syyuu 162 | ``` 163 | 164 | You may need to install a newer release if additional features have been added/removed from the installer. 165 | 166 | ## How to uninstall instance 167 | ```dos 168 | >Arch.exe clean 169 | 170 | ``` 171 | 172 | ## How to backup instance 173 | export to backup.tar.gz (WSL1 or 2) 174 | ```cmd 175 | >Arch.exe backup backup.tar.gz 176 | ``` 177 | export to backup.ext4.vhdx.gz (WSL2 only) 178 | ```cmd 179 | >Arch.exe backup backup.ext4.vhdx.gz 180 | ``` 181 | 182 | ## How to restore instance 183 | 184 | There are 2 ways to do it. 185 | 186 | Rename the backup to rootfs.tar.gz and run Arch.exe 187 | 188 | (or) 189 | 190 | .tar(.gz) 191 | ```cmd 192 | >Arch.exe install backup.tar.gz 193 | ``` 194 | .ext4.vhdx(.gz) 195 | ```cmd 196 | >Arch.exe install backup.ext4.vhdx.gz 197 | ``` 198 | 199 | You may need to run the command below in some circumstances. 200 | ```cmd 201 | >Arch.exe --default-uid 1000 202 | ``` 203 | 204 | ## How to build from source 205 | #### prerequisites 206 | Docker, tar, zip, unzip, bsdtar need to be installed. 207 | 208 | ```dos 209 | git clone git@gitlab.com:sileshn/ArchWSL2.git 210 | cd ArchWSL2 211 | make 212 | ``` 213 | Copy the ArchWSL2.zip file to a safe location and run the command below to clean. 214 | ```dos 215 | make clean 216 | ``` 217 | 218 | ## How to run docker in ArchWSL2 without using docker desktop 219 | Install docker. 220 | ```dos 221 | sudo pacman -S docker 222 | ``` 223 | 224 | Follow [this](https://blog.nillsf.com/index.php/2020/06/29/how-to-automatically-start-the-docker-daemon-on-wsl2/) blog post for further details on how to setup. Alternatively, if using systemd, use the commands below to setup and reboot. 225 | ```dos 226 | sudo systemctl start docker.service 227 | sudo systemctl enable docker.service 228 | sudo usermod -aG docker $USER 229 | ``` 230 | Screenshot-2022-05-09-232847 231 | -------------------------------------------------------------------------------- /archlinux.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sileshn/ArchWSL2/8e618e0b3745429390208e001dfc975b1fd2011a/archlinux.ico -------------------------------------------------------------------------------- /bash_profile: -------------------------------------------------------------------------------- 1 | # First run script for ArchWSL. 2 | 3 | blu=$(tput setaf 4) 4 | cyn=$(tput setaf 6) 5 | grn=$(tput setaf 2) 6 | mgn=$(tput setaf 5) 7 | red=$(tput setaf 1) 8 | ylw=$(tput setaf 3) 9 | txtrst=$(tput sgr0) 10 | 11 | test -e /mnt/c/Users/Public/shutdown.cmd && rm /mnt/c/Users/Public/shutdown.cmd 12 | test -e ~/shutdown.cmd && rm ~/shutdown.cmd 13 | figlet -t -k -f /usr/share/figlet/fonts/mini.flf "Welcome to ArchWSL2" | lolcat 14 | echo -e "\033[33;7mDo not interrupt or close the terminal window till script finishes execution!!!\n\033[0m" 15 | 16 | echo -e ${grn}"Initializing and populating keyring..."${txtrst} 17 | pacman-key --init >/dev/null 2>&1 18 | pacman-key --populate >/dev/null 2>&1 19 | pacman -Sy archlinux-keyring --noconfirm >/dev/null 2>&1 20 | setcap cap_net_raw+p /usr/sbin/ping 21 | sed -i '/PS1/d' /etc/skel/.bashrc 22 | echo "PS1='\[\033[01;32m\][\u@\h\[\033[01;37m\] \W\[\033[01;32m\]]\$\[\033[00m\] '" | tee -a /etc/skel/.bashrc >/dev/null 2>&1 23 | echo 'export BROWSER="wslview"' | tee -a /etc/skel/.bashrc >/dev/null 2>&1 24 | sudo systemctl daemon-reload 25 | sudo systemctl enable wslg-init.service >/dev/null 2>&1 26 | 27 | echo -e ${grn}"Do you want to create a new user?"${txtrst} 28 | select yn in "Yes" "No"; do 29 | case $yn in 30 | Yes) 31 | echo " " 32 | while read -p "Please enter the username you wish to create : " username; do 33 | if [ "x$username" = "x" ]; then 34 | echo -e ${red}" Blank username entered. Try again!!!"${txtrst} 35 | echo -en "\033[1A\033[1A\033[2K" 36 | username="" 37 | elif grep -q "^$username" /etc/passwd; then 38 | echo -e ${red}"Username already exists. Try again!!!"${txtrst} 39 | echo -en "\033[1A\033[1A\033[2K" 40 | username="" 41 | else 42 | useradd -m -g users -G wheel -s /bin/bash "$username" 43 | echo -en "\033[1B\033[1A\033[2K" 44 | passwd $username 45 | sed -i "/\[user\]/a default = $username" /etc/wsl.conf >/dev/null 46 | echo "@echo off" | sudo tee -a ~/shutdown.cmd >/dev/null 2>&1 47 | echo "wsl.exe --terminate $WSL_DISTRO_NAME" | sudo tee -a ~/shutdown.cmd >/dev/null 2>&1 48 | if env | grep "WT_SESSION" >/dev/null 2>&1; then 49 | echo "wt.exe -w 0 nt wsl.exe -d $WSL_DISTRO_NAME" | sudo tee -a ~/shutdown.cmd >/dev/null 2>&1 50 | else 51 | echo "cmd /c start \"$WSL_DISTRO_NAME\" wsl.exe --cd ~ -d $WSL_DISTRO_NAME" | sudo tee -a ~/shutdown.cmd >/dev/null 2>&1 52 | fi 53 | echo "del C:\Users\Public\shutdown.cmd" | sudo tee -a ~/shutdown.cmd >/dev/null 2>&1 54 | cp ~/shutdown.cmd /mnt/c/Users/Public && rm ~/shutdown.cmd 55 | 56 | secs=3 57 | printf ${ylw}"\nTo set the new user as the default user, ArchWSL2 will shutdown and restart!!!\n\n"${txtrst} 58 | while [ $secs -gt 0 ]; do 59 | printf "\r\033[KShutting down in %.d seconds. " $((secs--)) 60 | sleep 1 61 | done 62 | 63 | rm ~/.bash_profile 64 | powershell.exe -command "Start-Process -Verb Open -FilePath 'shutdown.cmd' -WorkingDirectory 'C:\Users\Public' -WindowStyle Hidden" 65 | exec sleep 0 66 | fi 67 | done 68 | ;; 69 | No) 70 | break 71 | ;; 72 | esac 73 | done 74 | 75 | echo "@echo off" | sudo tee -a ~/shutdown.cmd >/dev/null 2>&1 76 | echo "wsl.exe --terminate $WSL_DISTRO_NAME" | sudo tee -a ~/shutdown.cmd >/dev/null 2>&1 77 | if env | grep "WT_SESSION" >/dev/null 2>&1; then 78 | echo "wt.exe -w 0 nt wsl.exe -d $WSL_DISTRO_NAME" | sudo tee -a ~/shutdown.cmd >/dev/null 2>&1 79 | else 80 | echo "cmd /c start \"$WSL_DISTRO_NAME\" wsl.exe --cd ~ -d $WSL_DISTRO_NAME" | sudo tee -a ~/shutdown.cmd >/dev/null 2>&1 81 | fi 82 | echo "del C:\Users\Public\shutdown.cmd" | sudo tee -a ~/shutdown.cmd >/dev/null 2>&1 83 | cp ~/shutdown.cmd /mnt/c/Users/Public && rm ~/shutdown.cmd 84 | 85 | secs=3 86 | printf ${ylw}"\nArchWSL2 will shutdown and restart to finish setup!!!\n\n"${txtrst} 87 | while [ $secs -gt 0 ]; do 88 | printf "\r\033[KShutting down in %.d seconds. " $((secs--)) 89 | sleep 1 90 | done 91 | 92 | rm ~/.bash_profile 93 | powershell.exe -command "Start-Process -Verb Open -FilePath 'shutdown.cmd' -WorkingDirectory 'C:\Users\Public' -WindowStyle Hidden" 94 | exec sleep 0 95 | -------------------------------------------------------------------------------- /setcap-iputils.hook: -------------------------------------------------------------------------------- 1 | [Trigger] 2 | Type = Path 3 | Operation = Install 4 | Operation = Upgrade 5 | Target = usr/sbin/ping 6 | 7 | [Action] 8 | Description = Adding capabilities to ping to allow non-root user to ping... 9 | When = PostTransaction 10 | Exec = /usr/sbin/setcap cap_net_raw+p /usr/sbin/ping 11 | -------------------------------------------------------------------------------- /wsl-distribution.conf: -------------------------------------------------------------------------------- 1 | [shortcut] 2 | icon = /usr/lib/wsl/archlinux.ico 3 | -------------------------------------------------------------------------------- /wsl.conf: -------------------------------------------------------------------------------- 1 | [automount] 2 | 3 | [network] 4 | 5 | [interop] 6 | 7 | [user] 8 | 9 | #The Boot setting is only available on Windows 11 10 | [boot] 11 | systemd=true 12 | -------------------------------------------------------------------------------- /wslg-init.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=symlink /tmp/.X11-unix 3 | After=systemd-tmpfiles-setup.service 4 | 5 | [Service] 6 | Type=oneshot 7 | ExecStart=rmdir /tmp/.X11-unix 8 | ExecStart=ln -s /mnt/wslg/.X11-unix /tmp/ 9 | 10 | [Install] 11 | WantedBy=sysinit.target 12 | --------------------------------------------------------------------------------