TimeLinux1

Thursday, April 21, 2011

Linux: A closer look - 3 - Boot Process

... continued ...

-Linux Boot Process in general:
-when powered on, the bios performs power on self test (post)
-then the master boot rec (mbr) which is the 1st sector of the boot disk is read into memory and executed
-the mbr contains a small 512 byte program that calls the bootloader (eg grub or lilo) from the boot device
-the bootloader then copies itself to a higher memory address to make space for the kernel that will come afterwards.
-the bootloader usually needs to know how the filesystem works but not always true.
-eg: grub needs to know fs but intel's lilo doesnt need to (it relies on disk geometry not fs knowledge)
-the knowledge of disk geometry/fs helps the bootloader locate and load the kernel into memory
-the kernel startup code is written in assembly language and is machine dependent.
-the kernel startup job is to identify hardware, sanity checks, calling C language main procedure to start os etc.
-the C code starts services and writes messages on console.
-this includes loading drivers; modules are loaded as needed (unix preloads most, linux is more on-demand)
-once all h/w is ready, process 0 is started.
-process 0 sets up realtime clock, mounts root fs, creates process 1 (init) and process 2 (page daemon).
-process 1 checks if it is supposed to come up as single user or multi user process (depending on how boot was started by sa)
-in single user mode, process 1 forks a shell process and waits for user input.
-in multi  user mode, process 1 forks another process that runs the rc.d init scripts
-init scripts mount additional fs, start services, runs getty which starts login process on terminals.
-terminal procs are part of /etc/ttys, login procs are part of /bin/login, authentication info is in /etc/passwd
-if the login is ok, the command prompt is displayed in CUI or desktop env is started.
-thereafter the user is on his own...

... continued ...

No comments:

Post a Comment