CentOS源码更新Linux最新内核



查看当前的内核版本
[root@linux home]# uname -a
Linux linux 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
2
2
 
1
[root@linux home]# uname -a
2
Linux linux 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@linux home]# ll | grep linux
-rw-r--r--. 1 root root 103047692 May 24 17:35 linux-4.16.11.tar.xz
2
2
 
1
[root@linux home]# ll | grep linux
2
-rw-r--r--. 1 root root 103047692 May 24 17:35 linux-4.16.11.tar.xz
编译准备
[root@linux boot]# ll -ahl /boot | grep config-$(uname -r)
-rw-r--r--.  1 root root 138K Aug 23  2017 config-3.10.0-693.el7.x86_64
[root@linux boot]# cp config-3.10.0-693.el7.x86_64 .config
3
3
 
1
[root@linux boot]# ll -ahl /boot | grep config-$(uname -r)
2
-rw-r--r--.  1 root root 138K Aug 23  2017 config-3.10.0-693.el7.x86_64
3
[root@linux boot]# cp config-3.10.0-693.el7.x86_64 .config
这个文件是配置文件
需要拷贝出一个配置文件
[root@linux linux-4.16.11]# make menuconfig
1
1
 
1
[root@linux linux-4.16.11]# make menuconfig
选择要编译的模块,生成当前目录的配置文件
开始编译
[root@linux linux-4.16.11]# make -j 28
1
1
 
1
[root@linux linux-4.16.11]# make -j 28
编译完成
  OBJCOPY arch/x86/boot/setup.bin
  BUILD   arch/x86/boot/bzImage
Setup is 16860 bytes (padded to 16896 bytes).
System is 6937 kB
CRC 5dda9dcd
Kernel: arch/x86/boot/bzImage is ready  (#1)
6
6
 
1
  OBJCOPY arch/x86/boot/setup.bin
2
  BUILD   arch/x86/boot/bzImage
3
Setup is 16860 bytes (padded to 16896 bytes).
4
System is 6937 kB
5
CRC 5dda9dcd
6
Kernel: arch/x86/boot/bzImage is ready  (#1)
安装
[root@linux linux-4.16.11]# make modules_install
...
  INSTALL sound/usb/snd-usbmidi-lib.ko
  INSTALL sound/usb/usx2y/snd-usb-us122l.ko
  INSTALL sound/usb/usx2y/snd-usb-usx2y.ko
  INSTALL virt/lib/irqbypass.ko
  DEPMOD  4.16.11
7
7
 
1
[root@linux linux-4.16.11]# make modules_install
2
...
3
  INSTALL sound/usb/snd-usbmidi-lib.ko
4
  INSTALL sound/usb/usx2y/snd-usb-us122l.ko
5
  INSTALL sound/usb/usx2y/snd-usb-usx2y.ko
6
  INSTALL virt/lib/irqbypass.ko
7
  DEPMOD  4.16.11
[root@linux linux-4.16.11]# make install 
sh ./arch/x86/boot/install.sh 4.16.11 arch/x86/boot/bzImage \
	System.map "/boot"
 
1
[root@linux linux-4.16.11]# make install 
2
sh ./arch/x86/boot/install.sh 4.16.11 arch/x86/boot/bzImage \
3
    System.map "/boot"
启动内核作为引导
[root@linux linux-4.16.11]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.16.11
Found initrd image: /boot/initramfs-4.16.11.img
Found linux image: /boot/vmlinuz-3.10.0-862.3.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-862.3.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-842357192c9244d09270f31a145fa5e1
Found initrd image: /boot/initramfs-0-rescue-842357192c9244d09270f31a145fa5e1.img
done
[root@linux linux-4.16.11]# 
12
12
 
1
[root@linux linux-4.16.11]# grub2-mkconfig -o /boot/grub2/grub.cfg
2
Generating grub configuration file ...
3
Found linux image: /boot/vmlinuz-4.16.11
4
Found initrd image: /boot/initramfs-4.16.11.img
5
Found linux image: /boot/vmlinuz-3.10.0-862.3.2.el7.x86_64
6
Found initrd image: /boot/initramfs-3.10.0-862.3.2.el7.x86_64.img
7
Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64
8
Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img
9
Found linux image: /boot/vmlinuz-0-rescue-842357192c9244d09270f31a145fa5e1
10
Found initrd image: /boot/initramfs-0-rescue-842357192c9244d09270f31a145fa5e1.img
11
done
12
[root@linux linux-4.16.11]# 
这里没能启动成功
是因为系统是Legacy时候才找这个启动配置
UEFI模式的话是要去
/boot/efi/EFI/centos
下面找grub.cfg文件的
这时候在efi shell下是无法拷贝的
只能挂载镜像文件然后进入救援模式,然后找到挂载点的文件系统,进去之后把
/boot/grub2/grub.cfg 拷贝到  /boot/efi/EFI/centos/grub.cfg
另外启动的话,默认的还是以前的kernel,是保存在一个配置文件中
可以通过修改下面这个文件修改saved=0
vim /etc/default/grub/grub.cfg
修改
GRUB_DEFAULT=0
表示 GRUB初始化页面的第一个内核作为默认内核
这样就可以正常启动了
[root@localhost centos]# uname -a
Linux localhost.localdomain 4.16.11 #1 SMP Thu May 24 19:35:11 CST 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost centos]# 
 
1
[root@localhost centos]# uname -a
2
Linux localhost.localdomain 4.16.11 #1 SMP Thu May 24 19:35:11 CST 2018 x86_64 x86_64 x86_64 GNU/Linux
3
[root@localhost centos]# 








猜你喜欢

转载自www.cnblogs.com/kongchung/p/9084973.html