|
读书笔记:<Linux内核设计与实现>,原书第3版,陈莉君 康华 译
第2章:从内核出发
2.3节:编译内核 实验:
============================================================
系统环境:VM虚拟机 Ubuntu 14.04.3 LTS server版
任务:编译安装新的内核
注意:不要跨大版本,我在3.19版本内
耗时:2小时
所有版本的内核:
https://www.kernel.org/pub/linux/kernel/
当前系统内核版本
1
2
| uname -r
3.19.0-25-generic
|
下载,解压,编译,安装Linux内核
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
| wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.19.8.tar.xz
sudo tar xf linux-3.19.8.tar.xz -C /usr/src/
cd /usr/src/linux-3.19.8/
sudo cp /boot/config-3.19.0-25-generic .config
sudo make -j 8 (编译,耗时80分钟)
echo $?
0
sudo make modules_install (安装模块,耗时7分钟)
echo $?
0
ll /lib/modules/3.19.8 #列出安装的内容
unli@linux:~$ ll /lib/modules
total 12K
drwxr-xr-x 2 root root 4.0K Jul 30 05:51 3.13.0-92-generic
drwxr-xr-x 6 root root 4.0K Sep 23 18:18 3.19.0-25-generic
drwxr-xr-x 4 root root 4.0K Nov 29 13:56 3.19.8
sudo make install (安装内核引导,耗时2分钟)
echo $?
0
ll /boot/ #列出安装的内容
chunli@linux:~$ ll /boot/
total 219M
-rw-r--r-- 1 root root 1.3M Jul 25 2015 abi-3.19.0-25-generic
-rw-r--r-- 1 root root 174K Jul 25 2015 config-3.19.0-25-generic
-rw-r--r-- 1 root root 173K Nov 29 13:55 config-3.19.8
drwxr-xr-x 5 root root 4.0K Nov 29 13:57 grub
-rw-r--r-- 1 root root 20M Jul 30 05:59 initrd.img-3.19.0-25-generic
-rw-r--r-- 1 root root 19M Jul 30 05:59 initrd.img-3.19.0-25-generic.old-dkms
-rw-r--r-- 1 root root 160M Nov 29 13:57 initrd.img-3.19.8
-rw-r--r-- 1 root root 173K Mar 12 2014 memtest86+.bin
-rw-r--r-- 1 root root 174K Mar 12 2014 memtest86+.elf
-rw-r--r-- 1 root root 175K Mar 12 2014 memtest86+_multiboot.bin
-rw------- 1 root root 3.5M Jul 25 2015 System.map-3.19.0-25-generic
-rw-r--r-- 1 root root 3.5M Nov 29 13:55 System.map-3.19.8
-rw------- 1 root root 6.3M Jul 25 2015 vmlinuz-3.19.0-25-generic
-rw-r--r-- 1 root root 6.3M Nov 29 13:55 vmlinuz-3.19.8
查看内核安装成功
chunli@linux:~$ grep 3.19.8 /boot/grub/grub.cfg
linux /boot/vmlinuz-3.19.8 root=UUID=6e8a9edf-c57c-4411-8189-074aaa456310 ro
initrd /boot/initrd.img-3.19.8
menuentry 'Ubuntu, with Linux 3.19.8' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.8-advanced-6e8a9edf-c57c-4411-8189-074aaa456310' {
echo 'Loading Linux 3.19.8 ...'
linux /boot/vmlinuz-3.19.8 root=UUID=6e8a9edf-c57c-4411-8189-074aaa456310 ro
initrd /boot/initrd.img-3.19.8
menuentry 'Ubuntu, with Linux 3.19.8 (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.8-recovery-6e8a9edf-c57c-4411-8189-074aaa456310' {
echo 'Loading Linux 3.19.8 ...'
linux /boot/vmlinuz-3.19.8 root=UUID=6e8a9edf-c57c-4411-8189-074aaa456310 ro recovery nomodeset
initrd /boot/initrd.img-3.19.8
chunli@linux:~$
sudo reboot
|
连接到Linux:
1
2
3
4
| ssh chunli@11.11.11.6
Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.19.8 x86_64)
chunli@linux:~$ uname -r
3.19.8
|
到此,新的内核启动成功.
|
|