Wednesday, 13 July 2016

Linux OS initialization systems

The initialization system is basically the part of the OS which controls how the various services managed by the OS kernel startup. Linux essentially offers three init systems which are:

·         SystemVinit
·         Upstart
·         Systemd

This article briefly describes these systems.

SystemVinit:

It manages service management & startup with implementation of the concept of run levels wherein a certain set of services are operational at a certain operational level.
The following run levels are used in CentOS/SuSe/RedHat:

1.       Run level 0 (halt)
2.       Run level 1 (single user mode)
3.       Run level 2 (Multi user mode)
4.       Run level 3 (Multi user mode with n/w enabled)
5.       Run level 4 (unused)
6.       Run level 5 (Multi user mode with n/w & GUI enabled)
7.       Run level 6 (reboot)

In case of Debian based Linux distributions the run level 2 is somewhat analogous to run level 5 for CentOS & run levels 3,4 & 5 are clones of run level 2.To change a run level you can use telinit/init followed by the run level number. For example, to reboot the system type telinit 6 or init 6.
To change the default run level of a system modify the initdefault entry in /etc/inittab file.


Upstart:

Termed as a successor to SystemVinit. It provides a faster boot time as compared to SytemVinit by not relying on the startup/shutdown scripts in /etc/rc#.d directories for service startup. It ensured a more parallel service startup in a way that dependent services followed a dependency tree but services with no dependencies could start up quicker in a parallel fashion.

Systemd:

This is a more efficient, faster & complex init system which has been used in CentOS 7. It replaces run levels & correlates them with something called boot targets. For example run level 3 corresponds to multi-user.target & run level 6 corresponds to reboot.target. For further exploration on boot targets one should look around in /etc/systemd/system & /usr/lib/system/system. Systemd uses the systemctl tool for management of boot targets.

To change to graphical boot target we’d type:
#systemctl isolate graphical.target

To check the default boot target:
#systemctl get-default

To change the default boot target:
#systemctl set-default <target name>

The commands telinit & init still work in CentOS 7 with its systemd implementation but they’ve been re-written in such a way that they actually implement systemctl commands at the backend. So just because init command works in CentOS 7 does not mean that its using SystemVinit.

No comments:

Post a Comment

Using capture groups in grep in Linux

Introduction Let me start by saying that this article isn't about capture groups in grep per se. What we are going to do here with gr...