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
 
  • 下载最新的内核
[root@linux home]# ll | grep linux
-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
这个文件是配置文件
需要拷贝出一个配置文件
[root@linux linux-4.16.11]# make menuconfig
选择要编译的模块,生成当前目录的配置文件
 
  • 开始编译
[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)
 
  • 安装
[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
[root@linux linux-4.16.11]# make install
sh ./arch/x86/boot/install.sh 4.16.11 arch/x86/boot/bzImage \
 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]# 
 
  • 失败分析
这里没能启动成功
是因为系统是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]# 
 
 
 
 
 

<wiz_tmp_tag id="wiz-table-range-border" contenteditable="false" style="display: none;">





posted @ 2018-05-24 21:29  kongchung  阅读(1743)  评论(0编辑  收藏  举报