Systemd vs sysVinit - Initializing the system
Tags: linux, systems, operatingsystem, booting
Published: 2023-12-20 07:02:57

Motivation behind this post - my first post [here](https://dev.to/akshay_khoje/system-has-not-been-booted-with-systemd-as-init-system-pid-1-5e1d). In this post I'll try to explain the system initializer in linux and the difference between `sysVinit` and `systemd`.

# ESSENTIAL BACKGROUND

## What is the `init` process?
To answer this, we need to look a little bit at the booting process.

### **Boot sequence**
The boot process is everything that happens from the time you press the power button until you are presented with a login screen. It generally follows this sequence:
```
1. BIOS/UEFI locates and executes the bootloader (or UEFI can load a kernel directly).
2. Bootloader(e.g. GRUB2 loads the desired kernel into memory).
3. Kernel starts the init process (pid = 1).
4. init process manages overall system initialization : systemd( or sysVinit, upstart, etc).
5. Then the display manager takes over the control (the login screen).

```
---

This post focuses on point #4 of the boot sequence.

The ***init process*** essentially means loading all the services and daemons required by the user after login, to be loaded into the RAM and get the system up and ready.

Now, various system initializers are available - systemd, sysVinit, upstart, openRC, etc. In modern systems - `systemd` is the **default system initializer**, however some distros like MXLinux still prefer sysVinit (an older guy in the game).


### What does systemd do?

The systemd is an <u>**init and service manager**</u>. It is the `first user-level process` that runs until the PC is shutdown. It's process ID id 1.

![pid of systemd is 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5tlqpaeiapyw780k6a07.png)

It does the following tasks:
1. Once kernel starts the init process, systemd handles all the later stages of the boot process.
2. It configures the environment by loading all the services and daemons needed to login the user.
3. It allows managing services, devices, sockets, mount points, swap areas, etc.

Few notes about systemd:
- Starts all services parallely.
- Can start daemons without restarting the running service.
- It is the universal parent of all processes.

---

### What is sysVinit?

**sysVinit** was initially created for UNIX systems, it later got adapted in Linux. Till RHEL5, RedHat used this as its default system initializer. Thereafter, they switched to systemd.

Few notes about sysVinit:
- It loaded services in kind of a synchronous fashion as against parallel in systemd.
- A next service can be loaded only after the current one being loaded is timed out.


*One final question beginners might have is...*

### What is systemctl and how is it related to systemd?

`systemctl` is a command line utility to manage services, get the status of services. 
`systemd` on the other hand is a daemon which keeps running in the background until the machine is shut down. `systemctl` is simply an interface to access the services provided by systemd.

Finally, if you found this topic interesting, I had highly recommend you to check out this [reddit discussion](https://www.reddit.com/r/linuxadmin/comments/zl2m9v/systemd_vs_sysvinit/).

*If you find any mistakes, feel free to comment. Also, if you want to add any points, the comment section is all yours.*