DamionGans / ubuntu-wsl2-systemd-script

[Does not work anymore!] Script to enable systemd support on current Ubuntu WSL2 images

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ubuntu 22.04 LTS nsenter: cannot open /proc/xxx/ns/time: No such file or directory

c01hl opened this issue · comments

commented

image

Having the same problem after upgrading Ubuntu WSL from 20.04 to 22.04.

@c01hl going into my WSL2 Ubuntu 22.04 with wsl -e bash --norc command and using this #36 (comment) to edit the file using sudo nano /usr/sbin/enter-systemd-namespace helped me to fix my WSL2 environment.

Skip all the other steps in #36 (comment), especially the re-installation step. Because it writes -a back to the changed place in the /usr/sbin/enter-systemd-namespace file.

Ich tried the solution in #36 , but as shown in #36#issuecomment-1125293384 , this does only work for root wsl -u root, not for a normal user.

@apos this is weird. I logged in using wsl -e bash --norc under PowerShell, then I only did the -m -p change from #36 (comment) by editing the related file with sudo nano /usr/sbin/enter-systemd-namespace and disregarded everything else from the comment. After that the WSL environment booted as before with the non-root user, but with Ubuntu 22.04.

After that the WSL environment booted as before with the non-root user, but with Ubuntu 22.04.

@CleanHit: sure, that systemd is running?

ps aux | grep systemd

@CleanHit: sure, that systemd is running?

ps aux | grep systemd

Here is my output of ps aux | grep systemd, I've replaced my non-root username with <my_non-root_user>.

root         	      1  0.0  0.0 169544 11452 ?        Ss   22:13   0:00 /lib/systemd/systemd --unit=basic.target
root                  44  0.0  0.0  48016 15652 ?         S<s  22:13   0:00 /lib/systemd/systemd-journald
root         	      72  0.0  0.0  22344  6224 ?        Ss   22:13   0:00 /lib/systemd/systemd-udevd
systemd+     	      95  0.0  0.0  16064  8076 ?        Ss   22:13   0:00 /lib/systemd/systemd-networkd
message+     	      223  0.0  0.0   8772  5004 ?        Ss   22:13   0:00 @dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
root         	      304  0.0  0.0  12056  5704 pts/1    S+   22:13   0:00 /usr/bin/sudo -H -u <my_non-root_user> /bin/bash -c set -a; [ -f "$HOME/.systemd-env" ] && source "$HOME/.systemd-env"; set +a; exec bash -c sh\ -c\ \'\"\$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh\"\ da15b6fd3ef856477bf6f4fb29ba1b7af717770d\ stable\ code-server\ .vscode-server\ --host=127.0.0.1\ --port=0\ --connection-token=1991737642-3456313712\ --use-host-proxy\ --without-browser-env-var\ --disable-websocket-compression\ --accept-server-license-terms\ --telemetry-level=all\'
root                  305  0.0  0.0  12056   924 pts/2    Ss+  22:13   0:00 /usr/bin/sudo -H -u <my_non-root_user> /bin/bash -c set -a; [ -f "$HOME/.systemd-env" ] && source "$HOME/.systemd-env"; set +a; exec bash -c sh\ -c\ \'\"\$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh\"\ da15b6fd3ef856477bf6f4fb29ba1b7af717770d\ stable\ code-server\ .vscode-server\ --host=127.0.0.1\ --port=0\ --connection-token=1991737642-3456313712\ --use-host-proxy\ --without-browser-env-var\ --disable-websocket-compression\ --accept-server-license-terms\ --telemetry-level=all\'
root                  1422  0.0  0.0  15156  7184 ?        Ss   22:26   0:00 /lib/systemd/systemd-logind
<my_non-root_user>    1424  0.0  0.0  16996  9768 ?        Ss   22:26   0:00 /lib/systemd/systemd --user
<my_non-root_user>    1455  0.0  0.0   8292  4044 ?        Ss   22:26   0:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
<my_non-root_user>    1769  0.0  0.0   7004  2028 pts/4    S+   22:33   0:00 grep --color=auto systemd

Ok, I give up for now and comment out the call of /usr/sbin/enter-systemd-namespace in /etc/bashrc to get at least a running (shell-)system.

Thanks @CleanHit

P.S.: more weird: all the programs are running now (with above "fix") from Startmenu like Evolution (Gnome!), Stellarium, Xterm (with normal non-root-user), PDF-Arranger, LyX , also my printer works. But no terminal vom PS or Windows Terminal with normal user ... tssss.

I solved my problem decribed here: 36#issuecomment-1125293384 - login only with root

  1. I am using windows terminal app (see app store, best terminal app ever MS released!)
  2. This app has a settings file which can be edited eather manually or via Settings-Menü in the app (in very detail explained here )
  3. You can configure different shell environments
  4. For my ubuntu: you can set the start directory in the settings in which the terminal lands. The solution was to set it to: \\wsl.localhost\Ubuntu-20.04\home\myuser . The problem was: there had been a $ near wsl ($wsl). I really don't know, where this comes from.

Here another hint: my start command for wsl within the settings like C:\WINDOWS\system32\wsl.exe -d Ubuntu-20.04 -u myuser. This makes the terminal start with the correct user.

Summary: the fix provided an discribed works which is just edit /usr/sbin/enter-systemd-namespace and change -a in the described line to -m -p. No reininstallation of the script necessary!

Cheers Axel

@apos thanks for the informative post. I didn't mention that I was using the winsows terminal app, as I didn't think that it makes any difference. I gues it did and that's why the steps above were working for me.

@c01hl going into my WSL2 Ubuntu 22.04 with wsl -e bash --norc command and using this #36 (comment) to edit the file using sudo nano /usr/sbin/enter-systemd-namespace helped me to fix my WSL2 environment.

Skip all the other steps in #36 (comment), especially the re-installation step. Because it writes -a back to the changed place in the /usr/sbin/enter-systemd-namespace file.

Nice Bro!
I fix it with you solution!

my path is \\wsl$\Ubuntu-22.04\home\$username\ ... but I still can't get it to work with all options available

Guys,
For me I needed to delete the files that are copied to the usr folder by the script.

Go to: /usr/sbin/
Delete: start-systemd-namespace and enter-systemd-namespace

image

Change the script as directed in the comment above.
And run again.

@c01hl going into my WSL2 Ubuntu 22.04 with wsl -e bash --norc command and using this #36 (comment) to edit the file using sudo nano /usr/sbin/enter-systemd-namespace helped me to fix my WSL2 environment.

Skip all the other steps in #36 (comment), especially the re-installation step. Because it writes -a back to the changed place in the /usr/sbin/enter-systemd-namespace file.

Các bạn, Đối với tôi, tôi cần xóa các tệp được sao chép vào thư mục usr bằng tập lệnh.

Đi tới: /usr/sbin/ Xóa: start-systemd-namespace và enter-systemd-namespace

ảnh

Thay đổi kịch bản như được hướng dẫn trong phần bình luận ở trên. Và chạy lại.

@c01hl đi vào WSL2 Ubuntu 22.04 của tôi với lệnh và sử dụng # 36 này (nhận xét) để chỉnh sửa các tập tin bằng cách sử dụng đã giúp tôi sửa chữa môi trường WSL2 của tôi.wsl -e bash --norc``sudo nano /usr/sbin/enter-systemd-namespace
Bỏ qua tất cả các bước khác trong # 36 (nhận xét), đặc biệt là bước cài đặt lại. Bởi vì nó ghi lại vị trí đã thay đổi trong tệp /usr/sbin/enter-systemd-namespace.-a

It's easy. Thanks for your solution. I get this problem when update Ubuntu 2004 to 2204 and can fix it.