Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

Change systemd target to multi-user #49

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion enter-systemd-namespace
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if ! command -v /usr/bin/unshare > /dev/null; then
exit 1
fi

SYSTEMD_EXE="/lib/systemd/systemd --unit=basic.target"
SYSTEMD_EXE="/lib/systemd/systemd --unit=multi-user.target"
SYSTEMD_PID="$(ps -eo pid=,args= | awk '$2" "$3=="'"$SYSTEMD_EXE"'" {print $1}')"
if [ -z "$SYSTEMD_PID" ]; then
"$DAEMONIZE" /usr/bin/unshare --fork --pid --mount-proc bash -c 'export container=wsl; mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc; exec '"$SYSTEMD_EXE"
Expand Down
2 changes: 1 addition & 1 deletion start-systemd-namespace
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

SYSTEMD_EXE="/lib/systemd/systemd --unit=basic.target"
SYSTEMD_EXE="/lib/systemd/systemd --unit=multi-user.target"
SYSTEMD_PID="$(ps -eo pid=,args= | awk '$2" "$3=="'"$SYSTEMD_EXE"'" {print $1}')"
if [ "$LOGNAME" != "root" ] && ( [ -z "$SYSTEMD_PID" ] || [ "$SYSTEMD_PID" != "1" ] ); then
export | sed -e 's/^declare -x //;/^IFS=".*[^"]$/{N;s/\n//}' | \
Expand Down
3 changes: 3 additions & 0 deletions ubuntu-wsl2-systemd-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ sudo rm -f /etc/systemd/user/sockets.target.wants/gpg-agent*.socket
sudo rm -f /lib/systemd/system/sysinit.target.wants/proc-sys-fs-binfmt_misc.automount
sudo rm -f /lib/systemd/system/sysinit.target.wants/proc-sys-fs-binfmt_misc.mount
sudo rm -f /lib/systemd/system/sysinit.target.wants/systemd-binfmt.service
sudo rm -f /etc/systemd/system/multi-user.target.wants/systemd-resolved.service
sudo rm -f /etc/systemd/system/dbus-org.freedesktop.resolve1.service


if [ -f /proc/sys/fs/binfmt_misc/WSLInterop ] && [ "$(head -n1 /proc/sys/fs/binfmt_misc/WSLInterop)" == "enabled" ]; then
"$(interop_prefix)$(sysdrive_prefix)"/Windows/System32/cmd.exe /C setx WSLENV BASH_ENV/u
Expand Down