Features:
Update your Windows (min 2 Apr 2023, required for importing from .xz
)
Activate WSL if not have been activated yet
Download the latest Clear Linux server rootfs tarball (main purpose of this repo is maintaing of this tarball):
https://github.com/gh0st-work/clear-linux-wsl/releases/latest/download/clear_linux_rootfs.tar.xz
Start a new Powershell session:
<WIN + r>
powershell
<ENTER>
Or just run Powershell from Windows Start Menu
Create sources directory:
mkdir /wsl_distros/sources
Copy (or move) the clear_linux_rootfs.tar.xz
to the /wsl_distros/sources/
directory:
cp -v $HOME/Downloads/clear_linux_rootfs.tar.xz /wsl_distros/sources/
Update WSL (min 2 Apr 2023, required for importing from .xz
):
wsl.exe --update
Register Clear Linux as a new WSL2 distro:
wsl.exe --import ClearLinux /wsl_distros/ClearLinux /wsl_distros/sources/clear_linux_rootfs.tar.xz --version 2
Ensure the distro has been imported correctly:
wsl.exe --list --verbose
Create on your desktop shortcut with path:
%windir%\system32\cmd.exe /k cd %userprofile% && wsl.exe -d ClearLinux --cd ~
and name
ClearLinux
Recomended:
https://raw.githubusercontent.com/gh0st-work/clear-linux-wsl/main/clear_linux_logo.ico
Run it
Update the system:
swupd update
Create a new user (change USERNAME
to your username):
useradd -m -s /bin/bash USERNAME
passwd USERNAME
Add basic bundles:
swupd bundle-add sysadmin-basic sudo
Add user to sudoers (change USERNAME
to your username):
usermod -aG wheel USERNAME
Write default wsl.conf
config:
cat >> /etc/wsl.conf << 'EOF'
[automount]
enabled = true
options = "metadata,uid=1000,gid=1000,umask=22,fmask=11,case=off"
mountFsTab = true
crossDistro = true
[network]
generateHosts = true
generateResolvConf = true
[interop]
enabled = true
appendWindowsPath = true
[user]
default = USERNAME
Don't forget to change USERNAME
to your username, and then exit writing with EOF
at a new line:
EOF
Shutdown WSL machine with:
exit
wsl.exe -d ClearLinux --shutdown
exit
Edit your shortcut path (in Properties) adding -u USERNAME
(change USERNAME
to your username) before --cd ~
:
%windir%\system32\cmd.exe /k cd %userprofile% && wsl.exe -d ClearLinux -u USERNAME --cd ~
Run it
And here you are, logged as your user without any errors
Recommended:
Happy hacking :)
And don't forget to star the repo pls!
For more experienced users: you can use get_latest_rootfs.sh
script to get official images yourself, if you assume this repo GitHub releases can be compromised
wget https://raw.githubusercontent.com/gh0st-work/clear-linux-wsl/main/get_latest_rootfs.sh
bash get_latest_rootfs.sh 1 1
Where:
lscpu
Downloads
folder (change WINDOWS_USERNAME
to your Windows user username):
sudo cp clear_linux_rootfs.tar.xz /mnt/c/Users/WINDOWS_USERNAME/Downloads/
The main idea is to update & maintain
this installation method extract rootfs to .tar
that was mentioned in
this tutorial
to contain the latest version
(not 4 years old version as it is in the original tutorial)
Was decided to use GitHub Action to provide the latest version & to save my 20yo laptop resources (mainly my time lol) & just for fun of automation
GitHub only allows to store maximum 2GB files
Was decided to experiment with compression
gzip compression of any level did not give satisfying result
Found that wsl
supports .xz
compression container
(w lzma2 compression, generally available on any unix machine)
as of 2 Apr 2023 as mentioned here
Found unix compressions benchmark #1 & benchmark #2
xz -4
level of compression gives 1.9G
output that is alright
(for now, may change in future, have ~10-15% to compress where)
xz -T2
threads specified to speedup compression
(takes ~14min to compress
& ~9min to upload artifact
& ~1min to upload artifact to release draft,
~24min together)
Found an article that explains some math behind determining the optimal threads count. This task does not require such kind of complexity to measure lzma2 algo params, but just found it interesting for further reading
Works as 4 Dec 2023,
provided detailed README.md
& Installation from source
instructions,
trust nobody not even yourself kekw
Now accepts get_latest_rootfs.sh
arguments
& changed Installation from source
instructions
& tested
Auto-releases enabled: Every GHA run automatically publishes a release
xz -5
level of compression set,
as 40580 release reaches 1.9
-2.0
GB.
New 5
level of compression gives 1.85
GB result
(takes ~18min to compress
& ~8min to upload artifact
& ~1min to upload artifact to release draft,
~27min together)
xz -7
level of compression is set, as 41780 release reaches 2.1
GB.
New 7 level of compression gives 1.43
GB result.
GitHub runners drive space limit 19
GB is exceeded, so the order of operations has been changed to save space.
Takes ~17min in total.