Wednesday, September 13, 2023

How to install systemd in WSL linux

 Systemd is officially supported in the wsl from windown 11 onwards. Follow this instruction.

What is systemd?

It is one of the first questions that came up to mind when discussing systemd. To find the answer, we have to first know a bit about the sysvinit. If we forget about systemd and the other similar systems, then it’s safe to say that sysvinit is the first process started by the kernel when you boot up any Linux or Unix computer. This means that all the other processes are their child in one way or the other.


Once the system is successfully booted, the sysvinit process continues to run and waits for special commands like ‘shutdown’, which are used to shut down a Linux system. That means now the task of the sysvinit process is to gracefully shutdown the system. For many years, the sysvinit remained a perfect system to bring up and shutdown Linux-based systems. But as time passed by, the system became slow and inflexible, especially for modern-day computers.


So, in 2010 systemd was proposed to replace the widely used sysvinit system. Both systems have their own advantages but at last, it was decided to use systemd in place of sysvinit system.


Follow the instructions from the official website:

Set the systemd flag set in your WSL distro settings:

Open the file: /etc/wsl.conf in vi/vim editor

If the file does not exist, then create it.

vi /etc/wsl.conf


Add these two lines in it:

[boot]

systemd=true


These two lines can be added anywhere in the existing file. Else in the top if creating a new file.

Save the file.


Go to windows powershell with admin mode then below command:

wsl.exe --shutdown

systemd should be working now.

No comments:

Post a Comment