microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.24k stars 811 forks source link

enabling systemd on wsl2 under 22h2 results in extreemly bad performance (suspect some kind of io issue) #9029

Closed exitdown closed 1 year ago

exitdown commented 1 year ago

PS C:\Users\vinny> wsl.exe --status Default Distribution: Ubuntu-18.04 Default Version: 2 PS C:\Users\vinny> wsl.exe --version WSL version: 0.70.0.0 Kernel version: 5.15.68.1 WSLg version: 1.0.45 MSRDC version: 1.2.3575 Direct3D version: 1.606.4 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.22621.674 PS C:\Users\vinny>

PS C:\Users\vinny> cmd /c ver

Microsoft Windows [Version 10.0.22621.674]

[ 2.332217] pci c8cf:00:00.0: BAR 0: assigned [mem 0x9ffe0c000-0x9ffe0cfff 64bit] [ 2.332925] pci c8cf:00:00.0: BAR 2: assigned [mem 0x9ffe0d000-0x9ffe0dfff 64bit] [ 2.333681] pci c8cf:00:00.0: BAR 4: assigned [mem 0x9ffe0e000-0x9ffe0efff 64bit] [ 2.593421] systemd-journald[53]: Received client request to flush runtime journal. [ 2.602469] systemd-journald[53]: File /var/log/journal/d15c41973ea392736c6e42d15dfa8736/system.journal corrupted or uncleanly shut down, renaming and replacing. [ 49.167961] hv_balloon: Max. dynamic memory size: 8108 MB [ 64.333963] systemd-journald[53]: Failed to read journal file /var/log/journal/d15c41973ea392736c6e42d15dfa8736/user-1000.journal for rotation, trying to move it out of the way: Device or resource busy [ 92.928099] Failed to query system state: Transport endpoint is not connected [ 92.928586] WSL (2) ERROR: InitCreateSessionLeader:1064: /sbin/init failed to start within [ 92.928588] 10000ms [ 92.929369] WSL (2) WARNING: /etc/resolv.conf updating disabled in /etc/wsl.conf [ 92.942334] WSL (2): Creating login session for vinny root@spendyz:/home/vinny#

root@spendyz:/home/vinny# uname -a Linux spendyz 5.15.68.1-microsoft-standard-WSL2 #1 SMP Mon Sep 19 19:14:52 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux root@spendyz:/home/vinny# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.1 LTS Release: 22.04 Codename: jammy root@spendyz:/home/vinny#

system takes about 2 min to become avaiable once starting, and about 2 min to sudo etc.

only exhibited after enabling systemd=true [boot] flag in wsl.conf

removing this flag issue goes away

id love to use systemd if possible, so any suggestions on troubleshooting steps would be greatly appreciated :D

thanks!

pgmclean commented 1 year ago

Relevant information from https://github.com/arkane-systems/genie/wiki/Systemd-units-known-to-be-problematic-under-WSL systemd-remount-fs.service Fails with the following error: mount: /: can't find LABEL=cloudimg-rootfs. This occurs because systemd-remount-fs is trying to remount the root partition to make sure that it has the options configured in /etc/fstab; and the Ubuntu default /etc/fstab assumes that the root partition is labeled "cloudimg-rootfs". This isn't the case under WSL (the root partition is one of its .vhdx files), so the remount fails. (This isn't strictly a problem with the service - you'd get the same error if you tried to remount / manually.)

There are two ways to solve this one: either find the device the root partition is mounted from (probably /dev/sdb, but check first), and label it appropriately:

sudo e2label /dev/sdb cloudimg-rootfs or, if you're happy with the existing mount options for your root filesystem, simply delete the line for / from /etc/fstab entirely. WSL mounts it for you automatically and with reasonable options when starting up the distro, so unless you know that you need something different, there's not actually any point in having it there. I chose the sudo e2label /dev/sdc cloudimg-rootfs option and uncommented "LABEL=cloudimg-rootfs / ext4 defaults 0 1" in /etc/fstab.

mlaugharn commented 1 year ago

I did cd /etc/acpi/ && mv events events-OLD && mkdir events to fix the issue.

This worked for me! /sbin/init went from 100% cpu to nothing, and sudo commands work quickly again - had the same Transport endpoint issue when doing sudo systemctl status systemd-journald previously but now it works

pgmclean commented 1 year ago

Great to hear mlaughan that the fix helped. I'm pretty sure that systemd was consuming too many resources logging acpi events when running on WSL.

pgmclean commented 1 year ago

Great to hear mlaughan that the fix helped. I'm pretty sure that systemd was consuming too many resources logging acpi events when running on WSL.

Get Outlook for Androidhttps://aka.ms/ghei36