Friday, September 11, 2015

Boot sequence

POWERON
|
BIOS
|
POST -- POWERON SELF TEST
|
Boot Strap Loader
|
boot Seq order
|
[CDROM]
[FDD]
[USB]
[ZIP Drive]
[Network]
[HDD]
|
MBR(Master Boot Record ) --> 512 bytes
|
BS   :- Boot Sector__________________________________
            |  |    |
          BS(446) Partition
                                Table (64) MAGIC KEY(2)
  |
  BL (BootLoader)
  |
_________________
        | |
LILO or GRUB
LILO :- Linux Loader
GRUB :- Grand Unified Boot Loader
/etc/lilo.conf /etc/grub.conf   -->   /boot/grub/grub.conf
|
the kernel is extracted
|
INIT is known as father of all process INIT (binary) --- PID is 1
|
   /etc/inittab
|
id:5:initdefault: --> /etc/inittab
|
/etc/init/*   config files .
|
      rcS.conf /etc/rc.d/rc.sysinit --> /etc/init.d/function
|
      rc.conf /etc/rc.d/rc which will run all service specified in
/etc/rc.d/rc5.d/*

-------------------------------------------------------------------------------

-: Boot Loader :-


/boot/grub/grub.conf   ---->  /etc/grub.conf

#ls -l /boot/grub/grub.conf
-rw------- 1 root root 652 Aug 11 00:12 /boot/grub/grub.conf

#ls -l /etc/grub.conf
lrwxrwxrwx 1 root root 22 Jun 29 04:14 /etc/grub.conf -> ../boot/grub/grub.conf

----------------->>  Sample file of grub.conf  <<---------------------------

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,2)
#          kernel /vmlinuz-version ro root=/dev/sda4
#          initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=15
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-92.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-17.el6 ro root=/dev/sda2 rhgb quiet
        initrd /initramfs-2.6.32-17.el6.img
title Windows XP
        rootnoverify (hd0,5)
        chainloader +1
           
-------------------------------------------------------------------------------------
If a password is not set on grub.conf  , any person can manually reboot/start
the system & append kernel arguements to go directly to runlevel 1
(or any other runlevel ) & change the root password .


To avoid that one can add passwor dto grub.conf file such that if any one wants to edit
the preexisting grub.conf options , he would have to put the grub password set.

# grub-md5-crypt
provide the passphrase twice & copy in the grub file as

password  --md5   <encrypted_passphrase>


PID(A Proccess ID is given to every proccess by the kernel before executing it.)

After the kernel starts booting , linux loads INIT process.
INIT proccess is the 1st Proccess started by the kernel .(Its PID is always 1)
 which does some system checks, such as verifying the integrity of the file systems,
and starts vital programs needed for the operating system to function properly.
It then inspects the /etc/inittab file to determine the runlevel.

Runlevel :
Runlevels are modes / states in which linux system can be put to .
By default there are 7 runlevels ,from 0 -6 .


# Default runlevel. The runlevels used by RHS are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)


Your system can be directly put to a runlevel by the cmd ,
#init <0-6>

#init 6 //To restart

----------------------------------------------------------------------------------------



To find out machine is running in which current runlevel the command is -
# runlevel
N 3

N --> N  means previous runlevel
3 --> current runlevel








Init process check various different configuration files in /etc/init/












To find which daemons are independent or dependent the command is :--

# chkconfig --list | less   ---> [To list all deamons]

amd             0:off 1:off 2:off 3:off 4:off 5:off 6:off
ypserv         0:off 1:off 2:off 3:off 4:off 5:off 6:off
gpm         0:off 1:off 2:off 3:off 4:off 5:off 6:off
dc_server       0:off 1:off 2:off 3:off 4:off 5:off 6:off
mysqld         0:off 1:off 2:off 3:off 4:off 5:off 6:off
bgpd           0:off 1:off 2:off 3:off 4:off 5:off 6:off
xinetd based services:
echo: off
swat: off
amanda: off
telnet: off
finger: off

# chkconfig --list network   ---> [To list details about one appln daemon]
network             0:off   1:off   2:on    3:on    4:on    5:on    6:off


How daemons can be control ?

chkconfig [--level <levels>] <name> <on|off|reset>

# chkconfig --level 35 gpm on
# chkconfig --level 3 gpm on
# chkconfig --level 3 gpm off
# chkconfig --level 3 gpm reset

# ntsysv  (To manage for current run level)
# ntsysv --level 35

These are permanant entries which takes after the system boots into that runlevel .


To start daemons immediately use following command --
# service <service name> start
# service <service name> stop
# service <service name> restart
# service <service name> status

   For example : -
# service gpm stop
# service gpm start
# service gpm restart
# service gpm status

#/etc/init.d/gpm restart
#/etc/init.d/gpm stop
#/etc/init.d/gpm start
#/etc/init.d/gpm status

To manage service graphically
Note :- Use terminal to run a command

#system-config-services



Note :- Remember above command starts daemons
only on next reboot or if you switch your runlevel
by using e.g init 3 / init 5 command


       

1 comment:

  1. Jammin' Jars Hotel and Casino | Biloxi - JTM Hub
    JAMMIN' JARES 안성 출장안마 Hotel and Casino Biloxi. Hotel & Casino Biloxi. 당진 출장안마 JAMMIN' JARES 태백 출장마사지 Hotel and 광양 출장샵 Casino Biloxi. Biloxi, MS. 양산 출장샵

    ReplyDelete

Linux Tables: Block All Incoming Traffic But Allow SSH

  This is very common scenario. You want to permit access to a remote machine only by SSH. You would like to block all incoming traffic to y...