Because, why not ?
WSL is a nice feature of Windows 10, making Linux pseudo-distributions available through command line. I say pseudo, because they are not really like virtual machines, but they rely on virtualization capacities that make their integration with Windows almost seamless. Docker for Windows can now rely on WSL instead of Hyper-V, for example.
That last point brought me to delve into this thread’s matter. Since I was using Docker to test my YunoHost packages, why not directly use WSL to install YunoHost on it?
Bear in mind, this setup itself is not a container of any kind. If something breaks, there is no rollback capability. You may need to delete the Debian distro altogether and try again.
This setup is mainly meant for local testing. Due to limitations on WSL’s side (changing IP address, notably), selfhosting from it can be tricky and will not be described here. See the discussion below the first post.
Install Debian 10
Let’s install YunoHost into its own distro, not altering the default one. In PowerShell:
# Let's go in your home directory and prepare the working directories cd ~ mkdir WSL mkdir WSL\YunoHost # Download the Debian appx package and unzip it curl.exe -L -o debian.zip https://aka.ms/wsl-debian-gnulinux Expand-Archive .\debian.zip -DestinationPath .\debian # Import the Debian base into a new distro wsl --import YunoHost ~\WSL\YunoHost ~\debian\install.tar.gz --version 2 # Cleanup rmdir .\debian -R
You can access it with
wsl.exe -d YunoHost. I advise you to give a try to Windows Terminal Preview, it offers shortcuts to the WSL distros. Now, let’s open your new WSL distro. It is under Debian 9 Stretch, so let’s upgrade it:
sudo sed -i 's/stretch/buster/g' /etc/apt/sources.list` sudo apt update sudo apt upgrade sudo apt dist-upgrade
Prevent WSL from tweaking configuration files
/etc/wsl.conf and put the following code in it:
[network] generateHosts = false generateResolvConf = false
Force the use of iptables-legacy
Somehow the YunoHost post-installation does not like
nf_tables, the new software replacing
iptables. We can still explicitely use the good ol’
sudo update-alternatives --set iptables /usr/sbin/iptables-legacy sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
Debian on WSL does not have
systemd, a service configuration software. This is a key element for YunoHost, and any decent Debian distro (seriously MS, what the heck). Let’s install it:
- Install dotNET runtime:
wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb sudo apt update sudo apt install -y apt-transport-https sudo apt update sudo apt install -y dotnet-sdk-3.1
- Install Genie:
# Add their repository echo "deb [trusted=yes] https://wsl-translinux.arkane-systems.net/apt/ /" > /etc/apt/sources.list.d/wsl-translinux.list # Install Genie sudo apt update sudo apt install -y systemd-genie
# Let's switch to the root user, if you were not already sudo su # Initialize the Genie bottle to have systemd running genie -s # Your hostname should have been appended with "-wsl" # Install YunoHost curl https://install.yunohost.org | bash -s -- -a # Perform the postinstall yunohost tools postinstall
You will have to choose a fake domain, since it will not be accessible from outside. For example,
ynh.wsl. The tricky part is advertising this domain to your host.
C:\Windows\System32\drivers\etc\hosts file. You should have a line starting by
::1, update it or add it if needed to get:
::1 ynh.wsl localhost
If you want to create subdomains, do not forget to add them in the
hosts file too:
::1 ynh.wsl subdomain.ynh.wsl localhost
Access the command line
genie -s while starting your distro.
wsl -d YunoHost -e genie -s
Backup and restore the distro
Make your first backup
As said before, there is no rollback capability. So let’s export your fresh distro. In PowerShell:
cd ~ wsl --export YunoHost .\WSL\YunoHost.tar.gz
In case of crash, delete and restore
cd ~ wsl --unregister YunoHost wsl --import YunoHost .\WSL\YunoHost .\WSL\YunoHost.tar.gz --version 2
- 2020-07-04: v1
- 2020-12-06: v2, making it a bit more like a tutorial and make the steps more explicit.