nullpo-head / wsl-distrod

Distrod is a meta-distro for WSL 2 which installs Ubuntu, Arch, Debian, Gentoo, etc. with systemd in a minute for you. Distrod also has built-in auto-start feature on Windows startup and port forwarding ability.
MIT License
1.9k stars 91 forks source link

Install (Option 1) failed - fallback to normal WSL2 command execution without using systemd #10

Closed claudiusraphael closed 2 years ago

claudiusraphael commented 2 years ago

Following the README, choosing Option 1 i checked that default for WSL is version 2, then downloaded the .zip linked in Step 1 and executed the .exe to run Distrod. The following is the (self-explaining) output:

        ██████╗ ██╗███████╗████████╗██████╗  ██████╗ ██████╗
        ██╔══██╗██║██╔════╝╚══██╔══╝██╔══██╗██╔═══██╗██╔══██╗
        ██║  ██║██║███████╗   ██║   ██████╔╝██║   ██║██║  ██║
        ██║  ██║██║╚════██║   ██║   ██╔══██╗██║   ██║██║  ██║
        ██████╔╝██║███████║   ██║   ██║  ██║╚██████╔╝██████╔╝
        ╚═════╝ ╚═╝╚══════╝   ╚═╝   ╚═╝  ╚═╝ ╚═════╝ ╚═════╝
=================================================================================
Thanks for trying Distrod! Choose your distribution to install.
You can install a local .tar.xz, or download an image from linuxcontainers.org.

* linuxcontainers.org is a vendor-neutral project that offers distro images for
  containers, which is not related to Distrod. LXC/LXD is one of its projects.
  BTW, you can run Systemd with distrod, so you can try LXC/LXD with distrod!
=================================================================================
[1] Use a local tar.xz file
[2] Download an image from linxcontainers.org
[Distrod] Choose the way to get a distro image from the list above.
[Distrod] Type the name or the index of your choice.
[Default: Download an image from linxcontainers.org]: 2
[Distrod] Fetching from linuxcontainers.org...
[1] almalinux
[2] alpine
[3] alt
[4] amazonlinux
[5] apertis
[6] archlinux
[7] busybox
[8] centos
[9] debian
[10] devuan
[11] fedora
[12] funtoo
[13] gentoo
[14] kali
[15] mint
[16] opensuse
[17] openwrt
[18] oracle
[19] plamo
[20] pld
[21] rockylinux
[22] sabayon
[23] springdalelinux
[24] ubuntu
[25] voidlinux
[Distrod] Choose a linuxcontainers.org image from the list above.
[Distrod] Type the name or the index of your choice.
[Default: ubuntu]: 11
[Distrod] Fetching from linuxcontainers.org...
[1] 33
[2] 34
[3] 35
[Distrod] Choose a version from the list above.
[Distrod] Type the name or the index of your choice.
[Default: 35]: 35
[Distrod] Fetching from linuxcontainers.org...
[Distrod] Downloading 'https://images.linuxcontainers.org/images/fedora/35/amd64/default/20211118_20:33/rootfs.tar.xz'...
  [00:00:13] [####################################################] 85.36MiB/85.36MiB (6.23MiB/s, 0s)
[Distrod] Download done.
[Distrod] Unpacking and merging the given rootfs to the distrod rootfs. This may take a while...
[Distrod] Now Windows is installing the new distribution. This may take a while...
[Distrod] Distrod is installed in %LocalAppData%\Distrod
[Distrod] Done!
[Distrod] Please input the new Linux user name. This doesn't have to be the same as your Windows user name.
[Input user name]: cldsrphl
Changing password for user cldsrphl.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[Distrod] Querying the generated uid. This may take some time depending on your machine.
[Distrod] Initializing the new Distrod distribution. This may take a while...
[Distrod] Distrod has been enabled. Now your shell will start under systemd.
[Distrod] Setting the default user to uid: 1000
[Distrod] Installation of Distrod is now complete.
[Distrod][ERROR] Failed to run the given command in the Systemd container. Fall back to normal WSL2 command execution without using Systemd. Failed to launch the distro.

Caused by:
    0: Failed to make mountpoint shared.
    1: Failed to make the /tmp mountpoint shared.
    2: EINVAL: Invalid argument
[cldsrphl@D11MMWNX0SDPS66ENGUS distrod_wsl_launcher-x86_64]$

The following is (redacted/freed from personal data) info about my system - commands executed in CMD:

  1. SystemInfo:
C:\Users\cldsrphl>systeminfo
Host Name:                 D11MMWNX0SDPS66
OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.19044 N/A Build 19044
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Workstation
OS Build Type:             Multiprocessor Free
Original Install Date:     9/16/2021, 3:20:20 AM
System Type:               x64-based PC
Processor(s):              1 Processor(s) Installed.
                           [01]: AMD64 Family 16 Model 2 Stepping 3 AuthenticAMD ~2300 Mhz
Windows Directory:         C:\Windows
System Directory:          C:\Windows\system32
Boot Device:               \Device\HarddiskVolume1
System Locale:             en-us;English (United States)
Input Locale:              en-us;English (United States)
Time Zone:                 (UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna
Total Physical Memory:     7,678 MB
Available Physical Memory: 1,221 MB
Virtual Memory: Max Size:  15,337 MB
Virtual Memory: Available: 2,595 MB
Virtual Memory: In Use:    12,742 MB
Page File Location(s):     C:\pagefile.sys
Domain:                    WORKGROUP
Logon Server:              \\D11MMWNX0SDPS66
Hotfix(s):                 5 Hotfix(s) Installed.
                           [01]: KB5006365
                           [02]: KB5003791
                           [03]: KB5007186
                           [04]: KB5006753
                           [05]: KB5005699
Network Card(s):           4 NIC(s) Installed.
                           [01]: Realtek 8185 Extensible 802.11b/g Wireless Device
                                 Connection Name: Wi-Fi
                                 Status:          Media disconnected
                           [02]: Broadcom NetXtreme 57xx Gigabit Controller
                                 Connection Name: Ethernet
                                 DHCP Enabled:    Yes
                                 DHCP Server:     192.168.2.1
                                 IP address(es)
                                 [01]: 192.168.2.136
                                 [02]: fe80::545:81ae:63c6:a9fc
                                 [03]: 2003:cd:70c:bd6f:c551:a499:d529:d25c
                                 [04]: 2003:cd:70c:bd6f:7cfb:63a1:995f:7c7
                                 [05]: 2003:cd:70c:bd6f:545:81ae:63c6:a9fc
                           [03]: VirtualBox Host-Only Ethernet Adapter
                                 Connection Name: VirtualBox Host-Only Network
                                 DHCP Enabled:    No
                                 IP address(es)
                                 [01]: 192.168.56.1
                                 [02]: fe80::34ba:1c8b:7b2:8608
                           [04]: Bluetooth Device (Personal Area Network)
                                 Connection Name: Bluetooth Network Connection 2
                                 Status:          Media disconnected
Hyper-V Requirements:      A hypervisor has been detected. Features required for Hyper-V will not be displayed.
  1. WSL --status:
C:\Users\cldsrphl>wsl --status
Default Distribution: Ubuntu-20.04
Default Version: 2

Windows Subsystem for Linux was last updated on 11/3/2021
WSL automatic updates are on.

Kernel version: 5.10.60.1
  1. WSL --list:
C:\Users\cldsrphl>wsl --list
Windows Subsystem for Linux Distributions:
Ubuntu-20.04 (Default)
Distrod
Ubuntu
  1. WSL -d distrod:
C:\Users\cldsrphl>wsl -d distrod
[Distrod][ERROR] Failed to run the given command in the Systemd container. Fall back to normal WSL2 command execution without using Systemd. Failed to launch the distro.

Caused by:
    0: Failed to make mountpoint shared.
    1: Failed to make the /tmp mountpoint shared.
    2: EINVAL: Invalid argument
[cldsrphl@D11MMWNX0SDPS66ENGUS cldsrphl]$
  1. SystemCtl status (executed inside distrod):
[cldsrphl@D11MMWNX0SDPS66ENGUS cldsrphl]$ systemctl status
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

Please advise how to go on, what commands/procedures might help to investigate the issue.

Note: I was already running the default Ubuntu wsl-distro as installed originally via wsl --install (not the Ubuntu-20.04 - this one was added later). After the initial setup (specifying user/passwd) i ran sudo apt update and sudo apt full-upgrade - the latter was processing when i executed distrod - mentioning in case there is a need to not have a wsl-distro already running when doing the install via distrod.

I will now try Option 2, by applying it to the fresh setup and updated Ubuntu wsl-distro.

nullpo-head commented 2 years ago

Thanks for trying Distrod first! Are you running a Linux kernel you built by yourself? Anyway, could you try the following Python script with sudo and see if it causes an error?

import os
from ctypes import *
libc = CDLL("libc.so.6")
source = b"/tmp"
MS_BIND = 4096
MS_SHARED = 1<<20

print(str(libc.mount(source, source, None, MS_BIND | MS_SHARED, None)))
print(str(os.error()))
claudiusraphael commented 2 years ago

Are you running a Linux kernel you built by yourself?

Nope, it is the fresh standard install provided by Microsoft on Windows 10 Stable Channel, installed from CMD/PS via wsl --install which is the short form of wsl --install --distribution Ubuntu and therefore installs the stable version of Ubuntu, which is at the moment Ubuntu 20.04.3 with all updates/backports from up to and including Ubuntu 21.10 (friendly name Ubuntu in wsl --list --online) - this is Microsoft's default release for WSL2, whereas Ubuntu-20.04 would be the original release-version of Canonical Ubuntu 20.04 LTS, so 20.04.0, which also incorporates the WSL2 customized kernel by Microsoft, but is not based on the point-releases.

Regarding the mentioned script it would be preferable if you could provide a summary of what it actually does. Also, it is not clear if you mean to run that script in the Distrod wsl-distro as installed by distrod_wsl_launcher.exe or if you refer to install Option 2 which uses the Ubuntu wsl-distro default which was referenced here from the Install (Option 2) failed ... issue.

  1. Distrod wsl-distro (Fedora 35):
[cldsrphl@D11MMWNX0SDPS66ENGUS cldsrphl]$ uname -a
Linux D11MMWNX0SDPS66ENGUS 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 x86_64 x86_64 x86_64 GNU/Linux
[cldsrphl@D11MMWNX0SDPS66ENGUS cldsrphl]$ sudo python3
Python 3.10.0 (default, Oct  4 2021, 00:00:00) [GCC 11.2.1 20210728 (Red Hat 11.2.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> from ctypes import *
>>> libc = CDLL("libc.so.6")
>>> source = b"/tmp"
>>> MS_BIND = 4096
>>> MS_SHARED = 1<<20
>>>
>>> print(str(libc.mount(source, source, None, MS_BIND | MS_SHARED, None)))
-1
>>> print(str(os.error()))

>>> exit()
  1. Ubuntu wsl-distro (Ubuntu 20.04.3)
cldsrphl@D11MMWNX0SDPS66ENGUS:/mnt/c/Users/cldsrphl$ uname -a
Linux D11MMWNX0SDPS66ENGUS 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 x86_64 x86_64 x86_64 GNU/Linux
cldsrphl@D11MMWNX0SDPS66ENGUS:/mnt/c/Users/cldsrphl$ sudo python3
[sudo] password for cldsrphl:
Python 3.8.10 (default, Sep 28 2021, 16:10:42)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> from ctypes import *
>>> libc = CDLL("libc.so.6")
>>> source = b"/tmp"
>>> MS_BIND = 4096
>>> MS_SHARED = 1<<20
>>>
>>> print(str(libc.mount(source, source, None, MS_BIND | MS_SHARED, None)))
-1
>>> print(str(os.error()))

>>> exit()

If the python-code needs to be invoked in another way than by starting the interpreter with sudo, please provide the correct way - while i am willing to invest time to investigate the issue at hand i will not invest any more time in the self-contradictory mess that is python (i guess that makes it clear what my standpoint is regarding that "language").

I hope it helps. Let me know how to go on. I am open for any kind of experiments, including time-intensive exercises as compiling a custom kernel if it might be helpful - as long as needing to understand Python is not part of the exercise, meaning executing python-code i am fine with but nothing more - i would rather rewrite Windows 95 in brainfck than wrestling that oroborus (just in case i wasn't clear enough, lol).

nullpo-head commented 2 years ago

Hi! Thanks so much for taking your time for the investigation. It helped a lot! With that Python script, I wanted to check if the mount system call with MS_BIND | MS_SHARED flag succeeds or not in your environment. It does almost nothing than checking it. So, any environment was ok as far as it uses the same kernel, which is why I forgot to mention the desired test environment.

The result you shared is very interesting... So, -1 means it fails in your environment, which succeeds in my environment, 4.19.128-microsoft-standard and 5.10.60.1-microsoft-standard-WSL2. I guess setting MS_SHARED with MS_BIND at the same time is not correct usage of mount system call, so the old kernel was returning error to it.

I've released a new version which fixed how to call mount flag. Could you try it and check if the problem is fixed, please?

Thanks!

nullpo-head commented 2 years ago

Hi @claudiusraphael From your output of uname -a, it turns out that your installing Distrod as a WSL 1 instance. Set your default WSL version to 2.

This output means you're using WSL1. Linux D11MMWNX0SDPS66ENGUS 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 x86_64 x86_64 x86_64 GNU/Linux

claudiusraphael commented 2 years ago

Please explain what indicates it as "installed as WSL 1 instance", for better understanding.

Besides that:

I did all what is listed already on my first-try before creating the post regarding the second completely from scratch fresh setup specifically to test distrod. In both cases (on an existing system in use for months working perfectly fine regarding WSL 2 with and without Docker Desktop) as well as the fresh setup one it was identical behaviour.

In the meanwhile i repeated the task with the actual Insider Beta-Channel of Windows 10 Pro and the Dev-version of Windows 11 Pro on the otherwise mentioned two test-systems. The end-result is the exact same as i posted here. So please elaborate once more on possibilities why.

I have setup a fresh 2 TB Samsung QVO 870 SSD with Windows 11 Pro in the meanwhile to speed up testing and development.

I will repeat the install of distrod on this system once Visual Studio/Andorid Studio and diverse other stuff is done being installed in full.