3

After enabling Systemd per this answer in Ubuntu 22.04, sudo systemctl status shows State: degraded.

Additionally:

$ sudo systemctl --failed

UNIT LOAD ACTIVE SUB DESCRIPTION ● systemd-sysusers.service loaded failed failed Create System Users

LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend on unit type. 1 loaded units listed.

How can I transition from degraded to running?

NotTheDr01ds
  • 17,888

1 Answers1

4

Update: WSL 1.1.0, currently a pre-release, is reported to fix this issue. I have not confirmed yet, but it uses the same bind-mount solution I propose below, so I have every confidence that it will work.

Currently, 1.1.0 can be downloaded and installed manually with Add-AppxPackage, but when it exits pre-release status (likely with 1.1.1), it should be auto-installed with wsl --upgrade.


Old answer (still useful information for understanding the problem):

This is due to the current use of a symlink from /dev/shm to /run/shm in WSL. There are several related Github issues:

Among other things, this will cause any Systemd service that makes use of LoadCredentials= to fail. This impacts several other services on other distributions, but systemd-sysusers is the only default service under Ubuntu 22.10, at least, to make use of this.

The workaround, as documented in #8996, is to create a new Systemd service that corrects the problem before any other Systemd units make use of that shared memory device.

(Likely) Important -- Please check back here or the above Github issues after upgrading WSL to see if there have been any changes which would warrant the reversal of this action.

sudo -e /etc/systemd/system/fix_wsl2_shm.service

Add the following:

[Unit]
Description=Fix the /dev/shm symlink to be a mount
DefaultDependencies=no
Before=sysinit.target
ConditionPathExists=/dev/shm
ConditionPathIsSymbolicLink=/dev/shm
ConditionPathIsMountPoint=/run/shm

[Service] Type=oneshot ExecStart=/usr/bin/rm /dev/shm ExecStart=/bin/mount --bind -o X-mount.mkdir /run/shm /dev/shm

[Install] WantedBy=sysinit.target

sudo systemctl enable fix_wsl2_shm.service

Exit Ubuntu, wsl --terminate <distro_name> (or wsl --shutdown), and restart.

Confirm that sudo systemctl status now shows running. If not:

  • Confirm whether sudo systemctl status fix_wsl2_shm.service shows that the service was loaded.
  • Confirm whether findmnt /dev/shm shows that it is mounted, or if ls -ld /dev/shm shows that it is a symlink.
NotTheDr01ds
  • 17,888