Systemd vs sysVinit - Initializing the system

akshay_khoje

Akshay

Posted on December 20, 2023

Systemd vs sysVinit - Initializing the system

Motivation behind this post - my first post here. 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).



Enter fullscreen mode Exit fullscreen mode

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 init and service manager. 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

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.

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

💖 💪 🙅 🚩
akshay_khoje
Akshay

Posted on December 20, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related