SlideShare a Scribd company logo
1 of 12
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

What's hot

Chuẩn bị kế hoạch nâng cấp domain controller windows 2003 lên 2008 2012
Chuẩn bị kế hoạch nâng cấp domain controller windows 2003 lên 2008 2012Chuẩn bị kế hoạch nâng cấp domain controller windows 2003 lên 2008 2012
Chuẩn bị kế hoạch nâng cấp domain controller windows 2003 lên 2008 2012laonap166
 
Tìm hiểu đầy đủ về tràn bộ đệm
Tìm hiểu đầy đủ về tràn bộ đệmTìm hiểu đầy đủ về tràn bộ đệm
Tìm hiểu đầy đủ về tràn bộ đệmtienhien110293
 
03 installing linux as a server
03  installing linux as a server03  installing linux as a server
03 installing linux as a serverCơn Gió
 
Linux07 khoidong&dongtat
Linux07 khoidong&dongtatLinux07 khoidong&dongtat
Linux07 khoidong&dongtatanhbinhminhpro
 
Lesson 6 - Administering Linux System (2)
Lesson 6 - Administering Linux System (2)Lesson 6 - Administering Linux System (2)
Lesson 6 - Administering Linux System (2)Thang Man
 
Lab 2 nâng cấp windows server 2003 lên windows server 2008 .pdf
Lab 2 nâng cấp windows server 2003 lên windows server 2008 .pdfLab 2 nâng cấp windows server 2003 lên windows server 2008 .pdf
Lab 2 nâng cấp windows server 2003 lên windows server 2008 .pdfPham Viet Dung
 
Free RTOS Porting CPU - ADKS
Free RTOS Porting CPU - ADKSFree RTOS Porting CPU - ADKS
Free RTOS Porting CPU - ADKSAu Duong Kim Son
 
115 cau trac_nghiem_linux
115 cau trac_nghiem_linux115 cau trac_nghiem_linux
115 cau trac_nghiem_linuxPhuong Thuy
 
Giao trinh he_dieu_hanh_tech24_vn[bookbooming.com]
Giao trinh he_dieu_hanh_tech24_vn[bookbooming.com]Giao trinh he_dieu_hanh_tech24_vn[bookbooming.com]
Giao trinh he_dieu_hanh_tech24_vn[bookbooming.com]bookbooming1
 
Lesson 5 - Administering Linux System (1)
Lesson 5 - Administering Linux System (1)Lesson 5 - Administering Linux System (1)
Lesson 5 - Administering Linux System (1)Thang Man
 
13 samba nfs server
13  samba nfs server13  samba nfs server
13 samba nfs serverCơn Gió
 
Hướng dẫn làm quen với stm8 f103 - tincanban.com
Hướng dẫn làm quen với stm8 f103 - tincanban.comHướng dẫn làm quen với stm8 f103 - tincanban.com
Hướng dẫn làm quen với stm8 f103 - tincanban.comThùy Linh
 

What's hot (17)

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

Viewers also liked

87 rapport activité cdsp 2011
87 rapport activité cdsp 201187 rapport activité cdsp 2011
87 rapport activité cdsp 2011CCDH75
 
83 rapport activité cdsp 2011
83 rapport activité cdsp 201183 rapport activité cdsp 2011
83 rapport activité cdsp 2011CCDH75
 
The World This Week April 29 - May 03, 2013
The World This Week April 29 - May 03, 2013The World This Week April 29 - May 03, 2013
The World This Week April 29 - May 03, 2013Karvy Private Wealth
 
74 rapport activité cdsp 2011
74 rapport activité cdsp 201174 rapport activité cdsp 2011
74 rapport activité cdsp 2011CCDH75
 
72 rapport activité cdsp 2011
72 rapport activité cdsp 201172 rapport activité cdsp 2011
72 rapport activité cdsp 2011CCDH75
 
77 rapport activité cdsp 2011
77 rapport activité cdsp 201177 rapport activité cdsp 2011
77 rapport activité cdsp 2011CCDH75
 

Viewers also liked (8)

14 pam
14  pam14  pam
14 pam
 
La curación de la información pwp
La curación de la información pwpLa curación de la información pwp
La curación de la información pwp
 
87 rapport activité cdsp 2011
87 rapport activité cdsp 201187 rapport activité cdsp 2011
87 rapport activité cdsp 2011
 
83 rapport activité cdsp 2011
83 rapport activité cdsp 201183 rapport activité cdsp 2011
83 rapport activité cdsp 2011
 
The World This Week April 29 - May 03, 2013
The World This Week April 29 - May 03, 2013The World This Week April 29 - May 03, 2013
The World This Week April 29 - May 03, 2013
 
74 rapport activité cdsp 2011
74 rapport activité cdsp 201174 rapport activité cdsp 2011
74 rapport activité cdsp 2011
 
72 rapport activité cdsp 2011
72 rapport activité cdsp 201172 rapport activité cdsp 2011
72 rapport activité cdsp 2011
 
77 rapport activité cdsp 2011
77 rapport activité cdsp 201177 rapport activité cdsp 2011
77 rapport activité cdsp 2011
 

Similar to 10 compiling kernel

Linux Backup & Restore.docx
Linux Backup & Restore.docxLinux Backup & Restore.docx
Linux Backup & Restore.docxssuserca116d
 
[C] giao trinh c dhbk - viet nhat
[C] giao trinh c   dhbk - viet nhat[C] giao trinh c   dhbk - viet nhat
[C] giao trinh c dhbk - viet nhatHoang Nguyen
 
Lesson 2 - Install Linux & Command Line Environment
Lesson 2 - Install Linux & Command Line EnvironmentLesson 2 - Install Linux & Command Line Environment
Lesson 2 - Install Linux & Command Line EnvironmentThang Man
 
Linux Network Administration (LPI-1,LPI-2)
Linux Network Administration (LPI-1,LPI-2)Linux Network Administration (LPI-1,LPI-2)
Linux Network Administration (LPI-1,LPI-2)laonap166
 
Sinh vienit.net --57669587-c-dhkh-hue
Sinh vienit.net --57669587-c-dhkh-hueSinh vienit.net --57669587-c-dhkh-hue
Sinh vienit.net --57669587-c-dhkh-hueTuấn Nguyễn Văn
 
Cach su dung Ubuntu
Cach su dung UbuntuCach su dung Ubuntu
Cach su dung UbuntuKien Ma
 
Chương 3. Dịch ngược mã độc.pdf
Chương 3.  Dịch ngược mã độc.pdfChương 3.  Dịch ngược mã độc.pdf
Chương 3. Dịch ngược mã độc.pdfdong55
 
Bài 2: Hệ điều hành và các ứng dụng mã nguồn mở
Bài 2: Hệ điều hành và các ứng dụng mã nguồn mởBài 2: Hệ điều hành và các ứng dụng mã nguồn mở
Bài 2: Hệ điều hành và các ứng dụng mã nguồn mởMasterCode.vn
 

Similar to 10 compiling kernel (9)

Linux Backup & Restore.docx
Linux Backup & Restore.docxLinux Backup & Restore.docx
Linux Backup & Restore.docx
 
[C] giao trinh c dhbk - viet nhat
[C] giao trinh c   dhbk - viet nhat[C] giao trinh c   dhbk - viet nhat
[C] giao trinh c dhbk - viet nhat
 
Lesson 2 - Install Linux & Command Line Environment
Lesson 2 - Install Linux & Command Line EnvironmentLesson 2 - Install Linux & Command Line Environment
Lesson 2 - Install Linux & Command Line Environment
 
Linux+03
Linux+03Linux+03
Linux+03
 
Linux Network Administration (LPI-1,LPI-2)
Linux Network Administration (LPI-1,LPI-2)Linux Network Administration (LPI-1,LPI-2)
Linux Network Administration (LPI-1,LPI-2)
 
Sinh vienit.net --57669587-c-dhkh-hue
Sinh vienit.net --57669587-c-dhkh-hueSinh vienit.net --57669587-c-dhkh-hue
Sinh vienit.net --57669587-c-dhkh-hue
 
Cach su dung Ubuntu
Cach su dung UbuntuCach su dung Ubuntu
Cach su dung Ubuntu
 
Chương 3. Dịch ngược mã độc.pdf
Chương 3.  Dịch ngược mã độc.pdfChương 3.  Dịch ngược mã độc.pdf
Chương 3. Dịch ngược mã độc.pdf
 
Bài 2: Hệ điều hành và các ứng dụng mã nguồn mở
Bài 2: Hệ điều hành và các ứng dụng mã nguồn mởBài 2: Hệ điều hành và các ứng dụng mã nguồn mở
Bài 2: Hệ điều hành và các ứng dụng mã nguồn mở
 

More from Cơn Gió

19 web server
19  web server19  web server
19 web serverCơn Gió
 
18 dns server
18  dns server18  dns server
18 dns serverCơn Gió
 
17 ftp & ssh server
17  ftp & ssh server17  ftp & ssh server
17 ftp & ssh serverCơn Gió
 
15 nis server
15  nis server15  nis server
15 nis serverCơn Gió
 
12 dhcp server
12  dhcp server12  dhcp server
12 dhcp serverCơn Gió
 
11 networking fundamentals
11  networking fundamentals11  networking fundamentals
11 networking fundamentalsCơn Gió
 
09 core system services
09  core system services09  core system services
09 core system servicesCơn Gió
 
08 file systems
08  file systems08  file systems
08 file systemsCơn Gió
 
05 managing users
05  managing users05  managing users
05 managing usersCơn Gió
 
01 introduction
01  introduction01  introduction
01 introductionCơn Gió
 
16 ldap server
16  ldap server16  ldap server
16 ldap serverCơn Gió
 

More from Cơn Gió (11)

19 web server
19  web server19  web server
19 web server
 
18 dns server
18  dns server18  dns server
18 dns server
 
17 ftp & ssh server
17  ftp & ssh server17  ftp & ssh server
17 ftp & ssh server
 
15 nis server
15  nis server15  nis server
15 nis server
 
12 dhcp server
12  dhcp server12  dhcp server
12 dhcp server
 
11 networking fundamentals
11  networking fundamentals11  networking fundamentals
11 networking fundamentals
 
09 core system services
09  core system services09  core system services
09 core system services
 
08 file systems
08  file systems08  file systems
08 file systems
 
05 managing users
05  managing users05  managing users
05 managing users
 
01 introduction
01  introduction01  introduction
01 introduction
 
16 ldap server
16  ldap server16  ldap server
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

  1. 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