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;">






免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM