Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Systemctl not active #30

Open
h00jraq opened this issue May 30, 2022 · 4 comments
Open

Systemctl not active #30

h00jraq opened this issue May 30, 2022 · 4 comments

Comments

@h00jraq
Copy link

h00jraq commented May 30, 2022

Hi,

I've did everything from the instructions but I still get the below error.
As You can see, I sing as root but it does not change anything.

root@9BG9HG3:/home/fdrzewiecki# uname -a
Linux 9BG9HG3 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
root@9BG9HG3:/home/fdrzewiecki# systemctl is-active dbus
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
root@9BG9HG3:/home/fdrzewiecki# 

VIPW:

root:x:0:0:root:/root:/bin/bash
rootwsl:x:0:0:root:/root:/usr/local/bin/wsl2hack

VIPW -S


root:*:18375:0:99999:7:::
rootwsl:x:0:0:root:/root:/usr/local/bin/wsl2hack

#!/bin/bash
# your WSL2 username
UNAME="fdrzewiecki"

UUID=$(id -u "${UNAME}")
UGID=$(id -g "${UNAME}")
UHOME=$(getent passwd "${UNAME}" | cut -d: -f6)
USHELL=$(getent passwd "${UNAME}" | cut -d: -f7)

if [[ -p /dev/stdin || "${BASH_ARGC}" > 0 && "${BASH_ARGV[1]}" != "-c" ]]; then
    USHELL=/bin/bash
fi

if [[ "${PWD}" = "/root" ]]; then
    cd "${UHOME}"
fi

# get pid of systemd
SYSTEMD_PID=$(pgrep -xo systemd)

# if we're already in the systemd environment
if [[ "${SYSTEMD_PID}" -eq "1" ]]; then
    exec "${USHELL}" "$@"
fi

if [[ -z ${SYSTEMD_PID} ]]; then
    # start systemd
    /usr/bin/daemonize -l "${HOME}/.systemd.lock" /usr/bin/unshare -fp --mount-proc /lib/systemd/systemd --system-unit=basic.target

    # wait for systemd to start
    retries=50
    while [[ -z ${SYSTEMD_PID} && $retries -ge 0 ]]; do
        (( retries-- ))
            sleep .1
            SYSTEMD_PID=$(pgrep -xo systemd)
    done

    if [[ $retries -lt 0 ]]; then
        >&2 echo "Systemd timed out; aborting."
        exit 1
    fi
fi

# export WSL variables
export WINPATH="$(echo "$PATH"|grep -o ':/mnt/c.*$'|sed 's!^:!!')"
RUNOPTS=""
RUNOPTS="$RUNOPTS -l"
RUNOPTS="$RUNOPTS -w WINPATH"
RUNOPTS="$RUNOPTS -w WSL_INTEROP"
RUNOPTS="$RUNOPTS -w WSL_DISTRO_NAME"

# enter systemd namespace
exec /usr/bin/nsenter -t "${SYSTEMD_PID}" -m -p --wd="${PWD}" /sbin/runuser $RUNOPTS -s "${USHELL}" "${UNAME}" -- "${@}"

Not sure What I'm doing wrong here...

@leepc12
Copy link

leepc12 commented May 31, 2022

Same issue here

@psych0nokoi
Copy link

any glory?

@g2proko
Copy link

g2proko commented Jul 27, 2022

VIPW:

root:x:0:0:root:/root:/bin/bash
rootwsl:x:0:0:root:/root:/usr/local/bin/wsl2hack

@h00jraq @leepc12 , the line of rootwsl must be the first line.

@HVD3Z
Copy link

HVD3Z commented Aug 4, 2022

Had the same issue @g2proko correction worked. The author should update the guide to reflect this as I could see others having these issues especially if new to wsl/linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants