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

[Question or Bug]: Only first WSL Distro can enable systemd user mode, but not for rest distros #41

Open leolcao opened 2 years ago

leolcao commented 2 years ago

Describe the bug

I use distrod to make one distro by using the ubuntu cloudimg 22.04, then export it into tar file, and import it into 2 distros. In each distro, I created the default nromal user which id is 1000 obviously.

I find I only can enable the systemd user mode in one distro, but not in second, it dose not depend which distro, it depends on the the first one been launched.

Steps to reproduce

For example, distro A and B.

Step 1. I open A firstly, then use the way sudo login -f $(whoami) to enable systemd user mode, and then input command systemctl --user is-active dbus to check it, and get 'inactive' which is right because no user service yet.

Step 2. I open B secondly, use the same way to enable systemd user mode, but I get error message "Failed to connect to bus: No such file or directory" from 'systemctl --user is-active dbus'. Then I check the status in B, like this:

sudo systemctl status user@1000.service
Failed to dump process list for 'user@1000.service', ignoring: Input/output error
○ user@1000.service - User Manager for UID 1000
     Loaded: loaded (/lib/systemd/system/user@.service; static)
    Drop-In: /etc/systemd/system/user@.service.d
             └─delegate.conf
             /usr/lib/systemd/system/user@.service.d
             └─timeout.conf
     Active: inactive (dead) since Sun 2022-02-06 20:13:29 CST; 9min ago
       Docs: man:user@.service(5)
    Process: 423 ExecStart=/lib/systemd/systemd --user (code=exited, status=219/CGROUP)
   Main PID: 423 (code=exited, status=219/CGROUP)
      Tasks: 40
     Memory: 118.8M
        CPU: 2.057s
     CGroup: /user.slice/user-1000.slice/user@1000.service

Feb 06 20:13:29 DESKTOP-4SSBAGS systemd[1]: Starting User Manager for UID 1000...
Feb 06 20:13:29 DESKTOP-4SSBAGS systemd[1]: user@1000.service: Main process exited, code=exited, status=219/CGROUP
Feb 06 20:13:29 DESKTOP-4SSBAGS systemd[1]: user@1000.service: Failed to kill control group /user.slice/user-1000.slice/user@1000.service, ignoring: Input/output error
Feb 06 20:13:29 DESKTOP-4SSBAGS systemd[1]: user@1000.service: Failed to kill control group /user.slice/user-1000.slice/user@1000.service, ignoring: Input/output error
Feb 06 20:13:29 DESKTOP-4SSBAGS systemd[1]: user@1000.service: Failed with result 'exit-code'.
Feb 06 20:13:29 DESKTOP-4SSBAGS systemd[1]: Failed to start User Manager for UID 1000.

But I find it is same in reverse between A and B. If I open A in second step, will get same error.

PS: during the testing, I use 'wsl -t A | B' to terminate the distro, then open the distro again by using Windows terminal.

Expected behavior

Actually, I found the root cause is because A and B have same user id(1000), if I create a new user in B which UID is 1001, then A and B can bothly enable the systemd user mode successfully. So it seems the same UID cause the systemd resource conflicts.

Can u explain something for this finding? Is it a bug or not ?

Windows version

Windows 21H2 19044.1503

Linux kernel version

Linux DESKTOP-4SSBAGS 5.10.60.1-microsoft-standard-WSL2 #1 SMP Wed Aug 25 23:20:18 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Distro

ubuntu 22.04 current

How did you install that distro?

Installed by Distrod wizard

Logs

Sorry, didn't know the setting from reference during the tests. This question is want to solve my curiousness.

additional comment

No response