Hi!
I am trying to activate systemd and I almost did it.
I followed the instructions from here: https://github.com/DamionGans/ubuntu-wsl2-systemd-script.
After installing this script and running wsl for the first time, the command: “snap version” gives this result:
> snap version
snap 2.45.1+20.04.2
snapd unavailable
series -
The systemctl command produces this result:
> systemctl
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
But if I execute a command after that in the current session:
> neofetch
or
> wslfetch
then the message “Sleeping for 1 second to let systemd settle” will appear for a short time (~ 1 or 2 seconds).
Then a welcome message will be displayed:
Sleeping for 1 second to let systemd settle
Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 4.19.121-microsoftstandard x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Wed Aug 26 20:12:21 MSK 2020
System load: 0.0 Processes: 89
Usage of /: 6.7% of 250.98GB Users logged in: 0
Memory usage: 5% IPv4 address for eth0: 172.26.42.54
Swap usage: 0%
* Are you ready for Kubernetes 1.19? It's nearly here! Try RC3 with
sudo snap install microk8s --channel=1.19/candidate --classic
https://microk8s.io/ has docs and details.
3 updates can be installed immediately.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable
Last login: Wed Aug 26 20:10:40 MSK 2020 on pts/0
And after that the "systemctl" command will display a list of available units, their status and states (I'm just giving the end of a large list here):
LOAD = Reflects if the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
183 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
lines 150-191/191 (END)
The “snap version” command shows that snap and snapd are available:
> snap version
snap 2.45.1+20.04.2
snapd 2.45.3.1
series 16
ubuntu 20.04
kernel 4.19.121-microsoftstandard
The list of snap packages will be available as well as the packages themselves - I can run the snap packages available to me (GUI applications using VcXsrv or just console applications).
But snap packages will only be available to me in the current session of the terminal: if I open a new session of the terminal - snap packets will not be available again.
But when I execute commands again in the new session:
> neofetch
or
> wslfetch
— then again the message “Sleeping for 1 second to let systemd settle” will appear for a short time (~ 1 or 2 seconds).
Then a welcome message will be displayed:
Sleeping for 1 second to let systemd settle
Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 4.19.121-microsoftstandard x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Wed Aug 26 20:12:21 MSK 2020
System load: 0.0 Processes: 89
Usage of /: 6.7% of 250.98GB Users logged in: 0
Memory usage: 5% IPv4 address for eth0: 172.26.42.54
Swap usage: 0%
* Are you ready for Kubernetes 1.19? It's nearly here! Try RC3 with
sudo snap install microk8s --channel=1.19/candidate --classic
https://microk8s.io/ has docs and details.
3 updates can be installed immediately.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable
Last login: Wed Aug 26 20:10:40 MSK 2020 on pts/0
And I can use snap packages again.
Another strange thing is that when I get access to snap packages, or in other words when systemd is activated, it somehow modifies the $PATH environment variable, and then I cannot call windows applications from current wsl session (but in new session I can). For example: “code” to run vs code or “exlorer.exe .” to run the windows explorer:
> exlorer.exe .
zsh: command not found: explorer.exe
But in the new session, I lose the availability of snap packages (or systemd) and can run windows applications from wsl again.
And if print the value of the environment variable $PATH in the session where snap packages are available (or in other words, systemd is activated) will be something:
> echo $PATH
/home/haosmos/.nvm/versions/node/v14.8.0/bin:/home/haosmos/haosmos/.local/bin:/home/haosmos/bin:/usr/local/bin:/home/haosmos/. local/share/umake/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
If output the environment variable $PATH - in a session where snap packages are NOT available (or in other words, systemd is NOT activated) there will be something:
> echo $PATH
/home/haosmos/.nvm/versions/node/v14.8.0/bin:/home/haosmos/haosmos/.local/bin:/home/haosmos/bin:/usr/local/bin:/home/haosmos/.local/share/umake/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files (x86)/NetSarang/Xlpd 6/:/mnt/c/Program Files (x86)/NetSarang/Xftp 6/:/mnt/c/Program Files (x86)/NetSarang/Xshell 6/:/mnt/c/Program Files (x86)/NetSarang/Xmanager 6/:/mnt/c/tools/dart-sass:/mnt/c/Users/Haosmos/AppData/Local/hyper/app-3.0.2/resources/bin:/mnt/c/Windows/System32:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/dotnet/:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/Dart/dart-sdk/bin:/mnt/c/WINDOWS/System32/wsl:/mnt/c/Users/Haosmos/AppData/Roaming/nvm:/mnt/c/Program Files/nodejs:/mnt/c/Program Files/PowerShell/7/:/mnt/c/Program Files (x86)/Common Files/Acronis/VirtualFile/:/mnt/c/Program Files (x86)/Common Files/Acronis/VirtualFile64/:/mnt/c/Program Files (x86)/Common Files/Acronis/FileProtector/:/mnt/c/Program Files (x86)/Common Files/Acronis/FileProtector64/:/mnt/c/Program Files (x86)/Common Files/Acronis/SnapAPI/:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/Git/cmd:/mnt/c/Users/Haosmos/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files/Microsoft VS Code/bin:/mnt/c/Users/Haosmos/AppData/Local/GitHubDesktop/bin:/mnt/c/Users/Haosmos/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Program Files (x86)/Python38-32:/mnt/c/Program Files (x86)/Python38-32/Scripts:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/tools/dart-sdk/bin:/mnt/c/Users/Haosmos/AppData/Roaming/Pub/Cache/bin:/mnt/c/Program Files/JetBrains/WebStorm 2020.2/bin:/mnt/c/Program Files/JetBrains/PhpStorm 2020.1.2/bin:/mnt/c/Users/Haosmos/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files/JetBrains/WebStorm 2020.1/bin:/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe:/mnt/c/Program Files/Firefox Developer Edition/firefox.exe:/mnt/c/Program Files/Internet Explorer/iexplore.exe
I recorded a short video with a demonstration of what I have described above — https://yadi.sk/i/gRPIMDwaDqt6uw
Please tell me how to make snap packages (or more generally systemd) and commands to run windows applications always available in wsl 2?
My environment:
Windows 10
OS version: 2004
OS build: 20197.1000 (insider preview “dev”)
WSL: Ubuntu-20.04.1
Linux kernel: 4.19.121