SlideShare a Scribd company logo
Linux Kernel Compilation
from source to running
Muli Ben-Yehuda
mulix@mulix.org
IBM Haifa Research Labs
Linux Kernel Development, TAU Linux Workshop, July 2003 – p.1/9
introduction
In this talk, I will talk about and demonstrate compiling the
Linux kernel. Topics inlcude:
overview of kernel compilation
configuring the kernel
dep, clean and mrproper
make bzImage - build the kernel image
make modules - build the modules
make modules_install and final installation
problem solving
Linux Kernel Development, TAU Linux Workshop, July 2003 – p.2/9
overview
compiling the kernel is composed of three stages:
configuration, building (compiling) and installing
it’s really quite simpler than it appears, and it’s very hard
to cause damage and end with a non booting system
we will go over the steps together, configuring, building
and installing the latest 2.4 kernel (2.4.22-pre5 as I
write this)
Linux Kernel Development, TAU Linux Workshop, July 2003 – p.3/9
configuration
configuring the kernel can be non trivial, since you have
to include support for your hardware for things to work
if you’ve done it before and saved the .config, just do
’make oldconfig’. ’make oldconfig’ will only asked about
new configuration choices and use your old choices for
everything else
otherwise, run ’make menuconfig’ or ’make xconfig’,
and start going through the options, based on your
computer’s hardware
alternatives include ’make defconfig’, for a “default”
configuration, and copying a distribution’s .config for a
configuration that should fit almost everything
Linux Kernel Development, TAU Linux Workshop, July 2003 – p.4/9
dep, clean, and mrproper
after configuring the kernel, you need to do ’make dep’,
in order to generate dependency information and cause
various build magic to occur.
occasionally, you might want or need to clean up the
sources before beginning from scratch. ’make clean’ will
delete object files, ’make mrproper’ will delete everything
except the sources, including your .config! be sure to
save it elsewhere, not in the kernel source directory, as
’make mrproper’ will delete all files matching .config*
neither ’make clean’ nor ’make mrproper’ are needed if
this is the first time compiling the kernel from pristine
sources, only ’make dep’.
Linux Kernel Development, TAU Linux Workshop, July 2003 – p.5/9
make bzImage
Not much to say here, really... ’make bzImage’ will build a
compressed, ready to be installed kernel image.
Alternatives include ’make vmlinux’, which will create a
debuggable (but not runnable) kernel image.
Linux Kernel Development, TAU Linux Workshop, July 2003 – p.6/9
make modules
’make modules’ will built the various components which we
chose to build as modules. Why would we want to build
something as a module?
to save space in the kernel image (for embedded
systems)
for easier debugging of drivers and kernel code
to support new peripherals without requiring a kernel
reboot.
Linux Kernel Development, TAU Linux Workshop, July 2003 – p.7/9
install and make modules_install
’make modules_install’, which must be run as root,
ivileges) will create /lib/modules/‘uname -r‘ and copy the
modules there.
the bzImage file, found at arch/i386/boot/bzImage,
needs to be copied somewhere the boot loader will find
it. The System.map file should be copied along with it,
for debugging later, if necessary.
The boot loader (lilo, grub, else) should be updated to
reflect the old kernel. Never replace a working kernel
with a newly compiled one without verifying that it works
first!
Linux Kernel Development, TAU Linux Workshop, July 2003 – p.8/9
problem solving
So you compiled your first kernel, and it doesn’t work.
Congratulations! you aren’t the first one, and certainly won’t
be the last one.
did you install the bzImage and modules properly? did
you update the boot loader?
if hardware that used to work no longer works, check
the .config for appropriate support
if you compiled your disk drivers as modules, you need
to create an initrd (initial ram disk). Read the
documentation for more information.
enjoy your new kernel!
Linux Kernel Development, TAU Linux Workshop, July 2003 – p.9/9

More Related Content

What's hot

Aloofix
AloofixAloofix
Aloofix
Kevin Johnson
 
Remastering of ubuntu
Remastering of ubuntuRemastering of ubuntu
Remastering of ubuntu
Amit Karpe
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
John Coggeshall
 
Docker techzone
Docker techzoneDocker techzone
Docker techzone
Bjørn Nordlund
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
Jason Shepherd
 
Build Rails applications using Hudson
Build Rails applications using HudsonBuild Rails applications using Hudson
Build Rails applications using Hudson
Yassire Elhani
 
Ftp configuration
Ftp configurationFtp configuration
Ftp configuration
Himanshu Bhardwaj
 
Archlinux dev environment
Archlinux dev environmentArchlinux dev environment
Archlinux dev environment
Luke Luo
 
Sweden11
Sweden11Sweden11
Sweden11
Dru Lavigne
 
Nelf2012
Nelf2012Nelf2012
Nelf2012
Dru Lavigne
 
Tlf2013
Tlf2013Tlf2013
Tlf2013
Dru Lavigne
 
the NML project
the NML projectthe NML project
the NML project
Lei Yang
 
Windows Subsystem for Linux .NET Oxford Dec 2018
Windows Subsystem for Linux .NET Oxford Dec 2018Windows Subsystem for Linux .NET Oxford Dec 2018
Windows Subsystem for Linux .NET Oxford Dec 2018
Stuart Leeks
 
Introduction to telepresence
Introduction to telepresenceIntroduction to telepresence
Introduction to telepresence
Kyohei Mizumoto
 
How to test drive development using Linux
How to test drive development using LinuxHow to test drive development using Linux
How to test drive development using Linux
Craig Dickson
 
Buildstrapping Aloofix
Buildstrapping AloofixBuildstrapping Aloofix
Buildstrapping Aloofix
Kevin Johnson
 
Docker + Arm - Multi-arch builds with Docker `buildx`
Docker + Arm - Multi-arch builds with Docker `buildx`Docker + Arm - Multi-arch builds with Docker `buildx`
Docker + Arm - Multi-arch builds with Docker `buildx`
Elton Stoneman
 
Develop QNAP NAS App by Docker
Develop QNAP NAS App by DockerDevelop QNAP NAS App by Docker
Develop QNAP NAS App by Docker
Terry Chen
 
Introduce to linux
Introduce to linuxIntroduce to linux
Introduce to linux
Shamimul Alam
 
Next in Virtualization Era: Containerization & Docker
Next in Virtualization Era: Containerization & DockerNext in Virtualization Era: Containerization & Docker
Next in Virtualization Era: Containerization & Docker
Alper Kanat
 

What's hot (20)

Aloofix
AloofixAloofix
Aloofix
 
Remastering of ubuntu
Remastering of ubuntuRemastering of ubuntu
Remastering of ubuntu
 
Virtualization for Developers
Virtualization for DevelopersVirtualization for Developers
Virtualization for Developers
 
Docker techzone
Docker techzoneDocker techzone
Docker techzone
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Build Rails applications using Hudson
Build Rails applications using HudsonBuild Rails applications using Hudson
Build Rails applications using Hudson
 
Ftp configuration
Ftp configurationFtp configuration
Ftp configuration
 
Archlinux dev environment
Archlinux dev environmentArchlinux dev environment
Archlinux dev environment
 
Sweden11
Sweden11Sweden11
Sweden11
 
Nelf2012
Nelf2012Nelf2012
Nelf2012
 
Tlf2013
Tlf2013Tlf2013
Tlf2013
 
the NML project
the NML projectthe NML project
the NML project
 
Windows Subsystem for Linux .NET Oxford Dec 2018
Windows Subsystem for Linux .NET Oxford Dec 2018Windows Subsystem for Linux .NET Oxford Dec 2018
Windows Subsystem for Linux .NET Oxford Dec 2018
 
Introduction to telepresence
Introduction to telepresenceIntroduction to telepresence
Introduction to telepresence
 
How to test drive development using Linux
How to test drive development using LinuxHow to test drive development using Linux
How to test drive development using Linux
 
Buildstrapping Aloofix
Buildstrapping AloofixBuildstrapping Aloofix
Buildstrapping Aloofix
 
Docker + Arm - Multi-arch builds with Docker `buildx`
Docker + Arm - Multi-arch builds with Docker `buildx`Docker + Arm - Multi-arch builds with Docker `buildx`
Docker + Arm - Multi-arch builds with Docker `buildx`
 
Develop QNAP NAS App by Docker
Develop QNAP NAS App by DockerDevelop QNAP NAS App by Docker
Develop QNAP NAS App by Docker
 
Introduce to linux
Introduce to linuxIntroduce to linux
Introduce to linux
 
Next in Virtualization Era: Containerization & Docker
Next in Virtualization Era: Containerization & DockerNext in Virtualization Era: Containerization & Docker
Next in Virtualization Era: Containerization & Docker
 

Viewers also liked

Nachos
NachosNachos
Guide
GuideGuide
Linuxconcepts
LinuxconceptsLinuxconcepts
Linuxconcepts
Santosh Khadsare
 
packaging
packagingpackaging
packaging
Eddy Mulyono
 
Linux
LinuxLinux
$ make install
$ make install$ make install
$ make install
Marios Isaakidis
 

Viewers also liked (6)

Nachos
NachosNachos
Nachos
 
Guide
GuideGuide
Guide
 
Linuxconcepts
LinuxconceptsLinuxconcepts
Linuxconcepts
 
packaging
packagingpackaging
packaging
 
Linux
LinuxLinux
Linux
 
$ make install
$ make install$ make install
$ make install
 

Similar to Kernel compilation

Introduction to Linux Kernel Development
Introduction to Linux Kernel DevelopmentIntroduction to Linux Kernel Development
Introduction to Linux Kernel Development
Levente Kurusa
 
Getting Started with Buildroot - Lab
Getting Started with Buildroot - LabGetting Started with Buildroot - Lab
Getting Started with Buildroot - Lab
Trevor Woerner
 
Ansible container
Ansible containerAnsible container
Ansible container
Scott van Kalken
 
Kernel init
Kernel initKernel init
Kernel init
gowell
 
Build your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto projectBuild your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto project
Yen-Chin Lee
 
Linux kernel
Linux kernelLinux kernel
Linux kernel driver tutorial vorlesung
Linux kernel driver tutorial vorlesungLinux kernel driver tutorial vorlesung
Linux kernel driver tutorial vorlesung
dns -
 
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
 
Compiling linux kernel and submit first patch
Compiling linux kernel and submit first patchCompiling linux kernel and submit first patch
Compiling linux kernel and submit first patch
Mayur Patil
 
Ci For The Web 2.0 Guy Or Gal
Ci For The Web 2.0 Guy Or GalCi For The Web 2.0 Guy Or Gal
Ci For The Web 2.0 Guy Or Gal
Chad Woolley
 
Recompile
RecompileRecompile
Recompile
navaleashwini26
 
Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modules
dibyajyotig
 
Linux Kernel Development
Linux Kernel DevelopmentLinux Kernel Development
Linux Kernel Development
Priyank Kapadia
 
hw1a
hw1ahw1a
hw1a
hw1ahw1a
Kernel Recipes 2013 - Easy rootfs using Buildroot
Kernel Recipes 2013 - Easy rootfs using BuildrootKernel Recipes 2013 - Easy rootfs using Buildroot
Kernel Recipes 2013 - Easy rootfs using Buildroot
Anne Nicolas
 
BeagleBone Black: Platform Bring-Up with Upstream Components
BeagleBone Black: Platform Bring-Up with Upstream ComponentsBeagleBone Black: Platform Bring-Up with Upstream Components
BeagleBone Black: Platform Bring-Up with Upstream Components
GlobalLogic Ukraine
 
Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606
Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606
Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606
Eunice Lin
 
L lpic2201-pdf
L lpic2201-pdfL lpic2201-pdf
L lpic2201-pdf
G&P
 
Howtoinstallarchlinuxtousb final-120610172253-phpapp01
Howtoinstallarchlinuxtousb final-120610172253-phpapp01Howtoinstallarchlinuxtousb final-120610172253-phpapp01
Howtoinstallarchlinuxtousb final-120610172253-phpapp01
decenttr
 

Similar to Kernel compilation (20)

Introduction to Linux Kernel Development
Introduction to Linux Kernel DevelopmentIntroduction to Linux Kernel Development
Introduction to Linux Kernel Development
 
Getting Started with Buildroot - Lab
Getting Started with Buildroot - LabGetting Started with Buildroot - Lab
Getting Started with Buildroot - Lab
 
Ansible container
Ansible containerAnsible container
Ansible container
 
Kernel init
Kernel initKernel init
Kernel init
 
Build your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto projectBuild your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto project
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Linux kernel driver tutorial vorlesung
Linux kernel driver tutorial vorlesungLinux kernel driver tutorial vorlesung
Linux kernel driver tutorial vorlesung
 
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
 
Compiling linux kernel and submit first patch
Compiling linux kernel and submit first patchCompiling linux kernel and submit first patch
Compiling linux kernel and submit first patch
 
Ci For The Web 2.0 Guy Or Gal
Ci For The Web 2.0 Guy Or GalCi For The Web 2.0 Guy Or Gal
Ci For The Web 2.0 Guy Or Gal
 
Recompile
RecompileRecompile
Recompile
 
Introduction To Linux Kernel Modules
Introduction To Linux Kernel ModulesIntroduction To Linux Kernel Modules
Introduction To Linux Kernel Modules
 
Linux Kernel Development
Linux Kernel DevelopmentLinux Kernel Development
Linux Kernel Development
 
hw1a
hw1ahw1a
hw1a
 
hw1a
hw1ahw1a
hw1a
 
Kernel Recipes 2013 - Easy rootfs using Buildroot
Kernel Recipes 2013 - Easy rootfs using BuildrootKernel Recipes 2013 - Easy rootfs using Buildroot
Kernel Recipes 2013 - Easy rootfs using Buildroot
 
BeagleBone Black: Platform Bring-Up with Upstream Components
BeagleBone Black: Platform Bring-Up with Upstream ComponentsBeagleBone Black: Platform Bring-Up with Upstream Components
BeagleBone Black: Platform Bring-Up with Upstream Components
 
Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606
Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606
Ubuntu初體驗:脫離邪惡微軟帝國吧!_150606
 
L lpic2201-pdf
L lpic2201-pdfL lpic2201-pdf
L lpic2201-pdf
 
Howtoinstallarchlinuxtousb final-120610172253-phpapp01
Howtoinstallarchlinuxtousb final-120610172253-phpapp01Howtoinstallarchlinuxtousb final-120610172253-phpapp01
Howtoinstallarchlinuxtousb final-120610172253-phpapp01
 

More from Ganesh Chavan

rao-vlsi-comm-09 (1).ppt
rao-vlsi-comm-09 (1).pptrao-vlsi-comm-09 (1).ppt
rao-vlsi-comm-09 (1).ppt
Ganesh Chavan
 
wap01.ppt
wap01.pptwap01.ppt
wap01.ppt
Ganesh Chavan
 
AJAX.pptx
AJAX.pptxAJAX.pptx
AJAX.pptx
Ganesh Chavan
 
crypto.ppt
crypto.pptcrypto.ppt
crypto.ppt
Ganesh Chavan
 
exp 3.docx
exp 3.docxexp 3.docx
exp 3.docx
Ganesh Chavan
 
Lecture02 types
Lecture02 typesLecture02 types
Lecture02 types
Ganesh Chavan
 
Project00
Project00Project00
Project00
Ganesh Chavan
 

More from Ganesh Chavan (7)

rao-vlsi-comm-09 (1).ppt
rao-vlsi-comm-09 (1).pptrao-vlsi-comm-09 (1).ppt
rao-vlsi-comm-09 (1).ppt
 
wap01.ppt
wap01.pptwap01.ppt
wap01.ppt
 
AJAX.pptx
AJAX.pptxAJAX.pptx
AJAX.pptx
 
crypto.ppt
crypto.pptcrypto.ppt
crypto.ppt
 
exp 3.docx
exp 3.docxexp 3.docx
exp 3.docx
 
Lecture02 types
Lecture02 typesLecture02 types
Lecture02 types
 
Project00
Project00Project00
Project00
 

Kernel compilation

  • 1. Linux Kernel Compilation from source to running Muli Ben-Yehuda mulix@mulix.org IBM Haifa Research Labs Linux Kernel Development, TAU Linux Workshop, July 2003 – p.1/9
  • 2. introduction In this talk, I will talk about and demonstrate compiling the Linux kernel. Topics inlcude: overview of kernel compilation configuring the kernel dep, clean and mrproper make bzImage - build the kernel image make modules - build the modules make modules_install and final installation problem solving Linux Kernel Development, TAU Linux Workshop, July 2003 – p.2/9
  • 3. overview compiling the kernel is composed of three stages: configuration, building (compiling) and installing it’s really quite simpler than it appears, and it’s very hard to cause damage and end with a non booting system we will go over the steps together, configuring, building and installing the latest 2.4 kernel (2.4.22-pre5 as I write this) Linux Kernel Development, TAU Linux Workshop, July 2003 – p.3/9
  • 4. configuration configuring the kernel can be non trivial, since you have to include support for your hardware for things to work if you’ve done it before and saved the .config, just do ’make oldconfig’. ’make oldconfig’ will only asked about new configuration choices and use your old choices for everything else otherwise, run ’make menuconfig’ or ’make xconfig’, and start going through the options, based on your computer’s hardware alternatives include ’make defconfig’, for a “default” configuration, and copying a distribution’s .config for a configuration that should fit almost everything Linux Kernel Development, TAU Linux Workshop, July 2003 – p.4/9
  • 5. dep, clean, and mrproper after configuring the kernel, you need to do ’make dep’, in order to generate dependency information and cause various build magic to occur. occasionally, you might want or need to clean up the sources before beginning from scratch. ’make clean’ will delete object files, ’make mrproper’ will delete everything except the sources, including your .config! be sure to save it elsewhere, not in the kernel source directory, as ’make mrproper’ will delete all files matching .config* neither ’make clean’ nor ’make mrproper’ are needed if this is the first time compiling the kernel from pristine sources, only ’make dep’. Linux Kernel Development, TAU Linux Workshop, July 2003 – p.5/9
  • 6. make bzImage Not much to say here, really... ’make bzImage’ will build a compressed, ready to be installed kernel image. Alternatives include ’make vmlinux’, which will create a debuggable (but not runnable) kernel image. Linux Kernel Development, TAU Linux Workshop, July 2003 – p.6/9
  • 7. make modules ’make modules’ will built the various components which we chose to build as modules. Why would we want to build something as a module? to save space in the kernel image (for embedded systems) for easier debugging of drivers and kernel code to support new peripherals without requiring a kernel reboot. Linux Kernel Development, TAU Linux Workshop, July 2003 – p.7/9
  • 8. install and make modules_install ’make modules_install’, which must be run as root, ivileges) will create /lib/modules/‘uname -r‘ and copy the modules there. the bzImage file, found at arch/i386/boot/bzImage, needs to be copied somewhere the boot loader will find it. The System.map file should be copied along with it, for debugging later, if necessary. The boot loader (lilo, grub, else) should be updated to reflect the old kernel. Never replace a working kernel with a newly compiled one without verifying that it works first! Linux Kernel Development, TAU Linux Workshop, July 2003 – p.8/9
  • 9. problem solving So you compiled your first kernel, and it doesn’t work. Congratulations! you aren’t the first one, and certainly won’t be the last one. did you install the bzImage and modules properly? did you update the boot loader? if hardware that used to work no longer works, check the .config for appropriate support if you compiled your disk drivers as modules, you need to create an initrd (initial ram disk). Read the documentation for more information. enjoy your new kernel! Linux Kernel Development, TAU Linux Workshop, July 2003 – p.9/9