1. Trang chủ
  2. » Công Nghệ Thông Tin

Topic 7 Linux Kernel

7 4 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 7
Dung lượng 537,18 KB
File đính kèm Topic7_LinuxKernel.rar (515 KB)

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Triển khai một máy tính làm việc Linux với các tính năng về đồ họa, vi tính văn phòng,… Hệ thống vận hành: cài đặt, cấu hình, quản trị, xử lý sự cố,… Vận hành hệ điều hành Linux: cài đặt, cấu hình mạng, máy trong, sử dụng thành thạo các công cụ quản lý mạng, cấu hình nhân, DFS, lập kế hoạch cho việc lưu trữ và phục hồi dữ liệu, TCP IP , config device,… Liên kết cơ bản kỹ năng đến Internet: kết nối, email, bảo mật, DNS, Apache, SSH, NTP,…

Trang 1

Topic 7: Linux Kernel

Kernel Components Compiling a kernel Patching a kernel Customise, build and install a custom - kernel and kernel modules

Trang 2

116 Phiên Bản Thử Nghiệm – Lưu Hành Nội Bộ

[root@localhost ~]# lsmod | more

[root@localhost ~]# uname -a

Linux localhost.localdomain 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

[root@

[root@localhost ~]# modinfo ext4

filename: /lib/modules/3.10.0-229.el7.x86_64/kernel/fs/ext4/ext4.ko

license: GPL

description: Fourth Extended Filesystem

1 Kernel module:

Xem version của kernel bằng lệnh:

Dùng lệnh lsmod để liệt kê các module của kernel:

Module Size Used by

tcp_lp 12663 0

nls_utf8 12557 1

isofs 39844 1

bnep 19704 2

bluetooth

rfkill 372662 7 bnep 26536 3 bluetooth

fuse 87741 3

coretemp 13435 0

crct10dif_pclmul 14289 0

crc32_pclmul 13113 0

crc32c_intel 22079 0

ghash_clmulni_intel 13259 0

aesni_intel 52846 0

lrw 13286 1 aesni_intel

gf128mul 14951 1 lrw

glue_helper 13990 1 aesni_intel

ablk_helper 13597 1 aesni_intel

cryptd 20359 3 ghash_clmulni_intel,aesni_intel,ablk_helper snd_ens1371 25243 3

snd_rawmidi 30824 1 snd_ens1371

snd_ac97_codec

ac97_bus 130476 1 snd_ens1371 12730 1 snd_ac97_codec

snd_seq 63074 0

snd_seq_device 14497 2 snd_seq,snd_rawmidi

ppdev 17671 0

snd_pcm

vmw_balloon 103996 2 snd_ac97_codec,snd_ens1371 13415 0

serio_raw 13462 0

pcspkr 12718 0

snd_timer 29562 2 snd_pcm,snd_seq

Dùng lệnh modinfo để xem thông tin của một module:

Trang 3

author: Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger,

Theodore Ts'o and others

alias: fs-ext4

[root@localhost Desktop]# lsmod | grep arc4

arc4 12608 0

[root@localhost Desktop]# lsmod | grep arc4

Dùng lệnh insmod để insert thêm một module vào kernel:

[root@localhost ~]# insmod /lib/modules/3.10.0-229.el7.x86_64/kernel/crypto/arc4.ko

Nếu báo lỗi vì module này phụ thuộc vào một module khác chưa được insert Tìm trong file /lib/modules/3.10.0-229.el7.x86_64/modules.dep để biết mối quan hệ phụ thuộc

Dùng lệnh lsmod, liệt kê lại các module:

Dùng lệnh rmmod để remove 2 module vừa insert

# rmmod arc4

Liệt kê module lại để kiểm tra

2 Compiling kernel

Cài thư viện :

# yum install gcc ncurses ncurses-devel

- Download source kernel từ trang kernel.org

- Để biên dịch được kernel, cần cài bộ C compiler Xem lại phần cài đặt ở bài trước

- Giải nén gói source:

- Tạo file config Có thể tạo file config:

o make config: dạng text file, màn hình hiện ra nhiều câu hỏi, trả lời lần lượt

o make menuconfig: dạng đồ họa, (kiểu đồ họa trên DOS), dễ sử dụng hơn

Trang 4

118 Phiên Bản Thử Nghiệm – Lưu Hành Nội Bộ

o make xconfig hoặc gconfig: giao diện đồ họa

o make oldconfig: lấy lại file config cũ

- Sau khi đã tạo file config, lần lượt thực hiện những lệnh sau để tiến hành biên dịch kernel:

o make dep: kiểm tra sự phụ thuộc giữa những file C

Trang 5

o make clean: dọn dẹp những file biên dịch cũ, có thể đã được tạo ra trong gói source

o make bzImage: tạo kernel image

o make modules: biên dịch những module đã chọn lựa

o make modules_install: những module đã biên dịch sẽ được đưa vào

/lib/modules/kernel-version

o make install: Kernel image và initrd được đưa vào /boot/

Trang 6

120 Phiên Bản Thử Nghiệm – Lưu Hành Nội Bộ

76 menuentry 'CentOS Linux (3.2.3) 7 (Core)' class rhel fedora class gnu-linux class gnu

class os unrestricted $men uentry_id_option 'gnulinux-3.10.0-229.el7.x86_64- advanced-92dd65a3-6293-4f7c-ac60-8cc0599cfe87' {

77 load_video

78 set gfxpayload=keep

79 insmod gzio

80 insmod part_msdos

81 insmod ext2

82 set root='hd0,msdos1'

83 if [ x$feature_platform_search_hint = xy ]; then

84 search no-floppy fs-uuid set=root hint-bios=hd0,msdos1 hint-

efi=hd0,msdos1 hint-baremetal=ahci0,msdo s1 hint='hd0,msdos1' d1bf360f- 50b5-459d-92f5-195aa5215f54

85 else

86

87

88

search no-floppy fs-uuid set=root d1bf360f-50b5-459d-92f5-195aa5215f54

fi linux16 /vmlinuz-3.2.3 root=UUID=92dd65a3-6293-4f7c-ac60-8cc0599cfe87 ro crashkernel=auto rhgb quiet LANG=en_US.UT F-8 systemd.debug

89 initrd16 /initramfs-3.2.3.img

90 }

o Kiểm tra thư mục /boot đã có kernel image và initrd

o Xem file /boot/grub2/grub.conf để kiểm tra một kernel mới đã được thêm vào

[root@localhost linux-3.2.3]# ll /boot/

total 116292

-rw-r r 1 root root 123838 Mar 6 18:45 config-3.10.0-229.el7.x86_64

drwxr-xr-x 2 root root 1024 Apr 28 15:20 extlinux

drwxr-xr-x 2 root root 1024 Apr 14 17:17 grub

drwxr-xr-x 6 root root 1024 Apr 28 16:51 grub2

-rw-r r 1 root root 16496720 Apr 14 17:25 initramfs-3.10.0-229.el7.x86_64.img

-rw-r r 1 root root 16569444 Apr 18 10:24 initramfs-3.10.0-229.el7.x86_64kdump.img -rw-r r 1 root root 15951823 Apr 28 16:51 initramfs-3.2.3.img

-rwxr-xr-x 1 root root 5029136 Mar 6 18:45 vmlinuz-3.10.0-229.el7.x86_64

-rw-r r 1 root root 3855312 Apr 28 16:51 vmlinuz-3.2.3

-rw-r r 1 root root 3855312 Apr 28 16:48 vmlinuz-3.2.3.old

Trang 7

Menu khởi động

Kiểm tra kernel mới

Ngày đăng: 27/09/2022, 02:29