1. Explain the booting procedure?
In Linux systems
the booting is done in 6 stages.
BIOS
MBR
GRUB
Kernel
Init
Runlevel
BIOS :
BIOS stands for
Basic Input and Output System. Whenever we power on the system , the system
runs self diagnostic checks and
detects all the connected input and out peripherals. This process is called
POST (Power On Self Test). If
any errors found it displays on the screen. Then BIOS locates the booting disk
in the system and locates and
loads the Primary boot loader nothing but MBR (Master Boot Record) into the
memory. So, in simple terms the BIOS
loads the MBR into memory and executes the MBR.
MBR :
MBR stands for
Master Boot Record. It is located in the
1st sector of the bootable disk (it may be /dev/hda
or /dev/sda). The size of the MBR is 512 bytes
and it contains three components.
(i) Primary boot loader information and
its size is 446 bytes.
(ii) Partition table information and its
size is 64 bytes.
(iii) MBR validation check and its size is 2
bytes. Its main purpose is whether the MBR is valid or
not.
The primary boot
loader contains the secondary boot loader nothing but GRUB or
LILO (in old systems).
Then primary boot
loader locates and loads the secondary boot loader into memory.
So, in simple
terms the MBR loads and executes the GRUB boot loader.
GRUB
or LILO :
GRUB stands for
Grand Unified Boot loader. LILO stands for Linux Loader and is used in old
Linux systems. If we have
multiple kernel images installed in our system, we can choose which one to be
executed. GRUB displays a splash
screen, waits for few seconds. If we do not enter anything, it loads the
default kernel image as specified in
the grub configuration file. GRUB has the knowledge of the file system (the old
LILO didn't understand the system).
GRUB configuration file is /boot/grub/grub.conf (/etc/grub.conf is a link to this). This file contains kernel
and initrd images. So, in simple
terms GRUB just loads and executes kernel and initrd images.
Kernel :
Kernel
initialises itself and loads the kernel modules and mounts the root file system
as specified in the "root=" in
grub.conf and then kernel executes the /sbin/init program. Since init was the 1st program to be
executed by Linux kernel,
it has the process ID (PID) of 1. We can
see this id by # ps -ef | grep
init command. initrd stands for initial RAM Disk.
initrd is used by kernel as temporary
file system until kernel is booted and the real root the file system is mounted. It also contains necessary
drivers compiled inside which helps it to access the hard drive partitions and other hardware.
init
level :
In this init
program reads the /etc/inittab file and put
the system into specified run level. init identifies the default run level from /etc/inittab file and we can change the this default run
level whenever we needed. We can
find the default run level by #
grep "initdefault" /etc/inittab command on our system. Normally the
default run level in Linux is
3 in CLI (Command Line Interface) mode and 5 in GUI (Graphical User
Interface) mode.
Run Level Programs :
The following run
levels are available in Linux systems.
0 -----> halt
or shutdown the system
1 -----> Single user mode
2 -----> Multi user without NFS
3 -----> Full multi user mode but no GUI and only
CLI mode
4 -----> Unused
5 -----> Full multi user mode with GUI (X11
system)
6 -----> reboot the system
Whenever we start
the Linux system is booting we can see various services getting started. Those
services are located in different run
levels programs executed from the run level directory as defined by our default
run level. Depending on our default
init level setting, the system will execute the programs from one of the following directories.
Run level 0 -----> /etc/rc.d/rc0.d
Run level 1 -----> /etc/rc.d/rc1.d
Run level 2 -----> /etc/rc.d/rc2.d
Run level 3 -----> /etc/rc.d/rc3.d
Run level 4 -----> /etc/rc.d/rc4.d
Run level 5 -----> /etc/rc.d/rc5.d
Run level 6 -----> /etc/rc.d/rc6.d
The above
directories are also having symbolic links available for those directories
under /etc/rc0.d, /etc/rc1.d, ....etc., So, the
/etc/rc0.d is linked to /etc/rc.d/rc0.d
Booting procedure in RHEL - 7:
Upto kernel the
booting process is same as the above. /boot/grub2/grub.conf is the GRUB configuration file in RHEL - 7. systemd is the initial
process in RHEL - 7 and its process ID
is 1.
linux16
read the root ( / ) file system and then initrd16process will mount the root ( / ) file system in read & write mode and starts the systemdprocess. And the systemd
process will read the /etc/fstab file and mount
all the file systems. Then it reads the file
/etc/systemd/system/default.target file and brings the system into the default run level according to the scripts the
processes will start or stop.
2. How to check the current run level
of the system?
# who -r (to
see the present run level of the system)
3. How to change the default run level?
First open
the /etc/inittab file by #
vim /etc/inittab command and go to last line change the run
level number as we required and then
reboot the system by # init
6 command. After rebooting the
system check the current run
level by #
who -r command.
4. How to start the graphical interface
if the system is in run level 3 now?
# startx (it
changes the run level 3 to
5 and reboots the system)
5. How to troubleshoot if the boot disk
is not available?
(i) First check the hard disk is present
in the system or not. If not present connect the hard disk and restart the system.
(ii) If the hard disk is present, then go
to BIOS and find the location of the
hard disk.
(iii) Check the
boot priority in the BIOS. If boot priority is not the hard disk then change it
to hard disk and restart the system.
(iv) Even though the system is not started
then boot the system with CDROM in single user mode and open the /boot/grub/grub.conf file and see the hard disk name and partition
number. Normally it should be /dev/hda1 (if the hard disk is IDE hard disk) or /dev/sda1 (if the hard disk is
SATA or
SCSI). If the hard disk name and partition
number is different instead of the original then change them and reboot the
system with hard
disk.
(v)If the GRUB
is corrupted then reboot the system with CDROM in single user mode and
restore the grub information from the recent
backup and then restart the system with hard disk.
6. How to reboot the production server?
(i) In general the production servers
will not be rebooted frequently because the end users will suffer if the productions
server are in down state. If any changes made to the system like grub, selinux
policy, default run level
is changed and if kernel patches are applied the system reboot is required.
(ii) If any inconsistency is root ( / )
file system, then take the business approval from higher authorities,make a plan
for proper scheduleand also inform to the different teams like application team
to stop the application, databaseteam to stop the
databases, QC team to stop the testing,
monitoring people to ignore the alerts from thisserver and other teams
if any and then reboot the system
withCDROM in single user mode and then
run #fsck command on that file
system.
(iii) If
O/S disk is corrupted or
damaged then, reboot the system temporarily with the mirror disk then fix
that problem
and again boot the system with original disk.
7. What is the difference between # reboot
and # init 6 commands?
Both commands are
used to restart or reboot
the system.
# reboot command will not send the kill signals to
the system and it will kill all the running processes and services forcefully and then restart the system.
# init 6 command will send the kill signals to the
system and it will stop all the processes
and services one by one and then restart the system.
8. What is console port and how to
connect to the console port?
Console port is
used to connect the system even though the system is not booted with the
main O/S. This port is used to connect the system for
troubleshooting purpose only. We can
connect the console port as same as connect
to systems LAN port and it is also having IP address, user name and password to
connect to the console.
There are different
types of console ports for different types of servers. They are given below.
Server Name
|
Name of the Console port
|
Expansion name
|
DELL
|
DRAC or i-DRAC
|
DRAC ---> DELL
Remote Access Controllers
i-DRAC ---> Integrated
DELL Remote Access
Controllers
|
IBM Power series
|
HMC
|
Hardware Management Console
|
HP
|
ILO
|
Integrated Light Out
|
9. System is continuously rebooting.
How to troubleshoot it?
(i) Connect the system through console
port through putty by providing IP
address, user name and password. (ii) At console prompt and boot with CDROM in single
user mode and mount the root ( /
---> O/S) file system on temporary mount point.
(iii) Check any wrong entries in the cron
jobs ie., crontab editor see any reboot scripts are there or not. If found remove
those entries and reboot the system.
(iv) If the above is not resolved, then
check the memory (RAM).
(v) If
RAM module is not working the system get panic and it may continuously
reboots.
(vi) If the RAM module is working then
check the RAM size whether the sufficient RAM that requires to run the application is available or not. If not there
then increasing the RAM size may be resolve this issue.
(vii) Check "/var/log/messages" file for any messages regarding continuous
rebooting.
(viii) Even
though there is a sufficient RAM may be
swap space is not sufficient to run all the services and applications
then system get panic and may continuously reboots. If so, then increasing the
swap size may resolve this issue.
10. What is TCP handshaking?
The procedure that takes place between two
TCP/IP nodes to establish a connection. Known as the Synchronization, Synchronize-Acknowledgement and Acknowledgement
handshake.
For
example if computer A transmits a Synchronize packet to computer B, which sends
back a Synchronize- Acknowledge packet
to compute A. Computer A then transmits an Acknowledge packet to computer B and the connection
is established. This whole above said process is called the TCP handshaking.
11. How many
links will be created when we create the directory?
Whenever
we create any directory there are two links will be created.
12. What are
the differences between run level 2 and
run level 3?
Run Level 2 :
(i) It supports multiuser operations.
(ii) Multiple users can access the system.
(iii) All the system deamons will run
except NFS and some other network service related
deamons.
(iv) So, without NFS we
can use all other services.
Run Level 3 :
(i) It is also supports Multi user
operations.
(ii) Multiple users can access the system.
(iii) All the system deamons including
NFS and other network related
service deamons will run.
(iv)
So, we can avail all the services including
NFS also.
13. Server
running in single user mode, can you login remotely and how?
We
can login to the system remotely in single user mode also but it is possible to
connect to console instead of LAN
port through putty tool by giving IP address, user name and password. Then
console port appears and boot the system
with CDROM in single user mode.
14. How
to check the present kernel version?
# uname -r (it displays the present kernel
version)
# uname -a (it
displays the present kernel version with other details)
# cat /boot/grub/grub.conf (in this file also we can find the kernel version)
15. What
is the command to see the system architecture?
# arch or # uname -m (both
commands gives the architecture of the system)
16. How
to check the version of the O/S ?
# cat /etc/redhat-release (gives the version of the O/S)
17. How
to repair the corrupted boot loader and recover it?
This problems may be occur if the GRUB is corrupted. So, we have to
recover the GRUB. Basically the repairing of
GRUB means installing the new grub on the existing one from RHEL - 6 DVD. The
steps are given below.
(i) Insert the RHEL - 6 DVD and make sure that system should
boot from CD/DVD.
(ii) Boot the system in Rescue Installed System mode.
(iii) Select the language with which we want to continue and
click on OK.
(iv) Select the Keyboard type as US and
click OK.
(v) Select Local
CD/DVD and click OK.
(vi) Move the cursor to NO to ignore the Networking.
(vii) Move the cursor to Continue tab
to mount the root ( / ) from
CD/DVD and press Enter key.
(viii) Now the root ( / ) file
system is mounted on /mnt/sysimage,
here click on OK and Press Enter to continue.
(ix) Select the
"shell Start shell"
option and click on OK, then shell will be displayed on screen.
(xi) At shell prompt
type as # chroot /mnt/sysimage command,
press Enter.
(xii) Check the /boot
partition by # fdisk
-l command.
(xiii) Install the new grub on
the boot device ie., may be /dev/sda2
by # grub-install command (For example
# grub-install /dev/sda2).
(xiv) If it show no error
reported that means we have successfully recovered the grub.
(xv) Then type #
exit command and again type # exit or # reboot command
to reboot the system.
18. What
are Modules or Kernel Modules? How to find the Kernel
Modules?
The drivers is Linux system are
known as Modules or Kernel Modules. These modules are assigned by
kernel depending on the hardware.
Hardware can only be communicated and can work efficiently when the proper module is loaded in the kernel. we
can find the kernel modules by # ls
/etc/lib/modules command.
All the kernel modules in the
system will be ended with " .ko " extension. So, we can see all the modules in
the system by # find
/ -name *.ko
command.
19. What
other commands related to kernel modules?
# lsmod (to
list all the currently loaded modules)
# lsmod |grep
-i (to check whether the
particular module is loaded or not)
# lsmod |grep
-i fat (to check
the fat module is loaded or not)
There might be a situation where
our module is not working properly, in that case we have to remove that module and re-install it again by,
# modprobe -r
(to
remove the specified module)
# modprobe -r
fat (to
remove the fat module)
# modprobe (to install or
re-install the module)
# modprobe fat (to
install or re-install the module)
# modinfo (to
see the specified module information)
# uname (to
see the which O/S is present in the
system)
# uname -s (to
see which O/S kernel is this either Linux or Unix)
# rpm -qa
kernel --last (to
see the kernel installation date and time)
# rpm -qa
kernel* (to
see how many kernels are there in the system)
# ls /proc (to
see the kernel processes information)
# ls /boot (to
see the present kernel version created time) # ls /etc/lib/modules (installed
kernel module drivers)
# ls /usr/src (kernel
source code location)
# kudzu (to
scan the new hardware in RHEL - 4)
# depmod (to
scan the new hardware from RHEL - 5, 6 and 7)
# rmmod (to
remove the specified module)
# insmod (to
install the kernel module without dependency modules)
20. How
to see the run level?
#
who -r (to see the current run level)
21. How
to block the USB / CDROM driver?
# lsmod |grep
-i usb (to see the
USB module is loaded or not)
# mount (to
check the USB is mounted or not)
# modprobe -r
usb_storage (remove
the USB module, if it is mounted it will not remove)
# umount / (to
unmount the USB if it is mounted)
# vim /etc/modprobe.d/blocklist.conf (it will open the
blocklist.conf file, then put an entry of USB)
blocklist usb_storage (after type this
save and exit this file)
22. What
is " wait " and where it is stored?
(i) If there is not enough memory to run
the process, then it will wait for free space in memory. That process is called wait.
(ii) wait is stored in buffer like cache memory.
23. What
is run level?
(i) Run level is nothing but to put the system in different
levels to perform different maintenance modes.
(ii) There are 7 run
levels. Those are 0, 1,
2, 3, 4,
5 and 6.
(iii)
The above levels are used to put the system in different stages to avail
different services.
24. What
is the default run level?
(i) When we boot the server the system
automatically go to one particular run level. That run level is called the default
run level.
(ii) In Linux the default run level
is 5 in GUI
and 3 in CLI.
(iii)
We can modify the default run level by put an entry in /etc/inittab file.
25. Which
run level are you using?
Run
level 3.
26. How
to change the run level temporarily?
#
init (to
change the run level temporarily)
Example : #
init 0 or init 1
or init 2 or
init 3 or init 4
or init 5 or
init 6
27. Can
I mount on two disks alternatively when booting?
No
it is not possible to mount on two disks alternatively when booting because we
can specify only one disk as boot
disk but not two disks as booting disks in BIOS settings.
So,
it is not possible to mount on two disks alternatively when booting.
No comments:
Post a Comment