SlideShare a Scribd company logo
1
Kernel, Module and DriverKernel, Module and Driver
ConfigurationConfiguration
AUT LinuxFest 2017AUT LinuxFest 2017
Mahmoud Shiri VaraminiMahmoud Shiri Varamini
shirivaramini@gmail.comshirivaramini@gmail.com
Agenda
• Introduction to Linux kernel
• Compiling Linux kernelCompiling Linux kernel
• Working with grub2 boot loaderWorking with grub2 boot loader
• Manually updating the kernelManually updating the kernel
• Working with kernel modulesWorking with kernel modules
• referencereference
• QuestionsQuestions
3
Introduction to Linux kernelIntroduction to Linux kernel
What Is Kernel?
●
central module of an operating system (OS)
●
the part of the operating system that loads first, and it remains in main memory.
●
can be contrasted with a shell, the outermost part of an operating system that interacts
with user commands.
●
Manage your hardware and system resources
What Dose Kernel?
●
is responsible for memory management, process and task management, and disk
management.
●
connects the system hardware to the application software
Main Parts (1)
System call interface (SCI)
●
A thin layer that provides a method to interact from
●
user space to kernel space
Process Management (PM)
●
Create, destroy processes
●
Communication between different processes (kernel threads)
●
CPU scheduling
Memory Management (MM)
●
Physical to virtual memory management
●
Memory allocation
●
Swapping, from memory to hard disk
Main Parts (2)
Network Stack
●
Implement the network protocols
●
Deliver packets across programs and network interfaces
Device Drivers (DD)
●
Interact with the hardware
●
Extract an abstraction of the device functionalities
Arch
●
Architecture dependent code
Main Parts (I/O PATH)
Virtual File System (VFS)
●
Eports the common file interface
●
Abstract file system functionality from implementation
File Systems
●
Implementation of FS functionality
Buffer Cache
●
A set of functions to manipulate main memory designed for FS
Device Driver
●
Physical Device
●
Where data live
9
Compiling Linux kernelCompiling Linux kernel
Kernel.org
The Linux Kernel Organization is a California Public Benefit Corporation established in
2002 to distribute the Linux kernel and other Open Source software to the public without
charge.
Should We Compile Kernel?
you don’t need to compile the kernel, as it is installed by default when you install the OS.
Also, when there is a critical update done to the kernel, you can use yum, or apt-get to
update the kernel on your Linux system.
●
To enable experimental features that are not part of the default kernel.
●
To enable support for a new hardware that is not currently supported by the default
kernel.
●
To debug the kernel
●
Or, just to learn how kernel works, you might want to explore the kernel source code, and
compile it on your own.
Let’s Do It!!!
The first step is to download the latest stable kernel from kernel.org.
# cd /opt/
# wget “https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.10.14.tar.xz”
# tar -xvf linux-4.10.14.tar.xz
The kernel contains nearly 3000 configuration options. To make the kernel used by most
people on most hardware, the Linux distro like Ubuntu, Fedora, Debian, RedHat, CentOS,
etc, will generally include support for most common hardware. You can take any one of
configuration from the distro, and on top of that you can add your own configuration, or you
can configure the kernel from scratch, or you can use the default config provided by the
kernel.
Let’s Do It!!!
The first step is to download the latest stable kernel from kernel.org.
# cd ./linux-4.10.14
# make menuconfig
The kernel contains nearly 3000 configuration options. To make the kernel used by most
people on most hardware, the Linux distro like Ubuntu, Fedora, Debian, RedHat, CentOS,
etc, will generally include support for most common hardware. You can take any one of
configuration from the distro, and on top of that you can add your own configuration, or you
can configure the kernel from scratch, or you can use the default config provided by the
kernel.
The make menuconfig, will launch a text-based user interface with default configuration
options as shown in the figure. You should have installed “libncurses and libncurses-devel”
packages for this command to work.
Let’s Do It!!!
The first step is to download the latest stable kernel from kernel.org.
# cd ./linux-4.10.14
# make menuconfig
The kernel contains nearly 3000 configuration options. To make the kernel used by most
people on most hardware, the Linux distro like Ubuntu, Fedora, Debian, RedHat, CentOS,
etc, will generally include support for most common hardware. You can take any one of
configuration from the distro, and on top of that you can add your own configuration, or you
can configure the kernel from scratch, or you can use the default config provided by the
kernel.
The make menuconfig, will launch a text-based user interface with default configuration
options as shown in the figure. You should have installed “libncurses and libncurses-devel”
packages for this command to work.
Let’s Do It!!!
Let’s Do It!!!
We will use the default config provided by the kernel. So select “Save” and save the config
in the file name “.config”.
Compile the main kernel:
# make
Compile the kernel modules:
# make modules
Install the kernel modules:
# make modules_install
Let’s Do It!!!
Install the new kernel on the system:
# make install
The make install command will create the following files in the /boot directory.
Vmlinuz-4.10.14 – The actual kernel
System.map-4.10.14 – The symbols exported by the kernel
initrd.img-4.10.14 – initrd image is temporary root file system used during boot process
Config-4.10.14 – The kernel configuration file
The command “make install” will also update the grub.cfg by default. So we don’t need to
manually edit the grub.cfg file.
Let’s Do It!!!
To use the new kernel that you just compiled, reboot the system.
# reboot
Since, in grub.cfg, the new kernel is added as default boot, the system will boot from the
new kernel. Just in case if you have problems with the new kernel, you can select the old
kernel from the grub menu during boot and you can use your system as usual.
Once the system is up, use uname command to verify that the new version of Linux kernel
is installed.
Finally We Did It !!
19
Working with the GRUB 2 BootWorking with the GRUB 2 Boot
LoaderLoader
Boot Process at Glance
System Startup
Runlevel
$ man runlevel
Introduction to GRUB 2 (1)
●
RHEL7,CentOS7,OEL7: GNU GRand Unified Boot loader (GRUB)
version 2 boot loader.
●
GRUB2 allows select an operating system or kernel to be loaded at
system boot time.
●
Also allows the user to pass arguments to the kernel.
Introduction to GRUB 2 (2)
●
reads its configuration /boot/grub2/grub.cfg file on traditional BIOS-basedmachines and
from the /boot/efi/EFI/redhat/grub.cfg file on UEFI machines.
$ less /boot/grub2/grub.cfg
$ chattr +i /boot/grub2/grub.cfg
$ lsattr /boot/grub2/grub.cfg
$ rm /boot/grub2/grub.cfg
Q: Dose work last command ?
●
file contains menu information.
●
grub.cfg generated during installation, or by invoking the /usr/sbin/grub2-mkconfig
utility, and is automatically updated by grubby each time a new kernel is installed.
●
When regenerated manually using grub2-mkconfig, the file is generated according to
the template files located in /etc/grub.d/, and custom settings in the /etc/default/grub
file.
●
Edits of grub.cfg will be lost any time grub2-mkconfig is used to regenerate the file, so
care must be taken to reflect any manual changes in /etc/default/grub as well.
Introduction to GRUB 2 (3)
A sample of GRUB2 bootloader screen!
Introduction to GRUB 2 (3)
less /boot/grub2/grub.cfg
Making Temporary Changes to a GRUB 2
Menu
To change kernel parameters only during a single boot process:
●
Start the system and, on the GRUB 2 boot screen, move the cursor to the menu entry
you want to edit, and press the e key for edit.
●
Move the cursor down to find the kernel command line. The kernel command line starts
with linux on 64-Bit IBM Power Series, linux16 on x86-64 BIOS-based systems, or
linuxefi on UEFI systems.
●
Edit the kernel parameters as required. For example, to run the system in emergency
mode,add the emergency parameter at the end of the linux16 line:
Making Persistent Changes to a GRUB 2
Menu Using the grubby Tool
To find out the file name of the default kernel, enter a command as follows:
To make a persistent change in the kernel designated as the default kernel:
To list all the kernel menu entries:
# grubby –info=ALL
To view the GRUB menu entry for a specific kerne:
$ grubby --info /boot/vmlinuz-3.10.0-229.el7.x86_64
Making Persistent Changes to a GRUB 2
Menu Using the grubby Tool
To add and remove arguments from a kernel's GRUB menu entry:
# grubby --add-args="rhgb quiet" --args=console=ttyS0,115200 --update-kernel
/boot/vmlinuz-3.10.0-229.4.2.el7.x86_64
To change a value in an existing kernel argument, specify the argument again, changing the
value as required. For example, to change the virtual console font size, use a command as
follows:
# grubby --args=vconsole.font=latarcyrheb-sun32 --update-kernel /boot/vmlinuz-3.10.0-
229.4.2.el7.x86_64
See the grubby(8) manual page for more command options.
Customizing the GRUB 2 Configuration File
GRUB 2 allows basic customization of the boot menu to give users control of what actually
appears on the screen.GRUB 2 uses a series of scripts to build the menu; these are located in
the /etc/grub.d/ directory:
header, which loads GRUB 2 settings from the /etc/default/grub file.
users, which reads the superuser password from the user.cfg file. In Red Hat Enterprise Linux
7.0 and 7.1, this file was only created when boot password was defined in the kickstart file
during installation, and it included the defined password in plain text.
linux, which locates kernels in the default partition of Red Hat Enterprise Linux.
os-prober, which builds entries for operating systems found on other partitions.
custom, a template, which can be used to create additional menu entries.
Protecting GRUB 2 with a Password
GRUB 2 offers two types of password protection:
●
Password is required for modifying menu entries but not for booting existing menu entries;
●
Password is required for modifying menu entries and for booting one, several, or all menu
entries.
1.To require password authentication for modifying GRUB 2 entries:
# grub2-setpassword
Following this procedure creates a /boot/grub2/user.cfg file that contains the hash of the
password. The user for this password, root, is defined in the /boot/grub2/grub.cfg file. With
this change, modifying a boot entry during booting requires you to specify the root user name
and your password.
Protecting GRUB 2 with a Password
Setting a password using the grub2-setpassword prevents menu entries from unauthorized
modification but not from unauthorized booting. To also require password for booting an entry,
follow these steps after setting the password with grub2-setpassword:
1. Open the /boot/grub2/grub.cfg file.
2. Find the boot entry that you want to protect with password by searching for lines beginning
with menuentry.
3. Delete the --unrestricted parameter from the menu entry block.
N
●
Note:
If you delete the --unrestricted parameter from every menu entry in the /boot/grub2/grub.cfg
file, all newly installed kernels will have menu entry created without --unrestricted and hence
automatically inherit the password protection.
Reinstalling GRUB 2
Reinstalling GRUB 2 is a convenient way to fix certain problems usually caused by an incorrect
installation of GRUB 2, missing files, or a broken system. Other reasons to reinstall GRUB 2
include the following:
●
Upgrading from the previous version of GRUB.
●
The user requires the GRUB 2 boot loader to control installed operating systems. However,
some operating systems are installed with their own boot loaders. Reinstalling GRUB 2
returns control to the desired operating system.
●
Adding the boot information to another drive.
Use the grub2-install device command to reinstall GRUB 2 if the system is operating normally.
# grub2-install /dev/sda
Terminal Menu Editing During Boot
Menu entries can be modified and arguments passed to the kernel on boot. This is done using
the menu entry editor interface:
●
Booting to Rescue Mode
●
Booting to Emergency Mode
●
Booting to the Debug Shell
Booting to Rescue Mode:Rescue mode provides a convenient single-user environment and
allows you to repair your system in situations when it is unable to complete a normal booting
process. In rescue mode, the system attempts to mount all local file systems and start some
important system services, but it does not activate network interfaces or allow more users to be
logged into the system at the same time. In Red Hat Enterprise Linux 7, rescue mode is
equivalent to single user mode and requires the root password.
Terminal Menu Editing During Boot
Booting to Emergency Mode:Emergency mode provides the most minimal environment
possible and allows you to repair your system even in situations when the system is unable to
enter rescue mode. In emergency mode, the system mounts the root file system only for
reading, does not attempt to mount any other local file systems, does not activate network
interfaces, and only starts few essential services. In Red Hat Enterprise Linux 7, emergency
mode requires the root password.
Booting to the Debug Shell:The systemd debug shell provides a shell very early in the startup
process that can be used to diagnose systemd related boot-up problems. Once in the debug
shell, systemctl commands such as systemctl list-jobs, and systemctl list-units can be
used to look for the cause of boot problems. In addition, the debug option can be added to the
kernel command line to increase the number of log messages. For systemd, the kernel
command-line option debug is now a shortcut for systemd.log_level=debug.
36
Manually Upgrading the KernelManually Upgrading the Kernel
Overview of Kernel Packages(1)
Linux contains the following kernel packages:
Kernel: Contains the kernel for single-core, multi-core, and multi-processor systems.
Kernel-debug: Contains a kernel with numerous debugging options enabled for kernel
diagnosis, at the expense of reduced performance.
Kernel-devel: Contains the kernel headers and makefiles sufficient to build modules
against the kernel package.
Kernel-debug-devel: Contains the development version of the kernel with numerous
debugging options enabled for kernel diagnosis, at the expense of reduced performance.
Kernel-doc: Documentation files from the kernel source. Various portions of the Linux
kernel and the device drivers shipped with it are documented in these files. Installation of
this package provides a reference to the options that can be passed to Linux kernel
modules at load time.
Overview of Kernel Packages(2)
Kernel-headers: Includes the C header files that specify the interface between the Linux
kernel and user-space libraries and programs. The header files define structures and
constants that are needed for building most standard programs.
Linux-firmware: Contains all of the firmware files that are required by various devices to
operate.
Perf: This package contains the perf tool, which enables performance monitoring of the
Linux kernel.
Kernel-abi-whitelists: Contains information pertaining to the Red Hat Enterprise Linux
kernel ABI, including a lists of kernel symbols that are needed by external Linux kernel
modules and a yum plug-in to aid enforcement.
Kernel-tools: Contains tools for manipulating the Linux kernel and supporting
documentation.
$ rpm -qa | grep kernel-*
$ rpm -qf `which pref`
Verifying the Initial RAM Disk Image
The job of the initial RAM disk image: is to preload the block device modules, such as for
IDE, SCSI orRAID, so that the root file system, on which those modules normally reside,
can then be accessed and mounted.
$ ls -li /dev | less
On Red Hat Enterprise Linux 7 systems, whenever a new kernel is installed using either
the Yum, PackageKit, or RPM package manager, the Dracut utility is always called by the
installation scripts to create an initramfs (initial RAM disk image).
$ man dracut
If you make changes to the kernel attributes by modifying the /etc/sysctl.conf file or
another sysctl configuration file, and if the changed settings are used early in the boot
process, then rebuilding the Initial RAM Disk Image by running the dracut -f command
might be necessary. An example is if you have made changes related to networking and
are booting from network-attached storage.
$ ls -li /boot
Important :in the /boot directory you might find several initramfs-
kernel_versionkdump.img files. These are special files created by the Kdump
mechanism for kernel debugging purposes, are not used to boot the system, and can safely
be ignored.
40
Working with Kernel ModulesWorking with Kernel Modules
dynamically-loaded kernel modules
Linux kernel is modular, which means it can extend its capabilities through the use of
dynamically-loaded kernel modules. A kernel module can provide:
●
a device driver which adds support for new hardware; or,
●
support for a file system such as btrfs or NFS.
Like the kernel itself, modules can take parameters that customize their behavior, though
the default parameters work well in most cases.
“kmod” provides:
●
list the modules currently loaded into a running kernel
●
query all available modules for available parameters and module-specific information;
●
load or unload (remove) modules dynamically into or from a running kernel.
# yum install kmod
# rpm -qi kmod
Listing Currently-Loaded Modules
You can list all kernel modules that are currently loaded into the kernel by running the
lsmod command :
$ lsmod | less
$ man lsmod
Each row of lsmod output specifies:
●
the name of a kernel module currently loaded in memory
●
the amount of memory it uses
●
the sum total of processes that are using the module and other modules which depend
on it,followed by a list of the names of those modules, if there are any.
note that lsmod output is less verbose and considerably easier to read than the content of
the /proc/modules pseudo-file.
$ lsmod | grep nfs
Displaying Information About a Module
You can display detailed information about a kernel module using the modinfo
module_name command
$ modinfo vmnet | less
Note:When entering the name of a kernel module as an argument to one of the kmod
utilities, do not append a .ko extension to the end of the name. Kernel module names do
not have extensions; their corresponding files do
$ man modinfo
# systemctl start firewalld
# lsmod | grep iptable_nat
Loading a Module
To load a kernel module, run modprobe module_name as root.
$ man modprobe
By default, modprobe attempts to load the module from
/lib/modules/kernel_version/kernel/drivers/. In this directory, each type of module has
its own subdirectory, such as net/ and scsi/, for network and SCSI interface drivers
respectively.
You can use the -v (or --verbose) option to cause modprobe to display detailed information
about what it is doing, which can include loading module dependencies.
Important: Although the insmod command can also be used to load kernel modules, it does
not resolve dependencies. Because of this, you should always load modules using
modprobe instead
Unloading a Module
You can unload a kernel module by running modprobe -r module_name as root.
command will fail if a process is using:
●
Module
●
A module that directly depends
●
any module that through the dependency tree, depends on indirectly
modprobe -r -v
Although the rmmod command can be used to unload kernel modules, it is recommended
to use modprobe -r instead.
$ ls -R /lib/modules/`uname -r`/kernel/
46
QuestionQuestion

More Related Content

What's hot

Linux Internals - Kernel/Core
Linux Internals - Kernel/CoreLinux Internals - Kernel/Core
Linux Internals - Kernel/Core
Shay Cohen
 
Linux introduction
Linux introductionLinux introduction
Linux introduction
Md. Zahid Hossain Shoeb
 
Linux Presentation
Linux PresentationLinux Presentation
Linux Presentation
nishantsri
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
Goutam Sahoo
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module Programming
Tushar B Kute
 
Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)
Tushar B Kute
 
Introduction to char device driver
Introduction to char device driverIntroduction to char device driver
Introduction to char device driver
Vandana Salve
 
Linux device drivers
Linux device driversLinux device drivers
Linux device drivers
Abhishek Sagar
 
Linux Internals - Part I
Linux Internals - Part ILinux Internals - Part I
Linux file system
Linux file systemLinux file system
Linux file system
Md. Tanvir Hossain
 
An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to Linux
anandvaidya
 
systemd
systemdsystemd
systemd
nussbauml
 
Linux Crash Dump Capture and Analysis
Linux Crash Dump Capture and AnalysisLinux Crash Dump Capture and Analysis
Linux Crash Dump Capture and Analysis
Paul V. Novarese
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
shimosawa
 
Linux command ppt
Linux command pptLinux command ppt
Linux command ppt
kalyanineve
 
Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot images
Chris Simmonds
 
Linux kernel modules
Linux kernel modulesLinux kernel modules
Linux kernel modules
Eddy Reyes
 
Linux Internals - Part II
Linux Internals - Part IILinux Internals - Part II
Linux Internals - Part II
Emertxe Information Technologies Pvt Ltd
 

What's hot (20)

Linux basics
Linux basicsLinux basics
Linux basics
 
Linux Internals - Kernel/Core
Linux Internals - Kernel/CoreLinux Internals - Kernel/Core
Linux Internals - Kernel/Core
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
Linux introduction
Linux introductionLinux introduction
Linux introduction
 
Linux Presentation
Linux PresentationLinux Presentation
Linux Presentation
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module Programming
 
Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)
 
Introduction to char device driver
Introduction to char device driverIntroduction to char device driver
Introduction to char device driver
 
Linux device drivers
Linux device driversLinux device drivers
Linux device drivers
 
Linux Internals - Part I
Linux Internals - Part ILinux Internals - Part I
Linux Internals - Part I
 
Linux file system
Linux file systemLinux file system
Linux file system
 
An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to Linux
 
systemd
systemdsystemd
systemd
 
Linux Crash Dump Capture and Analysis
Linux Crash Dump Capture and AnalysisLinux Crash Dump Capture and Analysis
Linux Crash Dump Capture and Analysis
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
 
Linux command ppt
Linux command pptLinux command ppt
Linux command ppt
 
Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot images
 
Linux kernel modules
Linux kernel modulesLinux kernel modules
Linux kernel modules
 
Linux Internals - Part II
Linux Internals - Part IILinux Internals - Part II
Linux Internals - Part II
 

Similar to Linux kernel

Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606
Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606
Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606
Eunice Lin
 
linux minimal os tutorial - by shatrix
linux minimal os tutorial - by shatrixlinux minimal os tutorial - by shatrix
linux minimal os tutorial - by shatrixSherif Mousa
 
Building Mini Embedded Linux System for X86 Arch
Building Mini Embedded Linux System for X86 ArchBuilding Mini Embedded Linux System for X86 Arch
Building Mini Embedded Linux System for X86 Arch
Sherif Mousa
 
Building a linux kernel
Building a linux kernelBuilding a linux kernel
Building a linux kernelRaghu nath
 
7-compiling the Linux kerne pdf type is it
7-compiling the Linux kerne pdf type is it7-compiling the Linux kerne pdf type is it
7-compiling the Linux kerne pdf type is it
Behzad Soltaniyan Hemat
 
Linux basics
Linux basics Linux basics
Linux basics
suniljosekerala
 
Linux Kernel Development
Linux Kernel DevelopmentLinux Kernel Development
Linux Kernel Development
Priyank Kapadia
 
Linux basics
Linux basics Linux basics
Linux basics
suniljosekerala
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
Siji Sunny
 
Crafting GNU/Linux distributions for Embedded target from Scratch/Source
Crafting GNU/Linux distributions for Embedded target from Scratch/SourceCrafting GNU/Linux distributions for Embedded target from Scratch/Source
Crafting GNU/Linux distributions for Embedded target from Scratch/Source
Sourabh Singh Tomar
 
Grub and dracut ii
Grub and dracut iiGrub and dracut ii
Grub and dracut ii
plarsen67
 
Linux Booting Process
Linux Booting ProcessLinux Booting Process
Linux Booting Process
Rishabh5121993
 
Linux booting process - Linux System Administration
Linux booting process - Linux System AdministrationLinux booting process - Linux System Administration
Linux booting process - Linux System Administration
Sreenatha Reddy K R
 
6 stages of linux boot process
6 stages of linux boot process6 stages of linux boot process
6 stages of linux boot process
Hari Shankar
 
Crafting GNU/ linux distributions for embedded target using Builroot
Crafting GNU/ linux distributions for embedded target using BuilrootCrafting GNU/ linux distributions for embedded target using Builroot
Crafting GNU/ linux distributions for embedded target using Builroot
Sourabh Singh Tomar
 
Beagleboard xm-setup
Beagleboard xm-setupBeagleboard xm-setup
Beagleboard xm-setup
Premjith Achemveettil
 
Grub2 and troubleshooting_ol7_boot_problems
Grub2 and troubleshooting_ol7_boot_problemsGrub2 and troubleshooting_ol7_boot_problems
Grub2 and troubleshooting_ol7_boot_problems
Tommy Lee
 
Lecture 5 Kernel Development
Lecture 5 Kernel DevelopmentLecture 5 Kernel Development
Lecture 5 Kernel Development
Mohammed Farrag
 

Similar to Linux kernel (20)

101 1.2 boot the system
101 1.2 boot the system101 1.2 boot the system
101 1.2 boot the system
 
Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606
Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606
Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606
 
linux minimal os tutorial - by shatrix
linux minimal os tutorial - by shatrixlinux minimal os tutorial - by shatrix
linux minimal os tutorial - by shatrix
 
RPM (LINUX)
RPM (LINUX)RPM (LINUX)
RPM (LINUX)
 
Building Mini Embedded Linux System for X86 Arch
Building Mini Embedded Linux System for X86 ArchBuilding Mini Embedded Linux System for X86 Arch
Building Mini Embedded Linux System for X86 Arch
 
Building a linux kernel
Building a linux kernelBuilding a linux kernel
Building a linux kernel
 
7-compiling the Linux kerne pdf type is it
7-compiling the Linux kerne pdf type is it7-compiling the Linux kerne pdf type is it
7-compiling the Linux kerne pdf type is it
 
Linux basics
Linux basics Linux basics
Linux basics
 
Linux Kernel Development
Linux Kernel DevelopmentLinux Kernel Development
Linux Kernel Development
 
Linux basics
Linux basics Linux basics
Linux basics
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Crafting GNU/Linux distributions for Embedded target from Scratch/Source
Crafting GNU/Linux distributions for Embedded target from Scratch/SourceCrafting GNU/Linux distributions for Embedded target from Scratch/Source
Crafting GNU/Linux distributions for Embedded target from Scratch/Source
 
Grub and dracut ii
Grub and dracut iiGrub and dracut ii
Grub and dracut ii
 
Linux Booting Process
Linux Booting ProcessLinux Booting Process
Linux Booting Process
 
Linux booting process - Linux System Administration
Linux booting process - Linux System AdministrationLinux booting process - Linux System Administration
Linux booting process - Linux System Administration
 
6 stages of linux boot process
6 stages of linux boot process6 stages of linux boot process
6 stages of linux boot process
 
Crafting GNU/ linux distributions for embedded target using Builroot
Crafting GNU/ linux distributions for embedded target using BuilrootCrafting GNU/ linux distributions for embedded target using Builroot
Crafting GNU/ linux distributions for embedded target using Builroot
 
Beagleboard xm-setup
Beagleboard xm-setupBeagleboard xm-setup
Beagleboard xm-setup
 
Grub2 and troubleshooting_ol7_boot_problems
Grub2 and troubleshooting_ol7_boot_problemsGrub2 and troubleshooting_ol7_boot_problems
Grub2 and troubleshooting_ol7_boot_problems
 
Lecture 5 Kernel Development
Lecture 5 Kernel DevelopmentLecture 5 Kernel Development
Lecture 5 Kernel Development
 

Recently uploaded

Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
Srikant77
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 

Recently uploaded (20)

Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 

Linux kernel

  • 1. 1 Kernel, Module and DriverKernel, Module and Driver ConfigurationConfiguration AUT LinuxFest 2017AUT LinuxFest 2017 Mahmoud Shiri VaraminiMahmoud Shiri Varamini shirivaramini@gmail.comshirivaramini@gmail.com
  • 2. Agenda • Introduction to Linux kernel • Compiling Linux kernelCompiling Linux kernel • Working with grub2 boot loaderWorking with grub2 boot loader • Manually updating the kernelManually updating the kernel • Working with kernel modulesWorking with kernel modules • referencereference • QuestionsQuestions
  • 3. 3 Introduction to Linux kernelIntroduction to Linux kernel
  • 4. What Is Kernel? ● central module of an operating system (OS) ● the part of the operating system that loads first, and it remains in main memory. ● can be contrasted with a shell, the outermost part of an operating system that interacts with user commands. ● Manage your hardware and system resources
  • 5. What Dose Kernel? ● is responsible for memory management, process and task management, and disk management. ● connects the system hardware to the application software
  • 6. Main Parts (1) System call interface (SCI) ● A thin layer that provides a method to interact from ● user space to kernel space Process Management (PM) ● Create, destroy processes ● Communication between different processes (kernel threads) ● CPU scheduling Memory Management (MM) ● Physical to virtual memory management ● Memory allocation ● Swapping, from memory to hard disk
  • 7. Main Parts (2) Network Stack ● Implement the network protocols ● Deliver packets across programs and network interfaces Device Drivers (DD) ● Interact with the hardware ● Extract an abstraction of the device functionalities Arch ● Architecture dependent code
  • 8. Main Parts (I/O PATH) Virtual File System (VFS) ● Eports the common file interface ● Abstract file system functionality from implementation File Systems ● Implementation of FS functionality Buffer Cache ● A set of functions to manipulate main memory designed for FS Device Driver ● Physical Device ● Where data live
  • 10. Kernel.org The Linux Kernel Organization is a California Public Benefit Corporation established in 2002 to distribute the Linux kernel and other Open Source software to the public without charge.
  • 11. Should We Compile Kernel? you don’t need to compile the kernel, as it is installed by default when you install the OS. Also, when there is a critical update done to the kernel, you can use yum, or apt-get to update the kernel on your Linux system. ● To enable experimental features that are not part of the default kernel. ● To enable support for a new hardware that is not currently supported by the default kernel. ● To debug the kernel ● Or, just to learn how kernel works, you might want to explore the kernel source code, and compile it on your own.
  • 12. Let’s Do It!!! The first step is to download the latest stable kernel from kernel.org. # cd /opt/ # wget “https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.10.14.tar.xz” # tar -xvf linux-4.10.14.tar.xz The kernel contains nearly 3000 configuration options. To make the kernel used by most people on most hardware, the Linux distro like Ubuntu, Fedora, Debian, RedHat, CentOS, etc, will generally include support for most common hardware. You can take any one of configuration from the distro, and on top of that you can add your own configuration, or you can configure the kernel from scratch, or you can use the default config provided by the kernel.
  • 13. Let’s Do It!!! The first step is to download the latest stable kernel from kernel.org. # cd ./linux-4.10.14 # make menuconfig The kernel contains nearly 3000 configuration options. To make the kernel used by most people on most hardware, the Linux distro like Ubuntu, Fedora, Debian, RedHat, CentOS, etc, will generally include support for most common hardware. You can take any one of configuration from the distro, and on top of that you can add your own configuration, or you can configure the kernel from scratch, or you can use the default config provided by the kernel. The make menuconfig, will launch a text-based user interface with default configuration options as shown in the figure. You should have installed “libncurses and libncurses-devel” packages for this command to work.
  • 14. Let’s Do It!!! The first step is to download the latest stable kernel from kernel.org. # cd ./linux-4.10.14 # make menuconfig The kernel contains nearly 3000 configuration options. To make the kernel used by most people on most hardware, the Linux distro like Ubuntu, Fedora, Debian, RedHat, CentOS, etc, will generally include support for most common hardware. You can take any one of configuration from the distro, and on top of that you can add your own configuration, or you can configure the kernel from scratch, or you can use the default config provided by the kernel. The make menuconfig, will launch a text-based user interface with default configuration options as shown in the figure. You should have installed “libncurses and libncurses-devel” packages for this command to work.
  • 16. Let’s Do It!!! We will use the default config provided by the kernel. So select “Save” and save the config in the file name “.config”. Compile the main kernel: # make Compile the kernel modules: # make modules Install the kernel modules: # make modules_install
  • 17. Let’s Do It!!! Install the new kernel on the system: # make install The make install command will create the following files in the /boot directory. Vmlinuz-4.10.14 – The actual kernel System.map-4.10.14 – The symbols exported by the kernel initrd.img-4.10.14 – initrd image is temporary root file system used during boot process Config-4.10.14 – The kernel configuration file The command “make install” will also update the grub.cfg by default. So we don’t need to manually edit the grub.cfg file.
  • 18. Let’s Do It!!! To use the new kernel that you just compiled, reboot the system. # reboot Since, in grub.cfg, the new kernel is added as default boot, the system will boot from the new kernel. Just in case if you have problems with the new kernel, you can select the old kernel from the grub menu during boot and you can use your system as usual. Once the system is up, use uname command to verify that the new version of Linux kernel is installed. Finally We Did It !!
  • 19. 19 Working with the GRUB 2 BootWorking with the GRUB 2 Boot LoaderLoader
  • 20. Boot Process at Glance
  • 23. Introduction to GRUB 2 (1) ● RHEL7,CentOS7,OEL7: GNU GRand Unified Boot loader (GRUB) version 2 boot loader. ● GRUB2 allows select an operating system or kernel to be loaded at system boot time. ● Also allows the user to pass arguments to the kernel.
  • 24. Introduction to GRUB 2 (2) ● reads its configuration /boot/grub2/grub.cfg file on traditional BIOS-basedmachines and from the /boot/efi/EFI/redhat/grub.cfg file on UEFI machines. $ less /boot/grub2/grub.cfg $ chattr +i /boot/grub2/grub.cfg $ lsattr /boot/grub2/grub.cfg $ rm /boot/grub2/grub.cfg Q: Dose work last command ? ● file contains menu information. ● grub.cfg generated during installation, or by invoking the /usr/sbin/grub2-mkconfig utility, and is automatically updated by grubby each time a new kernel is installed. ● When regenerated manually using grub2-mkconfig, the file is generated according to the template files located in /etc/grub.d/, and custom settings in the /etc/default/grub file. ● Edits of grub.cfg will be lost any time grub2-mkconfig is used to regenerate the file, so care must be taken to reflect any manual changes in /etc/default/grub as well.
  • 25. Introduction to GRUB 2 (3) A sample of GRUB2 bootloader screen!
  • 26. Introduction to GRUB 2 (3) less /boot/grub2/grub.cfg
  • 27. Making Temporary Changes to a GRUB 2 Menu To change kernel parameters only during a single boot process: ● Start the system and, on the GRUB 2 boot screen, move the cursor to the menu entry you want to edit, and press the e key for edit. ● Move the cursor down to find the kernel command line. The kernel command line starts with linux on 64-Bit IBM Power Series, linux16 on x86-64 BIOS-based systems, or linuxefi on UEFI systems. ● Edit the kernel parameters as required. For example, to run the system in emergency mode,add the emergency parameter at the end of the linux16 line:
  • 28. Making Persistent Changes to a GRUB 2 Menu Using the grubby Tool To find out the file name of the default kernel, enter a command as follows: To make a persistent change in the kernel designated as the default kernel: To list all the kernel menu entries: # grubby –info=ALL To view the GRUB menu entry for a specific kerne: $ grubby --info /boot/vmlinuz-3.10.0-229.el7.x86_64
  • 29. Making Persistent Changes to a GRUB 2 Menu Using the grubby Tool To add and remove arguments from a kernel's GRUB menu entry: # grubby --add-args="rhgb quiet" --args=console=ttyS0,115200 --update-kernel /boot/vmlinuz-3.10.0-229.4.2.el7.x86_64 To change a value in an existing kernel argument, specify the argument again, changing the value as required. For example, to change the virtual console font size, use a command as follows: # grubby --args=vconsole.font=latarcyrheb-sun32 --update-kernel /boot/vmlinuz-3.10.0- 229.4.2.el7.x86_64 See the grubby(8) manual page for more command options.
  • 30. Customizing the GRUB 2 Configuration File GRUB 2 allows basic customization of the boot menu to give users control of what actually appears on the screen.GRUB 2 uses a series of scripts to build the menu; these are located in the /etc/grub.d/ directory: header, which loads GRUB 2 settings from the /etc/default/grub file. users, which reads the superuser password from the user.cfg file. In Red Hat Enterprise Linux 7.0 and 7.1, this file was only created when boot password was defined in the kickstart file during installation, and it included the defined password in plain text. linux, which locates kernels in the default partition of Red Hat Enterprise Linux. os-prober, which builds entries for operating systems found on other partitions. custom, a template, which can be used to create additional menu entries.
  • 31. Protecting GRUB 2 with a Password GRUB 2 offers two types of password protection: ● Password is required for modifying menu entries but not for booting existing menu entries; ● Password is required for modifying menu entries and for booting one, several, or all menu entries. 1.To require password authentication for modifying GRUB 2 entries: # grub2-setpassword Following this procedure creates a /boot/grub2/user.cfg file that contains the hash of the password. The user for this password, root, is defined in the /boot/grub2/grub.cfg file. With this change, modifying a boot entry during booting requires you to specify the root user name and your password.
  • 32. Protecting GRUB 2 with a Password Setting a password using the grub2-setpassword prevents menu entries from unauthorized modification but not from unauthorized booting. To also require password for booting an entry, follow these steps after setting the password with grub2-setpassword: 1. Open the /boot/grub2/grub.cfg file. 2. Find the boot entry that you want to protect with password by searching for lines beginning with menuentry. 3. Delete the --unrestricted parameter from the menu entry block. N ● Note: If you delete the --unrestricted parameter from every menu entry in the /boot/grub2/grub.cfg file, all newly installed kernels will have menu entry created without --unrestricted and hence automatically inherit the password protection.
  • 33. Reinstalling GRUB 2 Reinstalling GRUB 2 is a convenient way to fix certain problems usually caused by an incorrect installation of GRUB 2, missing files, or a broken system. Other reasons to reinstall GRUB 2 include the following: ● Upgrading from the previous version of GRUB. ● The user requires the GRUB 2 boot loader to control installed operating systems. However, some operating systems are installed with their own boot loaders. Reinstalling GRUB 2 returns control to the desired operating system. ● Adding the boot information to another drive. Use the grub2-install device command to reinstall GRUB 2 if the system is operating normally. # grub2-install /dev/sda
  • 34. Terminal Menu Editing During Boot Menu entries can be modified and arguments passed to the kernel on boot. This is done using the menu entry editor interface: ● Booting to Rescue Mode ● Booting to Emergency Mode ● Booting to the Debug Shell Booting to Rescue Mode:Rescue mode provides a convenient single-user environment and allows you to repair your system in situations when it is unable to complete a normal booting process. In rescue mode, the system attempts to mount all local file systems and start some important system services, but it does not activate network interfaces or allow more users to be logged into the system at the same time. In Red Hat Enterprise Linux 7, rescue mode is equivalent to single user mode and requires the root password.
  • 35. Terminal Menu Editing During Boot Booting to Emergency Mode:Emergency mode provides the most minimal environment possible and allows you to repair your system even in situations when the system is unable to enter rescue mode. In emergency mode, the system mounts the root file system only for reading, does not attempt to mount any other local file systems, does not activate network interfaces, and only starts few essential services. In Red Hat Enterprise Linux 7, emergency mode requires the root password. Booting to the Debug Shell:The systemd debug shell provides a shell very early in the startup process that can be used to diagnose systemd related boot-up problems. Once in the debug shell, systemctl commands such as systemctl list-jobs, and systemctl list-units can be used to look for the cause of boot problems. In addition, the debug option can be added to the kernel command line to increase the number of log messages. For systemd, the kernel command-line option debug is now a shortcut for systemd.log_level=debug.
  • 36. 36 Manually Upgrading the KernelManually Upgrading the Kernel
  • 37. Overview of Kernel Packages(1) Linux contains the following kernel packages: Kernel: Contains the kernel for single-core, multi-core, and multi-processor systems. Kernel-debug: Contains a kernel with numerous debugging options enabled for kernel diagnosis, at the expense of reduced performance. Kernel-devel: Contains the kernel headers and makefiles sufficient to build modules against the kernel package. Kernel-debug-devel: Contains the development version of the kernel with numerous debugging options enabled for kernel diagnosis, at the expense of reduced performance. Kernel-doc: Documentation files from the kernel source. Various portions of the Linux kernel and the device drivers shipped with it are documented in these files. Installation of this package provides a reference to the options that can be passed to Linux kernel modules at load time.
  • 38. Overview of Kernel Packages(2) Kernel-headers: Includes the C header files that specify the interface between the Linux kernel and user-space libraries and programs. The header files define structures and constants that are needed for building most standard programs. Linux-firmware: Contains all of the firmware files that are required by various devices to operate. Perf: This package contains the perf tool, which enables performance monitoring of the Linux kernel. Kernel-abi-whitelists: Contains information pertaining to the Red Hat Enterprise Linux kernel ABI, including a lists of kernel symbols that are needed by external Linux kernel modules and a yum plug-in to aid enforcement. Kernel-tools: Contains tools for manipulating the Linux kernel and supporting documentation. $ rpm -qa | grep kernel-* $ rpm -qf `which pref`
  • 39. Verifying the Initial RAM Disk Image The job of the initial RAM disk image: is to preload the block device modules, such as for IDE, SCSI orRAID, so that the root file system, on which those modules normally reside, can then be accessed and mounted. $ ls -li /dev | less On Red Hat Enterprise Linux 7 systems, whenever a new kernel is installed using either the Yum, PackageKit, or RPM package manager, the Dracut utility is always called by the installation scripts to create an initramfs (initial RAM disk image). $ man dracut If you make changes to the kernel attributes by modifying the /etc/sysctl.conf file or another sysctl configuration file, and if the changed settings are used early in the boot process, then rebuilding the Initial RAM Disk Image by running the dracut -f command might be necessary. An example is if you have made changes related to networking and are booting from network-attached storage. $ ls -li /boot Important :in the /boot directory you might find several initramfs- kernel_versionkdump.img files. These are special files created by the Kdump mechanism for kernel debugging purposes, are not used to boot the system, and can safely be ignored.
  • 40. 40 Working with Kernel ModulesWorking with Kernel Modules
  • 41. dynamically-loaded kernel modules Linux kernel is modular, which means it can extend its capabilities through the use of dynamically-loaded kernel modules. A kernel module can provide: ● a device driver which adds support for new hardware; or, ● support for a file system such as btrfs or NFS. Like the kernel itself, modules can take parameters that customize their behavior, though the default parameters work well in most cases. “kmod” provides: ● list the modules currently loaded into a running kernel ● query all available modules for available parameters and module-specific information; ● load or unload (remove) modules dynamically into or from a running kernel. # yum install kmod # rpm -qi kmod
  • 42. Listing Currently-Loaded Modules You can list all kernel modules that are currently loaded into the kernel by running the lsmod command : $ lsmod | less $ man lsmod Each row of lsmod output specifies: ● the name of a kernel module currently loaded in memory ● the amount of memory it uses ● the sum total of processes that are using the module and other modules which depend on it,followed by a list of the names of those modules, if there are any. note that lsmod output is less verbose and considerably easier to read than the content of the /proc/modules pseudo-file. $ lsmod | grep nfs
  • 43. Displaying Information About a Module You can display detailed information about a kernel module using the modinfo module_name command $ modinfo vmnet | less Note:When entering the name of a kernel module as an argument to one of the kmod utilities, do not append a .ko extension to the end of the name. Kernel module names do not have extensions; their corresponding files do $ man modinfo # systemctl start firewalld # lsmod | grep iptable_nat
  • 44. Loading a Module To load a kernel module, run modprobe module_name as root. $ man modprobe By default, modprobe attempts to load the module from /lib/modules/kernel_version/kernel/drivers/. In this directory, each type of module has its own subdirectory, such as net/ and scsi/, for network and SCSI interface drivers respectively. You can use the -v (or --verbose) option to cause modprobe to display detailed information about what it is doing, which can include loading module dependencies. Important: Although the insmod command can also be used to load kernel modules, it does not resolve dependencies. Because of this, you should always load modules using modprobe instead
  • 45. Unloading a Module You can unload a kernel module by running modprobe -r module_name as root. command will fail if a process is using: ● Module ● A module that directly depends ● any module that through the dependency tree, depends on indirectly modprobe -r -v Although the rmmod command can be used to unload kernel modules, it is recommended to use modprobe -r instead. $ ls -R /lib/modules/`uname -r`/kernel/