SlideShare a Scribd company logo
1
10 Compiling the10 Compiling the
Linux kernelLinux kernel
P2 Single host AdministrationP2 Single host Administration
2
Nội dungNội dung
 Kernel version.
 Kernel modules.
 Compiling kernel.
3
Kernel versionKernel version
 Version của kernel có format như sau:
 linux-major.minor.patchlevel
 Vd: linux-2.6.18.8
 major: version chính của kernel
 minor: những thay đổi quan trọng của version.
 số chẵn: version này đã được kiểm tra và công
bố sử dụng. 2.4, 2.6…
 số lẻ: version này dùng cho mục đích thử
nghiệm. Các kernel developer thường sử dụng.
 patchlevel: dùng để vá lỗi.
4
Kernel version (tt)Kernel version (tt)
 Để xác định kernel version, dùng lệnh:
 uname –a
 uname –r
 Kernel mặc định đã được dịch với các
module cần thiết, khi có nhu cầu có thể tiến
hành dịch lại kernel => có một hệ điều hành
mới.
5
Kernel modulesKernel modules
 Kernel thường được biên dịch với các
module cần thiết nhất.
 Các module ít sử dụng có thể được insert
vào kernel khi cần thiết.
 Các module của kernel là một file object, nằm
trong thư mục
/lib/modules/kernel-version/kernel/
6
Kernel modules (tt)Kernel modules (tt)
 Một số kernel modules:
 block: module cho những thiết bị phần cứng đặc biệt:
RAID controller, IDE tape drivers.
 cdrom: module cho CDROM.
 fs: module cho file systems.
 ipv4: module cần thiết cho việc hoạt động với TCP/IP
networking.
 net: module cho network interface.
 scsi: module cho SCSI controller.
 video: module cho video adapter.
 misc: các module không thuộc các module kể trên.
7
Kernel modules (tt)Kernel modules (tt)
 Lệnh lsmod: liệt kê những module đang được
kernel hỗ trợ.
 Lệnh insmod: thêm một module vào kernel.
 Lệnh rmmod: xóa bỏ một module ra khỏi
kernel.
 Lệnh modinfo: xem thông tin một module.
 File modules.dep: liệt kê mối quan hệ phụ
thuộc giữa các module.
8
Compiling kernelCompiling kernel
 Download source kernel từ:
 kernel.org
 Để biên dịch được kernel, cần cài đặt bộ C
compiler.
 Các lệnh để biên dịch:
 make mrproper
 make config, hoặc make menuconfig, make
xconfig, hoặc make oldconfig.
 Sau khi tạo file config xong, có thể edit trong
makefile, và thực hiện tiếp các lệnh sau.
9
Compiling kernel (tt)Compiling kernel (tt)
 Các lệnh để biên dịch kernel:
 make dep
 make clean
 make bzImage
 make modules
 make modules_install
 make install
10
Compiling kernel (tt)Compiling kernel (tt)
 Các lệnh để biên dịch kernel:
 make dep: những file source C sẽ được kiểm tra các
mối quan hệ phụ thuộc.
 make clean: remove những output file cũ có thể đã tồn
tại trong source.
 make bzImage: tạo một file kernel image.
 make modules: biên dịch những driver thiết bị, và
những module đã chọn lựa để biên dịch.
 make modules_install: tất cả những modules đã được
biên dịch sẽ được cài đặt vào thư mục
/lib/modules/kernel-version/
 make install: kernel image và initrd được đưa vào thư
mục boot.
11
Compiling kernel (tt)Compiling kernel (tt)
 Sau khi biên dịch kernel hoàn tất, sẽ tạo ra
một kernel image và một initrd mới.
 Khởi động lại máy, boot loader sẽ nhận thêm
một hệ điều hành mới.
 File system của hệ điều hành mới cũng là file
system của hệ điều hành cũ.
 Hệ điều hành mới chỉ khác hệ điều hành cũ
các modules được biên dịch trong kernel.
12
Hỏi & ĐápHỏi & Đáp

More Related Content

PPT
07 booting and shutting down
PDF
CCNA LAB - Cisco Packet Tracer
PPT
02 technical summary of linux distribution
PDF
Lesson 7 - Linux Shell Programming
PDF
PPT
06 the command line
PPT
04 installing software
07 booting and shutting down
CCNA LAB - Cisco Packet Tracer
02 technical summary of linux distribution
Lesson 7 - Linux Shell Programming
06 the command line
04 installing software

What's hot (17)

DOCX
Chuẩn bị kế hoạch nâng cấp domain controller windows 2003 lên 2008 2012
PDF
Tìm hiểu đầy đủ về tràn bộ đệm
DOC
Các lệnh shell cơ bản trong linux
PPT
03 installing linux as a server
PDF
Google+và+tortoise svn
PDF
Chuong 1 gt linux
PPT
Linux07 khoidong&dongtat
PPT
Linux+04
PDF
Lesson 6 - Administering Linux System (2)
PDF
Lab 2 nâng cấp windows server 2003 lên windows server 2008 .pdf
PPTX
Free RTOS Porting CPU - ADKS
DOC
115 cau trac_nghiem_linux
PDF
Giao trinh he_dieu_hanh_tech24_vn[bookbooming.com]
PDF
Lesson 5 - Administering Linux System (1)
PPT
13 samba nfs server
DOCX
PDF
Hướng dẫn làm quen với stm8 f103 - tincanban.com
Chuẩn bị kế hoạch nâng cấp domain controller windows 2003 lên 2008 2012
Tìm hiểu đầy đủ về tràn bộ đệm
Các lệnh shell cơ bản trong linux
03 installing linux as a server
Google+và+tortoise svn
Chuong 1 gt linux
Linux07 khoidong&dongtat
Linux+04
Lesson 6 - Administering Linux System (2)
Lab 2 nâng cấp windows server 2003 lên windows server 2008 .pdf
Free RTOS Porting CPU - ADKS
115 cau trac_nghiem_linux
Giao trinh he_dieu_hanh_tech24_vn[bookbooming.com]
Lesson 5 - Administering Linux System (1)
13 samba nfs server
Hướng dẫn làm quen với stm8 f103 - tincanban.com
Ad

Viewers also liked (8)

PPT
14 pam
PPTX
La curación de la información pwp
PDF
87 rapport activité cdsp 2011
PDF
83 rapport activité cdsp 2011
PDF
The World This Week April 29 - May 03, 2013
PDF
74 rapport activité cdsp 2011
PDF
72 rapport activité cdsp 2011
PDF
77 rapport activité cdsp 2011
14 pam
La curación de la información pwp
87 rapport activité cdsp 2011
83 rapport activité cdsp 2011
The World This Week April 29 - May 03, 2013
74 rapport activité cdsp 2011
72 rapport activité cdsp 2011
77 rapport activité cdsp 2011
Ad

Similar to 10 compiling kernel (20)

PDF
Cach su dung Ubuntu
PDF
Cài đặt quản trị hệ điều hành Ubuntu 12.0
PDF
Linux Network Administration (LPI-1,LPI-2)
PPTX
Cài đặt và cấu hình căn bản hệ điều hành.pptx
PDF
Linux Introduction
PDF
Thuc hanh 13
PDF
Lesson 2 - Install Linux & Command Line Environment
PPTX
Linux là một hệ điều hành mã nguồn mở, giống như Windows hay macOS, nhưng đượ...
PPTX
Linux là một hệ điều hành mã nguồn mở, giống như Windows
PDF
Linux LPI Bacis
PDF
Sử dụng Linux
PDF
Tom tat lenh_ubuntu
PDF
Tóm tắt lệnh Ubuntu
PDF
Tom tat lenh ubuntu
PPTX
RHEL9_Presentation_for_redhat_linux.pptx
PDF
Su dung linux shell
PPTX
Nang cao kien thuc ve redhat linux .pptx
Cach su dung Ubuntu
Cài đặt quản trị hệ điều hành Ubuntu 12.0
Linux Network Administration (LPI-1,LPI-2)
Cài đặt và cấu hình căn bản hệ điều hành.pptx
Linux Introduction
Thuc hanh 13
Lesson 2 - Install Linux & Command Line Environment
Linux là một hệ điều hành mã nguồn mở, giống như Windows hay macOS, nhưng đượ...
Linux là một hệ điều hành mã nguồn mở, giống như Windows
Linux LPI Bacis
Sử dụng Linux
Tom tat lenh_ubuntu
Tóm tắt lệnh Ubuntu
Tom tat lenh ubuntu
RHEL9_Presentation_for_redhat_linux.pptx
Su dung linux shell
Nang cao kien thuc ve redhat linux .pptx

More from Cơn Gió (11)

PPT
19 web server
PPT
18 dns server
PPT
17 ftp & ssh server
PPT
15 nis server
PPT
12 dhcp server
PPT
11 networking fundamentals
PPT
09 core system services
PPT
08 file systems
PPT
05 managing users
PPT
01 introduction
PPT
16 ldap server
19 web server
18 dns server
17 ftp & ssh server
15 nis server
12 dhcp server
11 networking fundamentals
09 core system services
08 file systems
05 managing users
01 introduction
16 ldap server

10 compiling kernel

  • 1. 1 10 Compiling the10 Compiling the Linux kernelLinux kernel P2 Single host AdministrationP2 Single host Administration
  • 2. 2 Nội dungNội dung  Kernel version.  Kernel modules.  Compiling kernel.
  • 3. 3 Kernel versionKernel version  Version của kernel có format như sau:  linux-major.minor.patchlevel  Vd: linux-2.6.18.8  major: version chính của kernel  minor: những thay đổi quan trọng của version.  số chẵn: version này đã được kiểm tra và công bố sử dụng. 2.4, 2.6…  số lẻ: version này dùng cho mục đích thử nghiệm. Các kernel developer thường sử dụng.  patchlevel: dùng để vá lỗi.
  • 4. 4 Kernel version (tt)Kernel version (tt)  Để xác định kernel version, dùng lệnh:  uname –a  uname –r  Kernel mặc định đã được dịch với các module cần thiết, khi có nhu cầu có thể tiến hành dịch lại kernel => có một hệ điều hành mới.
  • 5. 5 Kernel modulesKernel modules  Kernel thường được biên dịch với các module cần thiết nhất.  Các module ít sử dụng có thể được insert vào kernel khi cần thiết.  Các module của kernel là một file object, nằm trong thư mục /lib/modules/kernel-version/kernel/
  • 6. 6 Kernel modules (tt)Kernel modules (tt)  Một số kernel modules:  block: module cho những thiết bị phần cứng đặc biệt: RAID controller, IDE tape drivers.  cdrom: module cho CDROM.  fs: module cho file systems.  ipv4: module cần thiết cho việc hoạt động với TCP/IP networking.  net: module cho network interface.  scsi: module cho SCSI controller.  video: module cho video adapter.  misc: các module không thuộc các module kể trên.
  • 7. 7 Kernel modules (tt)Kernel modules (tt)  Lệnh lsmod: liệt kê những module đang được kernel hỗ trợ.  Lệnh insmod: thêm một module vào kernel.  Lệnh rmmod: xóa bỏ một module ra khỏi kernel.  Lệnh modinfo: xem thông tin một module.  File modules.dep: liệt kê mối quan hệ phụ thuộc giữa các module.
  • 8. 8 Compiling kernelCompiling kernel  Download source kernel từ:  kernel.org  Để biên dịch được kernel, cần cài đặt bộ C compiler.  Các lệnh để biên dịch:  make mrproper  make config, hoặc make menuconfig, make xconfig, hoặc make oldconfig.  Sau khi tạo file config xong, có thể edit trong makefile, và thực hiện tiếp các lệnh sau.
  • 9. 9 Compiling kernel (tt)Compiling kernel (tt)  Các lệnh để biên dịch kernel:  make dep  make clean  make bzImage  make modules  make modules_install  make install
  • 10. 10 Compiling kernel (tt)Compiling kernel (tt)  Các lệnh để biên dịch kernel:  make dep: những file source C sẽ được kiểm tra các mối quan hệ phụ thuộc.  make clean: remove những output file cũ có thể đã tồn tại trong source.  make bzImage: tạo một file kernel image.  make modules: biên dịch những driver thiết bị, và những module đã chọn lựa để biên dịch.  make modules_install: tất cả những modules đã được biên dịch sẽ được cài đặt vào thư mục /lib/modules/kernel-version/  make install: kernel image và initrd được đưa vào thư mục boot.
  • 11. 11 Compiling kernel (tt)Compiling kernel (tt)  Sau khi biên dịch kernel hoàn tất, sẽ tạo ra một kernel image và một initrd mới.  Khởi động lại máy, boot loader sẽ nhận thêm một hệ điều hành mới.  File system của hệ điều hành mới cũng là file system của hệ điều hành cũ.  Hệ điều hành mới chỉ khác hệ điều hành cũ các modules được biên dịch trong kernel.

Editor's Notes

  • #2: Trung Tâm Đào tạo Mạng Máy Tính NHẤT NGHỆ Người biên soạn: Phạm Trần Kim Chi