one-script-wsl2-systemd icon indicating copy to clipboard operation
one-script-wsl2-systemd copied to clipboard

High load on the cpu

Open haosmos opened this issue 2 years ago • 2 comments

Hi, thanks for your script! 😃 🚀

I installed your script and after that, for some reason, the cpu load increases a lot when running normal commands - it was not like that before I installed the script. I showed it in the video: I opened the search and just moved through the previous commands, - on the right side it says: "loading" and at that moment the cpu load increases.

After that I deleted the script and installed it without GPG4Win and without the custom kernel - but even in this case the load on the CPU when running simple commands increases significantly. That said, otherwise everything seems to work fine. I also added different variants to exceptions for windows defender: wsl.exe, wslhost.exe, ubuntu2004.exe and also added to exceptions folders containing executable wsl files. But still, the cpu load increases significantly.

What could be the reason and do you have any idea how to fix it?

https://user-images.githubusercontent.com/30666874/170988334-e1189ec4-379a-43d0-bbc4-01e6eafcfc2c.mp4

haosmos avatar May 30 '22 12:05 haosmos

If this is specific to the application you're running inside your shell then I need to know what that application is. Do you have a set of steps that I can use to reproduce your issue?

lucyllewy avatar Jun 15 '22 23:06 lucyllewy

I apologize for the long response.

I don't even know how to help you reproduce my problem)

I did not use any special applications.

Maybe it has something to do with the fact that earlier i updated ubuntu to version 22.04 with this command: sudo do-release-upgrade -d?

Maybe the problem was that I was using colorls, which is written in ruby.

While solving this problem i came across this post:

chrome_Rhr7sxrWdJ

and tried to install ubuntu 22.04 and activate systemd in the normal way.

I installed ubuntu 22.04 (from scratch, from the microsoft store) and specified this setting in the wsl.conf file:

[boot]
command="/usr/libexec/wsl-systemd"

And after that, systemd seems to work: I can run docker, manage services via systemctl and install snap packages. I don't know why it works)) 😃

171034174-b617e4b0-bdc4-4d18-bb03-967cda2738cd

I have accessed the services via systemctl and can manage them:

171019115-b62c8f1a-1bbd-4d26-91e3-48aa5c290eb0

I installed the native Docker for linux on - without Docker Desktop for Windows - so far everything seems to work fine: the docker service runs when the system is aging and I can manage docker with systemctl:

172050830-8d3f33da-8181-4e9c-8522-c4560eeaa7ff

172050856-0c26b190-4dd8-445e-a543-0288b8c68fc4

I also have no problem installing and can run postgres inside wsl and connect to it via phpstorm. I can also manage postgres via systemctl:

172066635-2bdc9ffc-55cb-4e21-9ba6-11e9e596387d

172050803-3614be39-e3b8-436c-87ac-3b9dff74df81

Only 2 services remained unactivated:

171019229-c50e0656-23ae-4d68-9027-05951d6afb92

I solved it this way: I commented out the line in the /etc/fstab file:

#LABEL=cloudimg-rootfs / ext4 discard,errors=remount-ro 0 1

and edited the /usr/lib/systemd/system/systemd-sysusers.service as follows:

[Unit]
Description=Create System Users
Documentation=man:sysusers.d(5) man:systemd-sysusers.service(8)
DefaultDependencies=no
Conflicts=shutdown.target
After=systemd-remount-fs.service
Before=sysinit.target shutdown.target systemd-update-done.service
ConditionNeedsUpdate=/etc

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=systemd-sysusers
TimeoutSec=90

[Service]
LoadCredential=

#Optionally, pick up a root password and shell for the root user from a

#credential passed to the service manager. This is useful for importing this
#LoadCredential=passwd.hashed-password.root
#LoadCredential=passwd.plaintext-password.root
#LoadCredential=passwd.shell.root

Then these services are working:

171034299-3cc46f01-b6c0-40d5-863d-842a807bd316

One important thing: I specified the path to wsl in windows terminal like this:

C:\Program Files\WindowsApps\CanonicalGroupLimited.Ubuntu22.04LTS_2204.0.9.0_x64__79rhkp1fndgsc\ubuntu2204.exe

If you set it like this: wsl.exe -d Ubuntu-22.04, it will not run under systemd for some reason.

It seems to work: I can open folders via explorer.exe . or code .

I can also download and install snap packages:

WindowsTerminal_y6oM9qSpB6

For example, I can run the chromium GUI.

I don't know if this is a good solution, maybe this will cause some problems?

But so far everything is working fine.

Do you know what limitations or disadvantages (problems) there are in this method I used?

And what advantages does your way of activating systemd have? Maybe your method has some advantages?

haosmos avatar Jun 28 '22 12:06 haosmos