Download presentation
Presentation is loading. Please wait.
Published byMoris Charles Modified over 9 years ago
1
CIS 191 - Lesson 13 Linux Kernel
2
Architecture Dependent Kernel Code Kernel Space Process Management Memory Management Network Stack Virtual File System User Space Device Drivers Kernel 1 Hardware System Call Interface Users Commands & Utilities Shell X / Desktops (multi-user) GNU C Library (glibc) Programs (multi-tasking) Add-ons 1 See “Anatomy of the Linux kernel” by M. Tim Jones at http://www-128.ibm.com/developerworks/linux/library/l-linux-kernel/http://www-128.ibm.com/developerworks/linux/library/l-linux-kernel/ GNU/Linux Operating System Architecture Richard Stallman started the GNU project in 1983 to create a free UNIX- like OS. He Founded the Free Software Foundation in 1985. In 1989 he wrote the first version of the GNU General Public License Linus Torvalds, as a student, initially conceived and assembled the Linux kernel in 1991. The kernel was later re- licensed under the GNU General Public License in 1992. CIS 191 - Lesson 13
3
The Linux Kernel (in /boot) Major Subsystems: System Call Interface mechanism for user space programs to request kernel services. Process Management handles fork, exec, exit, kill, signals, CPU scheduling, etc. Memory Management allocation, usage tracking, paging, etc. Virtual File System open, close, read, write, caching, etc. Architecture Dependent Kernel Code Drivers (in /lib) Design Linux kernel is “monolithic”, not a “microkernel” Dynamic – can load and unload modules on the fly Overtime has become efficient, stable and portable CIS 191 – Lesson 13
4
CIS 191 - Lesson 13 The Linux Kernel Building a New Kernel Obtain and verify kernel source tarball Extract source code Install development tools Configure the kernel options make config or make menuconfig or make xconfig or make gconfig or make oldconfig make clean make bzImage make modules make modules_install make install Steps for building a new kernel
5
CIS 191 - Lesson 13 The Linux Kernel Building a New Kernel Obtain and verify kernel source tarball Extract source code Install development tools Configure the kernel options make config or make menuconfig or make xconfig or make gconfig or make oldconfig make clean make bzImage make modules make modules_install make install must be done as root user
6
CIS 191 - Lesson 13 The Linux Kernel Building a New Kernel Obtain and verify kernel source tarball Extract source code Install development tools Configure the kernel options make config or make menuconfig or make xconfig or make gconfig or make oldconfig make clean make bzImage make modules make modules_install make install cleans up object files created from previous compiles
7
CIS 191 - Lesson 13 The Linux Kernel Building a New Kernel Obtain and verify kernel source tarball Extract source code Install development tools Configure the kernel options make config or make menuconfig or make xconfig or make gconfig or make oldconfig make clean make bzImage make modules make modules_install make install Compile the kernel
8
CIS 191 - Lesson 13 The Linux Kernel Kernel Background Obtain and kernel source code ‒ http://www.kernel.org ‒ Download either: *.tar.bz2 or *.tar.gz files bzip2 or gzip tarballs
9
CIS 191 - Lesson 13 The Linux Kernel Building a New Kernel Obtain and verify kernel source tarball Extract source code Install development tools Configure the kernel options make config or make menuconfig or make xconfig or make gconfig or make oldconfig make clean make bzImage make modules make modules_install make install Compile the loadable kernel modules
10
CIS 191 - Lesson 13 The Linux Kernel Building a New Kernel Obtain and verify kernel source tarball Extract source code Install development tools Configure the kernel options make config or make menuconfig or make xconfig or make gconfig or make oldconfig make clean make bzImage make modules make modules_install make install Install the loadable kernel modules in /lib
11
CIS 191 - Lesson 13 The Linux Kernel Building a New Kernel Obtain and verify kernel source tarball Extract source code Install development tools Configure the kernel options make config or make menuconfig or make xconfig or make gconfig or make oldconfig make clean make bzImage make modules make modules_install make install Copy files to /boot
12
CIS 191 - Lesson 13 http://kernel.org/ Click here
13
CIS 191 - Lesson 13 http://www.kernel.org/pub/ Click here
14
CIS 191 - Lesson 13 http://www.kernel.org/pub/linux/ Click here
15
CIS 191 - Lesson 13 http://www.kernel.org/pub/linux/kernel/ Click here
16
CIS 191 - Lesson 13 Change logs show fixed bugs and any enhancements http://www.kernel.org/pub/linux/kernel/v2.6/
17
CIS 191 - Lesson 13 Complete kernels http://www.kernel.org/pub/linux/kernel/v2.6/
18
CIS 191 - Lesson 13 http://www.kernel.org/pub/linux/kernel/v2.6/ Patches
19
CIS 191 - Lesson 13 http://kernel.org/ The latest (as of the date making this slide) http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.27.8
20
CIS 191 - Lesson 13 http://kernel.org/ Create a tarballs directory in /depot Obtain kernel tarballs and place in this directory
21
CIS 191 - Lesson 13 http://kernel.org/ Many ways to get the tarballs wget command Run level 5, run firefox, and download Download on another system and use Filezilla to transfer to Benji VM
22
CIS 191 - Lesson 13 http://kernel.org/ Using wget to get files from kernel.org
23
CIS 191 - Lesson 13 Getting kernel files to VM Download files to windows and transfer to VM with FileZilla
24
CIS 191 - Lesson 13 http://kernel.org/ [root@benji tarballs]# ls -l total 49408 -rw-r--r-- 1 root root 50384960 Dec 6 13:59 linux-2.6.27.8.tar.bz2 -rw-r--r-- 1 root root 248 Dec 6 13:58 linux-2.6.27.8.tar.bz2.sign -rw-r--r-- 1 root root 125174 Dec 5 14:16 patch-2.6.27.8.bz2 [root@benji tarballs]# Latest kernel source, patch and signature file
25
CIS 191 - Lesson 13 http://kernel.org/ Verify the downloaded source code Obtain the public key from http://www.kernel.org/signature.html And copy it into a new file kernel.pubkey Import the key gpg --import kernel.pubkey View the new key gpg --list-keys Verify gpg --verify linux-2.6.27.8.tar.bz2.sign linux- 2.6.27.8.tar.bz2 Linux Kernel Archive files are signed using OpenPGP. This signature can be used to prove downloaded files originated at the Linux Kernel Archives.
26
CIS 191 - Lesson 13 http://kernel.org/ Lets check we didn't get malicious code
27
CIS 191 - Lesson 13 http://kernel.org/ Public and private keys are used to verify source code is authentic
28
CIS 191 - Lesson 13 http://kernel.org/ Copy the public key to the clipboard
29
CIS 191 - Lesson 13 http://kernel.org/ [root@benji tarballs]# vi kernel.pubkey Edit a new file to place the public key
30
CIS 191 - Lesson 13 http://kernel.org/ Go to Insert mode and paste the key with a right click
31
CIS 191 - Lesson 13 http://kernel.org/ Scroll back to the top and make sure you got the whole public key then save it.
32
CIS 191 - Lesson 13 http://kernel.org/ Import the public key to your key collection
33
CIS 191 - Lesson 13 http://kernel.org/ List your set of keys and verify it was added
34
CIS 191 - Lesson 13 http://kernel.org/ You will get a warning unless you have built a trust path to the Linux Kernel Archives Verification Key The first section shows the verification
35
CIS 191 - Lesson 13 The Linux Kernel Building a New Kernel Obtain and verify kernel source tarball Extract source code Install development tools Configure the kernel options make config or make menuconfig or make xconfig or make gconfig or make oldconfig make clean make bzImage make modules make modules_install make install
36
CIS 191 - Lesson 13 Extract source code Extract the source code from the archive tar -xvjf linux-2.6.27.8.tar.bz2 Use j option for bzip2 compression
37
CIS 191 - Lesson 13 Extracting the kernel source code Extract source code
38
CIS 191 - Lesson 13 Note the new linux-2.6.27.8 directory cd into it Extract source code
39
CIS 191 - Lesson 13 Building the kernel Listing of the new linux-2.6.27.8 directory
40
CIS 191 - Lesson 13 Building the kernel Peek at some C code written by Linus
41
CIS 191 - Lesson 13 The Linux Kernel Building a New Kernel Obtain and verify kernel source tarball Extract source code Install development tools Configure the kernel options make config or make menuconfig or make xconfig or make gconfig or make oldconfig make dep make clean make bzImage make modules make modules_install make install
42
CIS 191 - Lesson 13 http://kernel.org/ Install development tools yum install gcc yum install ncurses-devel GNU C compiler and curses (line drawing characters) library
43
CIS 191 - Lesson 13 Install build tools Install the C compiler
44
CIS 191 - Lesson 13 --> Processing Dependency: libgomp.so.1 for package: gcc --> Processing Dependency: libgcc >= 4.1.2-42.el5 for package: gcc --> Restarting Dependency Resolution with new changes. --> Populating transaction set with selected packages. Please wait. ---> Downloading header for cpp to pack into transaction set. cpp-4.1.2-42.el5.i386.rpm 100% |=========================| 64 kB 00:00 ---> Package cpp.i386 0:4.1.2-42.el5 set to be updated ---> Downloading header for libgcc to pack into transaction set. libgcc-4.1.2-42.el5.i386. 100% |=========================| 60 kB 00:00 ---> Package libgcc.i386 0:4.1.2-42.el5 set to be updated ---> Downloading header for glibc-devel to pack into transaction set. glibc-devel-2.5-24.el5_2. 100% |=========================| 111 kB 00:02 ---> Package glibc-devel.i386 0:2.5-24.el5_2.2 set to be updated ---> Downloading header for libgomp to pack into transaction set. libgomp-4.1.2-42.el5.i386 100% |=========================| 60 kB 00:00 ---> Package libgomp.i386 0:4.1.2-42.el5 set to be updated --> Running transaction check --> Processing Dependency: glibc-headers for package: glibc-devel --> Processing Dependency: glibc = 2.5-24.el5_2.2 for package: glibc-devel --> Processing Dependency: glibc-headers = 2.5-24.el5_2.2 for package: glibc- devel Restarting Dependency Resolution with new changes. --> Populating transaction set with selected packages. Please wait. Install the C compiler (continued) Install build tools
45
CIS 191 - Lesson 13 --> Populating transaction set with selected packages. Please wait. ---> Downloading header for glibc-headers to pack into transaction set. glibc-headers-2.5-24.el5_ 100% |=========================| 144 kB 00:01 ---> Package glibc-headers.i386 0:2.5-24.el5_2.2 set to be updated ---> Downloading header for glibc to pack into transaction set. glibc-2.5-24.el5_2.2.i686 100% |=========================| 146 kB 00:01 ---> Package glibc.i686 0:2.5-24.el5_2.2 set to be updated --> Running transaction check --> Processing Dependency: glibc-common = 2.5-24.el5_2.2 for package: glibc --> Restarting Dependency Resolution with new changes. --> Populating transaction set with selected packages. Please wait. ---> Downloading header for glibc-common to pack into transaction set. glibc-common-2.5-24.el5_2 100% |=========================| 725 kB 00:09 ---> Package glibc-common.i386 0:2.5-24.el5_2.2 set to be updated --> Running transaction check Dependencies Resolved Install the C compiler (continued) Install build tools
46
CIS 191 - Lesson 13 Building the kernel ============================================================================= Package Arch Version Repository Size ============================================================================= Installing: gcc i386 4.1.2-42.el5 base 5.2 M Installing for dependencies: glibc-devel i386 2.5-24.el5_2.2 updates 2.0 M glibc-headers i386 2.5-24.el5_2.2 updates 611 k libgomp i386 4.1.2-42.el5 base 82 k Updating for dependencies: cpp i386 4.1.2-42.el5 base 2.7 M glibc i686 2.5-24.el5_2.2 updates 5.2 M glibc-common i386 2.5-24.el5_2.2 updates 16 M libgcc i386 4.1.2-42.el5 base 93 k Transaction Summary ============================================================================= Install 4 Package(s) Update 4 Package(s) Remove 0 Package(s) Total download size: 32 M Is this ok [y/N]: y Install the C compiler (continued)
47
CIS 191 - Lesson 13 Building the kernel Is this ok [y/N]: y Downloading Packages: (1/8): libgcc-4.1.2-42.el 100% |=========================| 93 kB 00:01 (2/8): glibc-devel-2.5-24 100% |=========================| 2.0 MB 00:20 (3/8): glibc-headers-2.5- 100% |=========================| 611 kB 00:07 (4/8): gcc-4.1.2-42.el5.i 100% |=========================| 5.2 MB 00:51 (5/8): cpp-4.1.2-42.el5.i 100% |=========================| 2.7 MB 00:21 (6/8): glibc-2.5-24.el5_2 100% |=========================| 5.2 MB 01:07 (7/8): glibc-common-2.5-2 100% |=========================| 16 MB 04:40 (8/8): libgomp-4.1.2-42.e 100% |=========================| 82 kB 00:01 Running Transaction Test Finished Transaction Test Transaction Test Succeeded Install the C compiler (continued)
48
CIS 191 - Lesson 13 Building the kernel Running Transaction Updating : libgcc ####################### [ 1/12] Updating : glibc-common ####################### [ 2/12] Updating : glibc ####################### [ 3/12] Installing: glibc-headers ####################### [ 4/12] Installing: glibc-devel ####################### [ 5/12] Updating : cpp ####################### [ 6/12] Installing: libgomp ####################### [ 7/12] Installing: gcc ####################### [ 8/12] Cleanup : libgcc ####################### [ 9/12] Cleanup : cpp ####################### [10/12] Cleanup : glibc ####################### [11/12] Cleanup : glibc-common ####################### [12/12] Installed: gcc.i386 0:4.1.2-42.el5 Dependency Installed: glibc-devel.i386 0:2.5-24.el5_2.2 glibc-headers.i386 0:2.5-24.el5_2.2 libgomp.i386 0:4.1.2-42.el5 Dependency Updated: cpp.i386 0:4.1.2-42.el5 glibc.i686 0:2.5-24.el5_2.2 glibc- common.i386 0:2.5-24.el5_2.2 libgcc.i386 0:4.1.2-42.el5 Complete! [root@benji tarballs]# Install the C compiler (continued)
49
CIS 191 - Lesson 13 Building the kernel Install ncurses-devel for make menu-config tool
50
CIS 191 - Lesson 13 Building the kernel Transaction Summary ============================================================================= Install 1 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 1.6 M Is this ok [y/N]: y Downloading Packages: (1/1): ncurses-devel-5.5- 100% |=========================| 1.6 MB 00:11 Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing: ncurses-devel ######################### [1/1] Installed: ncurses-devel.i386 0:5.5-24.20060715 Complete! [root@benji linux-2.6.27.8]# install ncurses-devel (continued)
51
CIS 191 - Lesson 13 The Linux Kernel Building a New Kernel Obtain and verify kernel source tarball Extract source code Install development tools Configure the kernel options make config or make menuconfig or make xconfig or make gconfig or make oldconfig make dep make clean make bzImage make modules make modules_install make install
52
CIS 191 - Lesson 13 The Linux Kernel Kernel Configuration Option Categories Code maturity level options Loadable module support Processor type and features General setup Memory Technology Devices Plug n Play configuration Block devices Networking options Telephony support ATA/IDE/MFM/RLL support SCSI support I2O device support Network device support Amateur radio support IrDA (infrared) support ISDN subsystem Old CD-ROM drivers (not SCSI, not IDE) Character devices Multimedia devices File systems Console drivers Sound USB support Kernel hacking There are bazillions of options for building the kernel
53
CIS 191 - Lesson 13 The Linux Kernel Kernel Configuration Options make config or make menuconfig or make xconfig or make gconfig or make oldconfig
54
CIS 191 - Lesson 13 make config (and holding down the enter key) Configuring the kernel build
55
CIS 191 - Lesson 13 Configuring the kernel build make config method [root@benji linux-2.6.27.8]# make config HOSTCC scripts/basic/fixdep HOSTCC scripts/basic/docproc HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/kxgettext.o SHIPPED scripts/kconfig/zconf.tab.c SHIPPED scripts/kconfig/lex.zconf.c SHIPPED scripts/kconfig/zconf.hash.c HOSTCC scripts/kconfig/zconf.tab.o HOSTLD scripts/kconfig/conf scripts/kconfig/conf arch/x86/Kconfig # # using defaults found in /boot/config-2.6.18-8.el5 # /boot/config-2.6.18-8.el5:1280:warning: symbol value 'm' invalid for FIXED_PHY /boot/config-2.6.18-8.el5:1532:warning: symbol value 'm' invalid for ISDN /boot/config-2.6.18-8.el5:2612:warning: symbol value 'm' invalid for RTC_INTF_SYSFS /boot/config-2.6.18-8.el5:2613:warning: symbol value 'm' invalid for
56
CIS 191 - Lesson 13 make config (continued) Configuring the kernel build http://simms-teach.com/docs/cis191/cis191esson13-make-config.pdf (and holding down the Enter key to take all the defaults)
57
CIS 191 - Lesson 13 After running make config [root@benji linux-2.6.27.8]# ls -la total 616 drwxrwxr-x 22 root root 4096 Dec 6 18:06. drwxr-xr-x 3 root root 4096 Dec 6 18:01.. drwxrwxr-x 24 root root 4096 Dec 5 12:03 arch drwxrwxr-x 2 root root 4096 Dec 5 12:03 block -rw-r--r-- 1 root root 72417 Dec 6 18:06.config -rw-rw-r-- 1 root root 18693 Dec 5 12:03 COPYING -rw-rw-r-- 1 root root 92899 Dec 5 12:03 CREDITS drwxrwxr-x 3 root root 4096 Dec 5 12:03 crypto drwxrwxr-x 78 root root 12288 Dec 5 12:03 Documentation drwxrwxr-x 80 root root 4096 Dec 5 12:03 drivers drwxrwxr-x 17 root root 4096 Dec 5 12:03 firmware drwxrwxr-x 64 root root 4096 Dec 5 12:03 fs -rw-rw-r-- 1 root root 867 Dec 5 12:03.gitignore drwxrwxr-x 31 root root 4096 Dec 6 18:05 include drwxrwxr-x 2 root root 4096 Dec 5 12:03 init drwxrwxr-x 2 root root 4096 Dec 5 12:03 ipc Configuring the kernel build http://simms-teach.com/docs/cis191/cis191esson13-dot-config.pdf
58
CIS 191 - Lesson 13 -rw-rw-r-- 1 root root 2430 Dec 5 12:03 Kbuild drwxrwxr-x 6 root root 4096 Dec 5 12:03 kernel drwxrwxr-x 6 root root 4096 Dec 5 12:03 lib -rw-rw-r-- 1 root root 3799 Dec 5 12:03.mailmap -rw-rw-r-- 1 root root 101926 Dec 5 12:03 MAINTAINERS -rw-rw-r-- 1 root root 56768 Dec 5 12:03 Makefile drwxrwxr-x 2 root root 4096 Dec 5 12:03 mm drwxrwxr-x 43 root root 4096 Dec 5 12:03 net -rw-rw-r-- 1 root root 16930 Dec 5 12:03 README -rw-rw-r-- 1 root root 3172 Dec 5 12:03 REPORTING-BUGS drwxrwxr-x 6 root root 4096 Dec 5 12:03 samples drwxrwxr-x 9 root root 4096 Dec 5 12:03 scripts drwxrwxr-x 5 root root 4096 Dec 5 12:03 security drwxrwxr-x 20 root root 4096 Dec 5 12:03 sound drwxrwxr-x 2 root root 4096 Dec 5 12:03 usr drwxrwxr-x 3 root root 4096 Dec 5 12:03 virt [root@benji linux-2.6.27.8]# After running make config Configuring the kernel build skip this for now
59
CIS 191 - Lesson 13 make menuconfig Configuring the kernel build needs ncurses package for line drawing set
60
CIS 191 - Lesson 13 make menuconfig Configuring the kernel build
61
CIS 191 - Lesson 13 make oldconfig and hold down the enter key Configuring the kernel build
62
CIS 191 - Lesson 13 Note make config and make oldconfig yielded the same configuration file Configuring the kernel build
63
CIS 191 - Lesson 13 The hidden.config file [root@benji linux-2.6.27.8]# ls -a..config.old drivers init.mailmap README sound.. COPYING firmware ipc MAINTAINERS REPORTING-BUGS usr arch CREDITS fs Kbuild Makefile samples virt block crypto.gitignore kernel mm scripts.config Documentation include lib net security [root@benji linux-2.6.27.8]# Configuring the kernel build http://simms-teach.com/docs/cis191/cis191esson13-dot-config.pdf
64
CIS 191 - Lesson 13.config file Configuring the kernel build http://simms-teach.com/docs/cis191/cis191esson13-make-config.pdf
65
CIS 191 - Lesson 13 The Linux Kernel Building a New Kernel Obtain and verify kernel source tarball Extract source code Install development tools Configure the kernel options make config or make menuconfig or make xconfig or make gconfig or make oldconfig make dep (not required for v2.6 and higher) make clean make bzImage make modules make modules_install make install We are building a v2.6 kernel
66
CIS 191 - Lesson 13 Building the kernel Clean up miscellaneous object files
67
CIS 191 - Lesson 13 The Linux Kernel Building a New Kernel Obtain and verify kernel source tarball Extract source code Install development tools Configure the kernel options make config or make menuconfig or make xconfig or make gconfig or make oldconfig make dep (not required for v2.6 and higher) make clean make bzImage make modules make modules_install make install
68
CIS 191 - Lesson 13 Building the kernel Start compiling 11:42 pm – 11:52 pm http://simms-teach.com/docs/cis191/cis191esson13-make-bzImage.pdf
69
CIS 191 - Lesson 13 The Linux Kernel Building a New Kernel Obtain and verify kernel source tarball Extract source code Install development tools Configure the kernel options make config or make menuconfig or make xconfig or make gconfig or make oldconfig make dep (not required for v2.6 and higher) make clean make bzImage make modules make modules_install make install
70
CIS 191 - Lesson 13 Building the kernel Start compiling modules 11:59 -12:20 http://simms-teach.com/docs/cis191/cis191esson13-make-modules.pdf
71
CIS 191 - Lesson 13 Building the kernel Post compile [root@benji linux-2.6.27.8]# ls -aF./ ipc/ scripts/.tmp_vmlinux1*../ Kbuild security/..tmp_vmlinux1.cmd arch/ kernel/ sound/.tmp_vmlinux2* block/ lib/ System.map..tmp_vmlinux2.cmd.config.mailmap.tmp_kallsyms1.o.tmp_vmlinux3* COPYING MAINTAINERS..tmp_kallsyms1.o.cmd..tmp_vmlinux3.cmd CREDITS Makefile.tmp_kallsyms1.S usr/ crypto/.missing-syscalls.d.tmp_kallsyms2.o.version Documentation/ mm/..tmp_kallsyms2.o.cmd virt/ drivers/ modules.order.tmp_kallsyms2.S vmlinux* firmware/ Module.symvers.tmp_kallsyms3.o.vmlinux.cmd fs/ net/..tmp_kallsyms3.o.cmd vmlinux.o.gitignore README.tmp_kallsyms3.S.vmlinux.o.cmd include/ REPORTING-BUGS.tmp_System.map init/ samples/.tmp_versions/ [root@benji linux-2.6.27.8]#
72
CIS 191 - Lesson 13 Building the kernel Post compile [root@benji linux-2.6.27.8]# ls -l total 153100 drwxrwxr-x 25 root root 4096 Dec 6 18:25 arch drwxrwxr-x 2 root root 4096 Dec 6 18:37 block -rw-rw-r-- 1 root root 18693 Dec 5 12:03 COPYING -rw-rw-r-- 1 root root 92899 Dec 5 12:03 CREDITS drwxrwxr-x 3 root root 12288 Dec 6 18:53 crypto drwxrwxr-x 78 root root 12288 Dec 5 12:03 Documentation drwxrwxr-x 80 root root 4096 Dec 6 18:46 drivers drwxrwxr-x 17 root root 4096 Dec 6 18:56 firmware drwxrwxr-x 64 root root 12288 Dec 6 18:37 fs drwxrwxr-x 31 root root 4096 Dec 6 18:16 include drwxrwxr-x 2 root root 4096 Dec 6 18:34 init drwxrwxr-x 2 root root 4096 Dec 6 18:37 ipc -rw-rw-r-- 1 root root 2430 Dec 5 12:03 Kbuild drwxrwxr-x 6 root root 12288 Dec 6 18:34 kernel drwxrwxr-x 6 root root 12288 Dec 6 18:55 lib -rw-rw-r-- 1 root root 101926 Dec 5 12:03 MAINTAINERS -rw-rw-r-- 1 root root 56768 Dec 5 12:03 Makefile drwxrwxr-x 2 root root 4096 Dec 6 18:34 mm
73
CIS 191 - Lesson 13 Building the kernel Post compile drwxrwxr-x 2 root root 4096 Dec 6 18:34 mm -rw-r--r-- 1 root root 33750 Dec 6 18:52 modules.order -rw-r--r-- 1 root root 337836 Dec 6 18:52 Module.symvers drwxrwxr-x 43 root root 4096 Dec 6 18:52 net -rw-rw-r-- 1 root root 16930 Dec 5 12:03 README -rw-rw-r-- 1 root root 3172 Dec 5 12:03 REPORTING-BUGS drwxrwxr-x 6 root root 4096 Dec 5 12:03 samples drwxrwxr-x 9 root root 4096 Dec 6 18:34 scripts drwxrwxr-x 5 root root 4096 Dec 6 18:37 security drwxrwxr-x 20 root root 4096 Dec 6 18:56 sound -rw-r--r-- 1 root root 1076204 Dec 6 18:25 System.map drwxrwxr-x 2 root root 4096 Dec 6 18:34 usr drwxrwxr-x 3 root root 4096 Dec 5 12:03 virt -rwxr-xr-x 1 root root 69534188 Dec 6 18:25 vmlinux -rw-r--r-- 1 root root 85037854 Dec 6 18:24 vmlinux.o [root@benji linux-2.6.27.8]# vmlinux is the uncompressed kernel
74
CIS 191 - Lesson 13 Building the kernel text segment: the instructions that will be executed by the CPU data segment: initialized program variables bss: uninitialized or zero-initialized data segment
75
CIS 191 - Lesson 13 Building the kernel Post compile bxImage is the compressed version of the new kernel
76
CIS 191 - Lesson 13 The Linux Kernel Building a New Kernel Obtain and verify kernel source tarball Extract source code Install development tools Configure the kernel options make config or make menuconfig or make xconfig or make gconfig or make oldconfig make dep (not required for v2.6 and higher) make clean make bzImage make modules make modules_install make install
77
CIS 191 - Lesson 13 Building the kernel Check disk space before make modules_install The kernel modules will be placed in /lib using up more of /dev/sda1
78
CIS 191 - Lesson 13 Building the kernel make modules_install http://simms-teach.com/docs/cis191/cis191esson13-make-modules_install.pdf
79
CIS 191 - Lesson 13 Building the kernel After make modules_install
80
CIS 191 - Lesson 13 Building the kernel After make modules_install Increased / partition usage from 69% to 77%
81
CIS 191 - Lesson 13 The Linux Kernel Building a New Kernel Obtain and verify kernel source tarball Extract source code Install development tools Configure the kernel options make config or make menuconfig or make xconfig or make gconfig or make oldconfig make dep (not required for v2.6 and higher) make clean make bzImage make modules make modules_install make install
82
CIS 191 - Lesson 13 Building the kernel Before make install
83
CIS 191 - Lesson 13 Building the kernel Before make install [root@benji linux-2.6.27.8]# ls /boot config-2.6.18-8.el5 symvers-2.6.18-8.el5.gz config-2.6.18-92.1.13.el5 symvers-2.6.18-92.1.13.el5.gz grub System.map-2.6.18-8.el5 initrd-2.6.18-8.el5.img System.map-2.6.18-92.1.13.el5 initrd-2.6.18-92.1.13.el5.img vmlinuz-2.6.18-8.el5 message vmlinuz-2.6.18-92.1.13.el5 [root@benji linux-2.6.27.8]# Note that we do not see 2.6.27.8 files
84
CIS 191 - Lesson 13 Building the kernel make install
85
CIS 191 - Lesson 13 Building the kernel After make install [root@benji linux-2.6.27.8]# cat /boot/grub/grub.conf # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You do not have a /boot partition. This means that # all kernel and initrd paths are relative to /, eg. # root (hd0,0) # kernel /boot/vmlinuz-version ro root=/dev/sda1 # initrd /boot/initrd-version.img #boot=/dev/sda1 default=2 timeout=60 splashimage=(hd0,0)/boot/grub/splash.xpm.gz #hiddenmenu title CentOS (2.6.27.8) root (hd0,0) kernel /boot/vmlinuz-2.6.27.8 ro root=LABEL=/1 rhgb quiet initrd /boot/initrd-2.6.27.8.img title CentOS (2.6.18-92.1.13.el5) root (hd0,0) kernel /boot/vmlinuz-2.6.18-92.1.13.el5 ro root=LABEL=/1 rhgb quiet initrd /boot/initrd-2.6.18-92.1.13.el5.img title CentOS (2.6.18-8.el5) root (hd0,0) kernel /boot/vmlinuz-2.6.18-8.el5 ro root=LABEL=/1 rhgb quiet initrd /boot/initrd-2.6.18-8.el5.img title My Distro root (hd0,0) kernel /boot/vmlinuz-2.6.18-8.el5 ro root=/dev/sda6 init=/bin/bash initrd /boot/initrd-2.6.18-8.el5.img [root@benji linux-2.6.27.8]#
86
CIS 191 - Lesson 13 Building the kernel After make install the kernel is copied to the /boot directory copy of bzImage (compressed kernel) Initial ram disk kernel symbol table bzImage = vmlinuz
87
CIS 191 - Lesson 13 The Linux Kernel Building a New Kernel Obtain and verify kernel source tarball Extract source code Install development tools Configure the kernel options make config or make menuconfig or make xconfig or make gconfig or make oldconfig make dep (not required for v2.6 and higher) make clean make bzImage make modules make modules_install make install
88
CIS 191 - Lesson 13 Building the kernel After make install
89
CIS 191 - Lesson 13 Building the kernel After make install
90
CIS 191 - Lesson 13 Patches
91
CIS 191 - Lesson 13 The Linux Kernel Patches Applying a Kernel Patch ‒ copy the patch file to /depot ‒ uncompress it with bunzip2 or gunzip as appropriate ‒ cd to your kernel build directory (named using the version number of the full kernel built previously) ‒ patch -p1 <../patch-2.6.27.n ‒ Apply patches in order ‒ Rebuild everything again
92
CIS 191 - Lesson 13 Kernel RPM Updates
93
CIS 191 - Lesson 13 Updating a kernel RPM Be careful Don't use the –U option rpm –U newkernel This overwrites existing kernel Use the –i option rpm –ivh newkernel or yum install kernel This installs new kernel side by side with old kernel and extends GRUB boot options
94
CIS 191 - Lesson 13 Updating a kernel RPM CentOS 5 kernel "update" using install [root@star ~]# cat /boot/grub/grub.conf # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,1) # kernel /vmlinuz-version ro root=/dev/sda3 # initrd /initrd-version.img #boot=/dev/sda2 default=0 timeout=35 splashimage=(hd0,1)/grub/splash.xpm.gz #hiddenmenu title CentOS (2.6.18-8.el5) root (hd0,1) kernel /vmlinuz-2.6.18-8.el5 ro root=LABEL=/ rhgb initrd /initrd-2.6.18-8.el5.img title FreeDOS rootnoverify (hd0,0) chainloader +1 [root@star ~]# Note: This is on the star VM
95
CIS 191 - Lesson 13 Updating a kernel RPM CentOS 5 kernel "update" using install [root@star ~]# yum install kernel Loading "installonlyn" plugin Setting up Install Process Setting up repositories Reading repository metadata in from local files Parsing package install arguments Resolving Dependencies --> Populating transaction set with selected packages. Please wait. ---> Downloading header for kernel to pack into transaction set. kernel-2.6.18-92.1.13.el5 100% |=========================| 319 kB 00:01 ---> Package kernel.i686 0:2.6.18-92.1.13.el5 set to be installed --> Running transaction check Dependencies Resolved ============================================================================= Package Arch Version Repository Size ============================================================================= Installing: kernel i686 2.6.18-92.1.13.el5 updates 14 M Transaction Summary ============================================================================= Install 1 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 14 M Is this ok [y/N]: y New kernel version available User confirms here
96
CIS 191 - Lesson 13 Updating a kernel RPM CentOS 5 kernel "update" using install Downloading Packages: (1/1): kernel-2.6.18-92.1 100% |=========================| 14 MB 01:15 warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897 Importing GPG key 0xE8562897 "CentOS-5 Key (CentOS 5 Official Signing Key) " from http://mirror.centos.org/centos/RPM-GPG-KEY- CentOS-5 Is this ok [y/N]: y Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing: kernel ######################### [1/1] Installed: kernel.i686 0:2.6.18-92.1.13.el5 Complete! [root@star ~]# New kernel is installed …
97
CIS 191 - Lesson 13 Updating a kernel RPM CentOS 5 kernel "update" using install [root@star ~]# cat /boot/grub/grub.conf # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,1) # kernel /vmlinuz-version ro root=/dev/sda3 # initrd /initrd-version.img #boot=/dev/sda2 default=0 timeout=35 splashimage=(hd0,1)/grub/splash.xpm.gz #hiddenmenu title CentOS (2.6.18-92.1.13.el5) root (hd0,1) kernel /vmlinuz-2.6.18-92.1.13.el5 ro root=LABEL=/ rhgb initrd /initrd-2.6.18-92.1.13.el5.img title CentOS (2.6.18-8.el5) root (hd0,1) kernel /vmlinuz-2.6.18-8.el5 ro root=LABEL=/ rhgb initrd /initrd-2.6.18-8.el5.img title FreeDOS rootnoverify (hd0,0) chainloader +1 [root@star ~]# … and grub.conf is modified to show the new kernel boot option
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.