SlideShare a Scribd company logo
Linux Kernel
  Morteza Noorelahi Alamdari(Ipo)

    Linux kernel history

    Structure

    What we need

    Configuring / Building / Installing / Upgrading

    Customizing
History:
Linux is a clone of the operating system Unix, written from scratch by Linus Torvalds
with assistance from a loosely-knit team of hackers across the Net. It aims towards
POSIX and Single UNIX Specification compliance.
License : GNU General Public License
Although originally developed first for 32-bit x86-based PCs (386 or higher), today
Linux also runs on (at least) the Compaq Alpha AXP, Sun SPARC and UltraSPARC,
Motorola 68000, PowerPC, PowerPC64, ARM, Hitachi SuperH, Cell, IBM S/390,
MIPS, HP PA-RISC, Intel IA-64, DEC VAX, AMD x86-64, AXIS CRIS, Xtensa, Tilera
TILE, AVR32 and Renesas M32R architectures.
Structure:
Basic Linux kernel
What we need:
GCC is a C compiler
Make is a tools that walks the kernel source tree to determine which files need to be compiled.
Binutils is linking and assembling of source files.
Git is version controller [optional]
Getting Kernel source code :

$ wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.6.6.tar.bz2


Or :


$ curl http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.6.6.tar.bz2 -o linux-3.6.6.tar.bz2


Then :
       $ tar -xjzf linux-3.6.6.tar.bz2
       $ cd linux-3.6.6
What is Git?
Git is a free and open source distributed version control system designed to handle
everything from small to very large projects with speed and efficiency.

Redhat:
    # yum install git
Debian:
    # apt-get install git
OpenSuse:
    # zypper install git
Arch:
    # pacman -S git
Simple example about Git:
You can get clone projects via this command:
    $ git clone https://github.com/torvalds/linux.git

Redirect to linux directory:
    $ cd linux

For showing list of logs:
     $ git log

For showing list of versions:
     $ git tags

For getting last update from the git server:
     $ git pull
Simple example about Git:
For pushing changed parts to the git server:
     $ git push


For showing status of project:
     $ git status


For configing git :
     $ git config [--global] user.name “your name”
     $ git config [--global] user.email “your email”
Configuring:
For showing help:
     $ make help


We have several ways for configuring kernel:
     1- For configuring step by step:
          $ make config
     2- For configuring with default config:
          $ make defconfig
     3- For configuring in graphical mode:
          $ make menuconfig/gconfig/xconfig
     4- see `make help` ...


For removing all generated files + config + various backup files:
     $ make mrproper
Building:
For building kernel:
     $ make

Advanced building options:
    $ make -j4
    $ make -j8
    $ make -j

For getting iso file:
     $ make isoimage

For making deb package:
    $ make deb-pkg
For making rpm package:
    $ make rpm-pkg
For making targz file:
    $ make targz-pkg
Installing:
For install any modules that we want:
     # make module_install

Then for installing kernel in your system:
    # make install
Updating:
For updating this version we need to get patch files from the official site:
     $ wget http://kernel.org/patches/patch-3.6.6.7.10.bz

Redirect to the directory of kernel source:
    $ cd linux-3.6.6

And for adding patch in the kernel:
     $ bzip2 -dv patch-3.6.6.7.10.bz | patch -p1

     Or:

     $ bzip2 -dv patch-3.6.6.7.10.bz
     $ cd linux-3.6.6
     $ patch -p1 < ../patch-3.6.6.7.10
Config file:
Sometimes you want to use other distributions config file, Like ubuntu.
You can find config file of ubuntu via live cd!


$ cp /proc/config.gz .
$ gzip -dv config.gz
$ cp config linux-3.6.6/.config

And then you can run `make` command.
Customizing:
Determining the driver:
    Example network driver:
    ls /sys/class/net

    $ basename $(readlink /sys/class/net/eth0/device/driver/module)
    $ r8169 << output
    $ cd linux-3.6.6
    $ fine . -type f -a -name Makefile | grep -i r8169
    $ ./drivers/net/ethernet/realtek/Makefile:obj-$(CONFIG_R8169) += r8169.o
    $ make menuconfig
          => press /
          => type module name: r8169

Now you can enable this module in the kernel.
Basic Linux kernel
Determining the correct module from scratch:
    PCI devices:
        # lspci | grep -i ethernet
        # 13:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B
        PCI Express Gigabit Ethernet controller (rev 06)
        $ cd /sys/bus/pci/devices/
        $ ls
        $
        0000:00:00.0 0000:00:1a.0 0000:00:1c.1 0000:00:1d.0 0000:00:1f.2 0000:12:00.0 0000:ff:00.1
        0000:ff:02.2 0000:00:02.0 0000:00:1b.0 0000:00:1c.2 0000:00:1e.0 0000:00:1f.3 0000:13:00.0
        0000:ff:02.0 0000:ff:02.3 0000:00:16.0 0000:00:1c.0 0000:00:1c.4 0000:00:1f.0 0000:00:1f.6
        0000:ff:00.0 0000:ff:02.1
        $ cd cd 0000:13:00.0/
        $ cat vendor
        $ 0x10ec << output
        $ cat device
        $ 0x8168 << output
        $ cd linux-3.6.6
        $ grep -i 0x10ec include/linux/pci_ids.h
        $ #define PCI_VENDOR_ID_REALTEK                             0x10ec
$ grep -R1 PCI_VENDOR_ID_REALTEK * | less
/0x8168 << search device
Result:
--
drivers/net/ethernet/realtek/r8169.c-static DEFINE_PCI_DEVICE_TABLE(rtl8169_pci_tbl) = {
drivers/net/ethernet/realtek/r8169.c: { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8129), 0, 0, RTL_CFG_0 },
drivers/net/ethernet/realtek/r8169.c: { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8136), 0, 0, RTL_CFG_2 },
drivers/net/ethernet/realtek/r8169.c: { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8167), 0, 0, RTL_CFG_0 },
drivers/net/ethernet/realtek/r8169.c: { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168), 0, 0, RTL_CFG_1 },
drivers/net/ethernet/realtek/r8169.c: { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), 0, 0, RTL_CFG_0 },
drivers/net/ethernet/realtek/r8169.c- { PCI_DEVICE(PCI_VENDOR_ID_DLINK,       0x4300), 0, 0, RTL_CFG_0 },
--


All PCI drivers contain a list of different devices that ther support.
Vendor id matches with device.
Summery:
Here are steps needed in order to find which pci driver can control a specific PCI device:


1.Find the PCI bus ID of the device for which you want to find the driver , using lspci.
2.Go into the /sys/bus/pci/devices/0000:bus_id directory , where bus_id is the PCI bus ID
  found in the previous step.
3.Read the values of the vendor and device file in the PCI device directory.
4.Move back the kernel source tree and look in include/linux/pci_ids.h for the PCI vendor and
  device IDs found in the previous step.
5.Search the kernel source tree for references to those values in drivers . Both the vendor
  and device ID should be in a struct pci_device_id definition.
6.Search the kernel Makefile for the CONFIG_ rule that builds this driver by using find and
  grep: $ find . -type f -a -name Makefile | xargs grep DRIVER_NAME
7.Search in the kernel configuration system for that configuration value and go to the location
  in the menu that it specifies to enable that driver to be built.
References:
Oreilly : Linux Kernel in the nutshell
http://www.wikipedia.org/
https://github.com/torvalds/linux
http://kernel.org/
Thanks for your attention
Ad

More Related Content

What's hot (20)

Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
mukul bhardwaj
 
Linuxdd[1]
Linuxdd[1]Linuxdd[1]
Linuxdd[1]
mcganesh
 
Linux Kernel Programming
Linux Kernel ProgrammingLinux Kernel Programming
Linux Kernel Programming
Nalin Sharma
 
Architecture Of The Linux Kernel
Architecture Of The Linux KernelArchitecture Of The Linux Kernel
Architecture Of The Linux Kernel
guest547d74
 
Introduction to Linux Kernel
Introduction to Linux KernelIntroduction to Linux Kernel
Introduction to Linux Kernel
Stryker King
 
Linux architecture
Linux architectureLinux architecture
Linux architecture
mcganesh
 
Linux introduction
Linux introductionLinux introduction
Linux introduction
Abhishek Khune
 
Linux kernel architecture
Linux kernel architectureLinux kernel architecture
Linux kernel architecture
SHAJANA BASHEER
 
Kernel Configuration and Compilation
Kernel Configuration and CompilationKernel Configuration and Compilation
Kernel Configuration and Compilation
Bud Siddhisena
 
Kernel module programming
Kernel module programmingKernel module programming
Kernel module programming
Vandana Salve
 
Browsing Linux Kernel Source
Browsing Linux Kernel SourceBrowsing Linux Kernel Source
Browsing Linux Kernel Source
Motaz Saad
 
Linux Kernel Development
Linux Kernel DevelopmentLinux Kernel Development
Linux Kernel Development
Priyank Kapadia
 
Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modules
dibyajyotig
 
Linux Kernel I/O Schedulers
Linux Kernel I/O SchedulersLinux Kernel I/O Schedulers
Linux Kernel I/O Schedulers
RajKumar Rampelli
 
Linux kernel architecture
Linux kernel architectureLinux kernel architecture
Linux kernel architecture
Teja Bheemanapally
 
Kernel Module Programming
Kernel Module ProgrammingKernel Module Programming
Kernel Module Programming
Saurabh Bangad
 
linux device driver
linux device driverlinux device driver
linux device driver
Rahul Batra
 
Gnubs-pres-foss-cdac-sem
Gnubs-pres-foss-cdac-semGnubs-pres-foss-cdac-sem
Gnubs-pres-foss-cdac-sem
Sagun Baijal
 
Kernel modules
Kernel modulesKernel modules
Kernel modules
Elmàgic Àlàâ
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device drivers
Alexandre Moreno
 
Linuxdd[1]
Linuxdd[1]Linuxdd[1]
Linuxdd[1]
mcganesh
 
Linux Kernel Programming
Linux Kernel ProgrammingLinux Kernel Programming
Linux Kernel Programming
Nalin Sharma
 
Architecture Of The Linux Kernel
Architecture Of The Linux KernelArchitecture Of The Linux Kernel
Architecture Of The Linux Kernel
guest547d74
 
Introduction to Linux Kernel
Introduction to Linux KernelIntroduction to Linux Kernel
Introduction to Linux Kernel
Stryker King
 
Linux architecture
Linux architectureLinux architecture
Linux architecture
mcganesh
 
Linux kernel architecture
Linux kernel architectureLinux kernel architecture
Linux kernel architecture
SHAJANA BASHEER
 
Kernel Configuration and Compilation
Kernel Configuration and CompilationKernel Configuration and Compilation
Kernel Configuration and Compilation
Bud Siddhisena
 
Kernel module programming
Kernel module programmingKernel module programming
Kernel module programming
Vandana Salve
 
Browsing Linux Kernel Source
Browsing Linux Kernel SourceBrowsing Linux Kernel Source
Browsing Linux Kernel Source
Motaz Saad
 
Linux Kernel Development
Linux Kernel DevelopmentLinux Kernel Development
Linux Kernel Development
Priyank Kapadia
 
Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modules
dibyajyotig
 
Kernel Module Programming
Kernel Module ProgrammingKernel Module Programming
Kernel Module Programming
Saurabh Bangad
 
linux device driver
linux device driverlinux device driver
linux device driver
Rahul Batra
 
Gnubs-pres-foss-cdac-sem
Gnubs-pres-foss-cdac-semGnubs-pres-foss-cdac-sem
Gnubs-pres-foss-cdac-sem
Sagun Baijal
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device drivers
Alexandre Moreno
 

Similar to Basic Linux kernel (20)

DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker Captains
Docker, Inc.
 
Raspberry Pi tutorial
Raspberry Pi tutorialRaspberry Pi tutorial
Raspberry Pi tutorial
艾鍗科技
 
Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !
Dobrica Pavlinušić
 
App container rkt
App container rktApp container rkt
App container rkt
Xiaofeng Guo
 
Investigation report on 64 bit support and some of new features in aosp master
Investigation report on 64 bit support and some of new features in aosp masterInvestigation report on 64 bit support and some of new features in aosp master
Investigation report on 64 bit support and some of new features in aosp master
hidenorly
 
9 creating cent_os 7_mages_for_dpdk_training
9 creating cent_os 7_mages_for_dpdk_training9 creating cent_os 7_mages_for_dpdk_training
9 creating cent_os 7_mages_for_dpdk_training
videos
 
Debugging 2013- Jesper Brouer
Debugging 2013- Jesper BrouerDebugging 2013- Jesper Brouer
Debugging 2013- Jesper Brouer
Mediehuset Ingeniøren Live
 
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Jian-Hong Pan
 
7 hands on
7 hands on7 hands on
7 hands on
videos
 
Crash_Report_Mechanism_In_Tizen
Crash_Report_Mechanism_In_TizenCrash_Report_Mechanism_In_Tizen
Crash_Report_Mechanism_In_Tizen
Lex Yu
 
Systemtap
SystemtapSystemtap
Systemtap
Feng Yu
 
Debug generic process
Debug generic processDebug generic process
Debug generic process
Vipin Varghese
 
Spraykatz installation & basic usage
Spraykatz installation & basic usageSpraykatz installation & basic usage
Spraykatz installation & basic usage
Sylvain Cortes
 
Kernel Recipes 2015 - Kernel dump analysis
Kernel Recipes 2015 - Kernel dump analysisKernel Recipes 2015 - Kernel dump analysis
Kernel Recipes 2015 - Kernel dump analysis
Anne Nicolas
 
C&C Botnet Factory
C&C Botnet FactoryC&C Botnet Factory
C&C Botnet Factory
Nullbyte Security Conference
 
Querying 1.8 billion reddit comments with python
Querying 1.8 billion reddit comments with pythonQuerying 1.8 billion reddit comments with python
Querying 1.8 billion reddit comments with python
Daniel Rodriguez
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
biicode
 
Building
BuildingBuilding
Building
Satpal Parmar
 
Reverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemReverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande Modem
Cyber Security Alliance
 
Intel® RDT Hands-on Lab
Intel® RDT Hands-on LabIntel® RDT Hands-on Lab
Intel® RDT Hands-on Lab
Michelle Holley
 
DCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker CaptainsDCEU 18: Tips and Tricks of the Docker Captains
DCEU 18: Tips and Tricks of the Docker Captains
Docker, Inc.
 
Raspberry Pi tutorial
Raspberry Pi tutorialRaspberry Pi tutorial
Raspberry Pi tutorial
艾鍗科技
 
Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !Linux+sensor+device-tree+shell=IoT !
Linux+sensor+device-tree+shell=IoT !
Dobrica Pavlinušić
 
Investigation report on 64 bit support and some of new features in aosp master
Investigation report on 64 bit support and some of new features in aosp masterInvestigation report on 64 bit support and some of new features in aosp master
Investigation report on 64 bit support and some of new features in aosp master
hidenorly
 
9 creating cent_os 7_mages_for_dpdk_training
9 creating cent_os 7_mages_for_dpdk_training9 creating cent_os 7_mages_for_dpdk_training
9 creating cent_os 7_mages_for_dpdk_training
videos
 
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Jian-Hong Pan
 
7 hands on
7 hands on7 hands on
7 hands on
videos
 
Crash_Report_Mechanism_In_Tizen
Crash_Report_Mechanism_In_TizenCrash_Report_Mechanism_In_Tizen
Crash_Report_Mechanism_In_Tizen
Lex Yu
 
Systemtap
SystemtapSystemtap
Systemtap
Feng Yu
 
Spraykatz installation & basic usage
Spraykatz installation & basic usageSpraykatz installation & basic usage
Spraykatz installation & basic usage
Sylvain Cortes
 
Kernel Recipes 2015 - Kernel dump analysis
Kernel Recipes 2015 - Kernel dump analysisKernel Recipes 2015 - Kernel dump analysis
Kernel Recipes 2015 - Kernel dump analysis
Anne Nicolas
 
Querying 1.8 billion reddit comments with python
Querying 1.8 billion reddit comments with pythonQuerying 1.8 billion reddit comments with python
Querying 1.8 billion reddit comments with python
Daniel Rodriguez
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
biicode
 
Reverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemReverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande Modem
Cyber Security Alliance
 
Intel® RDT Hands-on Lab
Intel® RDT Hands-on LabIntel® RDT Hands-on Lab
Intel® RDT Hands-on Lab
Michelle Holley
 
Ad

Recently uploaded (20)

Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdfBiophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Library Association of Ireland
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
Political History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptxPolitical History of Pala dynasty Pala Rulers NEP.pptx
Political History of Pala dynasty Pala Rulers NEP.pptx
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Marie Boran Special Collections Librarian Hardiman Library, University of Gal...
Library Association of Ireland
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
How to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of saleHow to manage Multiple Warehouses for multiple floors in odoo point of sale
How to manage Multiple Warehouses for multiple floors in odoo point of sale
Celine George
 
Introduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe EngineeringIntroduction to Vibe Coding and Vibe Engineering
Introduction to Vibe Coding and Vibe Engineering
Damian T. Gordon
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Niamh Lucey, Mary Dunne. Health Sciences Libraries Group (LAI). Lighting the ...
Library Association of Ireland
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx2541William_McCollough_DigitalDetox.docx
2541William_McCollough_DigitalDetox.docx
contactwilliamm2546
 
Ad

Basic Linux kernel

  • 1. Linux Kernel Morteza Noorelahi Alamdari(Ipo)
  • 2. Linux kernel history  Structure  What we need  Configuring / Building / Installing / Upgrading  Customizing
  • 3. History: Linux is a clone of the operating system Unix, written from scratch by Linus Torvalds with assistance from a loosely-knit team of hackers across the Net. It aims towards POSIX and Single UNIX Specification compliance. License : GNU General Public License Although originally developed first for 32-bit x86-based PCs (386 or higher), today Linux also runs on (at least) the Compaq Alpha AXP, Sun SPARC and UltraSPARC, Motorola 68000, PowerPC, PowerPC64, ARM, Hitachi SuperH, Cell, IBM S/390, MIPS, HP PA-RISC, Intel IA-64, DEC VAX, AMD x86-64, AXIS CRIS, Xtensa, Tilera TILE, AVR32 and Renesas M32R architectures.
  • 6. What we need: GCC is a C compiler Make is a tools that walks the kernel source tree to determine which files need to be compiled. Binutils is linking and assembling of source files. Git is version controller [optional]
  • 7. Getting Kernel source code : $ wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.6.6.tar.bz2 Or : $ curl http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.6.6.tar.bz2 -o linux-3.6.6.tar.bz2 Then : $ tar -xjzf linux-3.6.6.tar.bz2 $ cd linux-3.6.6
  • 8. What is Git? Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Redhat: # yum install git Debian: # apt-get install git OpenSuse: # zypper install git Arch: # pacman -S git
  • 9. Simple example about Git: You can get clone projects via this command: $ git clone https://github.com/torvalds/linux.git Redirect to linux directory: $ cd linux For showing list of logs: $ git log For showing list of versions: $ git tags For getting last update from the git server: $ git pull
  • 10. Simple example about Git: For pushing changed parts to the git server: $ git push For showing status of project: $ git status For configing git : $ git config [--global] user.name “your name” $ git config [--global] user.email “your email”
  • 11. Configuring: For showing help: $ make help We have several ways for configuring kernel: 1- For configuring step by step: $ make config 2- For configuring with default config: $ make defconfig 3- For configuring in graphical mode: $ make menuconfig/gconfig/xconfig 4- see `make help` ... For removing all generated files + config + various backup files: $ make mrproper
  • 12. Building: For building kernel: $ make Advanced building options: $ make -j4 $ make -j8 $ make -j For getting iso file: $ make isoimage For making deb package: $ make deb-pkg For making rpm package: $ make rpm-pkg For making targz file: $ make targz-pkg
  • 13. Installing: For install any modules that we want: # make module_install Then for installing kernel in your system: # make install
  • 14. Updating: For updating this version we need to get patch files from the official site: $ wget http://kernel.org/patches/patch-3.6.6.7.10.bz Redirect to the directory of kernel source: $ cd linux-3.6.6 And for adding patch in the kernel: $ bzip2 -dv patch-3.6.6.7.10.bz | patch -p1 Or: $ bzip2 -dv patch-3.6.6.7.10.bz $ cd linux-3.6.6 $ patch -p1 < ../patch-3.6.6.7.10
  • 15. Config file: Sometimes you want to use other distributions config file, Like ubuntu. You can find config file of ubuntu via live cd! $ cp /proc/config.gz . $ gzip -dv config.gz $ cp config linux-3.6.6/.config And then you can run `make` command.
  • 16. Customizing: Determining the driver: Example network driver: ls /sys/class/net $ basename $(readlink /sys/class/net/eth0/device/driver/module) $ r8169 << output $ cd linux-3.6.6 $ fine . -type f -a -name Makefile | grep -i r8169 $ ./drivers/net/ethernet/realtek/Makefile:obj-$(CONFIG_R8169) += r8169.o $ make menuconfig => press / => type module name: r8169 Now you can enable this module in the kernel.
  • 18. Determining the correct module from scratch: PCI devices: # lspci | grep -i ethernet # 13:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06) $ cd /sys/bus/pci/devices/ $ ls $ 0000:00:00.0 0000:00:1a.0 0000:00:1c.1 0000:00:1d.0 0000:00:1f.2 0000:12:00.0 0000:ff:00.1 0000:ff:02.2 0000:00:02.0 0000:00:1b.0 0000:00:1c.2 0000:00:1e.0 0000:00:1f.3 0000:13:00.0 0000:ff:02.0 0000:ff:02.3 0000:00:16.0 0000:00:1c.0 0000:00:1c.4 0000:00:1f.0 0000:00:1f.6 0000:ff:00.0 0000:ff:02.1 $ cd cd 0000:13:00.0/ $ cat vendor $ 0x10ec << output $ cat device $ 0x8168 << output $ cd linux-3.6.6 $ grep -i 0x10ec include/linux/pci_ids.h $ #define PCI_VENDOR_ID_REALTEK 0x10ec
  • 19. $ grep -R1 PCI_VENDOR_ID_REALTEK * | less /0x8168 << search device Result: -- drivers/net/ethernet/realtek/r8169.c-static DEFINE_PCI_DEVICE_TABLE(rtl8169_pci_tbl) = { drivers/net/ethernet/realtek/r8169.c: { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8129), 0, 0, RTL_CFG_0 }, drivers/net/ethernet/realtek/r8169.c: { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8136), 0, 0, RTL_CFG_2 }, drivers/net/ethernet/realtek/r8169.c: { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8167), 0, 0, RTL_CFG_0 }, drivers/net/ethernet/realtek/r8169.c: { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8168), 0, 0, RTL_CFG_1 }, drivers/net/ethernet/realtek/r8169.c: { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8169), 0, 0, RTL_CFG_0 }, drivers/net/ethernet/realtek/r8169.c- { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4300), 0, 0, RTL_CFG_0 }, -- All PCI drivers contain a list of different devices that ther support. Vendor id matches with device.
  • 20. Summery: Here are steps needed in order to find which pci driver can control a specific PCI device: 1.Find the PCI bus ID of the device for which you want to find the driver , using lspci. 2.Go into the /sys/bus/pci/devices/0000:bus_id directory , where bus_id is the PCI bus ID found in the previous step. 3.Read the values of the vendor and device file in the PCI device directory. 4.Move back the kernel source tree and look in include/linux/pci_ids.h for the PCI vendor and device IDs found in the previous step. 5.Search the kernel source tree for references to those values in drivers . Both the vendor and device ID should be in a struct pci_device_id definition. 6.Search the kernel Makefile for the CONFIG_ rule that builds this driver by using find and grep: $ find . -type f -a -name Makefile | xargs grep DRIVER_NAME 7.Search in the kernel configuration system for that configuration value and go to the location in the menu that it specifies to enable that driver to be built.
  • 21. References: Oreilly : Linux Kernel in the nutshell http://www.wikipedia.org/ https://github.com/torvalds/linux http://kernel.org/
  • 22. Thanks for your attention