Last active
December 10, 2025 20:37
-
-
Save mmitchel/18f57e434c9816ccaddf7ace709fa586 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #cloud-config | |
| ### USER DEFINED ########################################### | |
| # apt: | |
| # http_proxy: 'http://windows_user:[email protected]:8080/' | |
| ### INSTANCE SPECIFIC ###################################### | |
| locale: en_US.UTF-8 | |
| users: | |
| - name: user | |
| gecos: WSL Instance | |
| plain_text_passwd: password | |
| groups: [adm,dialout,disk,cdrom,floppy,sudo,audio,dip,video,plugdev,netdev] | |
| shell: /bin/bash | |
| homedir: /home/user | |
| sudo: ['ALL=(ALL) NOPASSWD: ALL'] | |
| write_files: | |
| # Overwrite the original | |
| - path: /etc/wsl.conf | |
| owner: 'root:root' | |
| permissions: '0644' | |
| defer: false | |
| append: false | |
| content: | | |
| [boot] | |
| systemd=true | |
| [user] | |
| default=user | |
| [automount] | |
| enabled=true | |
| mountFsTab=true | |
| options="uid=1000,gid=1000,case=off,fmask=0077,dmask=0077" | |
| [network] | |
| hostname=wsl | |
| [interop] | |
| enabled=true | |
| appendWindowsPath=true | |
| [time] | |
| useWindowsTimezone=true | |
| # Overwrite the original | |
| - path: /usr/lib/wsl/wsl-setup | |
| owner: 'root:root' | |
| permissions: '0755' | |
| defer: false | |
| append: false | |
| content: | | |
| #!/bin/bash | |
| set -euo pipefail | |
| echo "Provisioning the new WSL instance $WSL_DISTRO_NAME" | |
| echo "This might take a while..." | |
| # Wait for cloud-init to finish if systemd and its service is enabled | |
| # by running the script located at the same dir as this one. | |
| this_dir=$(dirname "$(realpath $0)") | |
| source "${this_dir}/wait-for-cloud-init" | |
| echo "Terminate this WSL instance by exiting. Upon termination, set" | |
| echo "required environment variables by executing the following:" | |
| echo " setx.exe GNUPGHOME %USERPROFILE%\.gnupg" | |
| echo " setx.exe WLSENV USERNAME:USERPROFILE/p" | |
| echo "Finally, terminate all Windows Terminal instances. Allow WSL" | |
| echo "about 60 seconds to terminate. Start a new Windows Terminal" | |
| echo "and open an Ubuntu-24.04 instance." | |
| - path: /etc/profile.d/wsl-instance.sh | |
| owner: 'root:root' | |
| permissions: '0644' | |
| content: | | |
| # WSL Instance | |
| export BB_NICE_LEVEL="5" | |
| export BB_NUMBER_THREADS="$(( $(nproc) * 50 / 100 ))" | |
| export PARALLEL_MAKE="-j$(( BB_NUMBER_THREADS * 50 / 100 ))" | |
| export BB_ENV_PASSTHROUGH_ADDITIONS="BB_NICE_LEVEL BB_NUMBER_THREADS PARALLEL_MAKE" | |
| export XDG_RUNTIME_DIR=/run/user/$(id -u) | |
| export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock | |
| if [ "$USER" != "root" ] ; then | |
| if [ -n "$USERPROFILE" ] ; then | |
| if [ -d "$USERPROFILE" ] ; then | |
| mkdir -p "$USERPROFILE/.config" && ln -sf "$USERPROFILE/.config" $HOME/.config && rm -f $HOME/.config/.config | |
| mkdir -p "$USERPROFILE/.gnupg" && ln -sf "$USERPROFILE/.gnupg" $HOME/.gnupg && rm -f $HOME/.gnupg/.gnupg | |
| mkdir -p "$USERPROFILE/.local/bin" | |
| export PATH="$USERPROFILE/.local/bin:$PATH" | |
| [[ -d $HOME/.ssh && ! -h $HOME/.ssh ]] && mv -f $HOME/.ssh $HOME/.ssh.old | |
| mkdir -p "$USERPROFILE/.ssh" && ln -sf "$USERPROFILE/.ssh" $HOME/.ssh && rm -f $HOME/.ssh/.ssh | |
| touch "$USERPROFILE/.netrc" && ln -sf "$USERPROFILE/.netrc" $HOME/.netrc | |
| touch "$USERPROFILE/.s3cfg" && ln -sf "$USERPROFILE/.s3cfg" $HOME/.s3cfg | |
| rm -fr $HOME/.config/systemd/user | |
| rm -fr $HOME/.config/systemd/user.control | |
| fi | |
| fi | |
| fi | |
| - path: /etc/sysctl.d/wsl-instance.conf | |
| owner: 'root:root' | |
| permissions: '0644' | |
| content: | | |
| fs.inotify.max_user_watches = 524288 | |
| - path: /etc/smbcredentials | |
| owner: 'root:root' | |
| permissions: '0600' | |
| content: | | |
| username=windows_user | |
| password=windows_password | |
| mounts: | |
| - [ "# M:","/mnt/m ","drvfs","defaults,nosuid,nodev,x-mount.mkdir","0","0"] | |
| - [ "# //10.236.1.99/share","/mnt/share","cifs","credentials=/etc/smbcredentials,nosuid,nodev,x-mount.mkdir","0","0" ] | |
| package_reboot_if_required: true | |
| package_update: true | |
| package_upgrade: true | |
| packages: | |
| # Development | |
| - build-essential | |
| - chrpath | |
| - cpio | |
| - debianutils | |
| - diffstat | |
| - file | |
| - gawk | |
| - gcc | |
| - git | |
| - git-lfs | |
| - iputils-ping | |
| - libacl1 | |
| - liblz4-tool | |
| - locales | |
| - python3 | |
| - python3-git | |
| - python3-jinja2 | |
| - python3-pexpect | |
| - python3-pip | |
| - python3-subunit | |
| - socat | |
| - texinfo | |
| - unzip | |
| - wget | |
| - xz-utils | |
| - zstd | |
| # General | |
| # - wslu | |
| - curl | |
| - gnupg2 | |
| - htop | |
| - jq | |
| - pciutils | |
| - usbutils | |
| - python3-paho-mqtt | |
| - python3-serial | |
| - python3-serial-asyncio | |
| - python3-paramiko | |
| - python3-venv | |
| - uidmap | |
| - libxml2-utils | |
| # Disk and Filesystem | |
| - repo | |
| - rsync | |
| - s3cmd | |
| - dosfstools | |
| - e2fsprogs | |
| - btrfs-progs | |
| - cryptsetup | |
| - ostree | |
| - cifs-utils | |
| - parted | |
| runcmd: | |
| - | | |
| mkdir -p /srv/repo | |
| chmod 1777 /srv/repo | |
| touch /root/.hushlogin | |
| - | | |
| rsync -av /etc/skel/ /home/user/ | |
| touch /home/user/.hushlogin | |
| chown -R user:user /home/user | |
| - | | |
| shutdown --poweroff now |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
WSL Ubuntu-24.04
Configuration for All Instances running on WSL
Windows Preparation
Execute (CMD.EXE)
setx.exe GNUPGHOME %USERPROFILE%\.gnupgExecute (CMD.EXE)
Execute (CMD.EXE)
Execute (CMD.EXE)
Terminate all instances of Windows Terminal
Configuration for Ubuntu 24.04 LTS running on WSL
Install Ubuntu-24.04.user-data at %USERPROFILE%.cloud-init\Ubuntu-24.04.user-data
Execute (CMD.EXE)
Execute (CMD.EXE)
Execute (CMD.EXE)
until Ubunu-24.04 is not shown
Terminate all instances of Windows Terminal
Wait ~60 seconds
Start new instances of Windows Terminal CLI prompts
Interop with USB Mass Storage
Insure WSL Instance Ubuntu-24.04 is running
Install from https://github.com/dorssel/usbipd-win, v5.x
Insert USB flash disk
Execute Elevated Privileges (CMD.EXE)
usbipd.exe list usbipd.exe unbind --all usbipd.exe bind --force --busid BUSID usbipd.exe attach --wsl --busid BUSIDExecute Elevated Privileges (CMD.EXE)