Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the first process a typical Linux kernel starts?

I searched on the internet for which is the first process which gets executed upon system startup.

I found two answers which are init and sched. What is it really?

Which gets executed first? sched process or init process?

like image 322
Hardik Avatar asked Feb 06 '14 20:02

Hardik


People also ask

What is the name of the first process created in Linux?

What is the name of first process created in Linux? Init process is the mother (parent) of all processes on the system, it’s the first program that is executed when the Linux system boots up; it manages all other processes on the system. It is started by the kernel itself, so in principle it does not have a parent process.

What is kernel initialization in Linux boot?

Thus, the kernel initializes devices, mounts the root filesystem specified by the boot loader as read only, and runs Init ( /sbin/init ) which is designated as the first process run by the system (PID = 1). What is kernel initialization in Linux? After GRUB has loaded the kernel into RAM it turns over execution to the kernel.

What is the process ID of init in Linux kernel?

Since init was the 1st program to be executed by Linux Kernel, it has the process id (PID) of 1. Do a ‘ps -ef | grep init’ and check the pid.

What are the stages of a typical Linux boot process?

The following are the 6 high level stages of a typical Linux boot process. 1. BIOS Searches, loads, and executes the boot loader program. It looks for boot loader in floppy, cd-rom, or hard drive. You can press a key (typically F12 of F2, but it depends on your system) during the BIOS startup to change the boot sequence.


1 Answers

Typically it is the init process, the path of which is hard coded into the kernel itself. init performs very low level functions like starting upstart in the case of Ubuntu (prior to 15.40) or systemd in the case of Ubuntu 15.04 and later, Arch, Fedora, and others, which load the remaining processes and setup. Note that the system is not done booting when init runs - that is a common misconception. In fact, init sets up your login screen and other related tasks. Here's a WikiPedia page on init: https://en.wikipedia.org/wiki/Linux_startup_process#SysV_init

Init is the father of all processes. Its primary role is to create processes from a script stored in the file /etc/inittab. This file usually has entries which cause init to spawn gettys on each line that users can log in. It also controls autonomous processes required by any particular system. A run level is a software configuration of the system which allows only a selected group of processes to exist. The processes spawned by init for each of these run levels are defined in the /etc/inittab file.

However, the Linux kernel does start the scheduler but it is not in userspace, which is what most people associate as the home for a process. Also, the Bourne Shell (/bin/sh) can be substituted if the init is missing or cannot be called. You can also in theory substitute it for any executable by using the init=*some path here* Linux kernel boot option.

like image 114
SevenBits Avatar answered Oct 01 '22 14:10

SevenBits