centos7 內核管理

查看linux內核版本

[root@zabbix ~]# uname -r 
4.4.162-1.el7.elrepo.x86_64
[root@zabbix ~]# cat /proc/version 
Linux version 4.4.162-1.el7.elrepo.x86_64 (mockbuild@Build64R7) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) ) #1 SMP Sat Oct 20 11:33:06 EDT 2018

查詢當前使用的系統

[root@zabbix ~]# uname  -a 
Linux zabbix 4.4.162-1.el7.elrepo.x86_64 #1 SMP Sat Oct 20 11:33:06 EDT 2018 x86_64 x86_64 x86_64 GNU/Linux

列出當前linux系統的版本

[root@zabbix ~]# rpm -aq | grep kernel 
kernel-tools-3.10.0-693.el7.x86_64
kernel-tools-libs-3.10.0-693.el7.x86_64
kernel-3.10.0-1062.1.2.el7.x86_64
abrt-addon-kerneloops-2.1.11-55.el7.centos.x86_64
kernel-lt-4.4.162-1.el7.elrepo.x86_64
kernel-3.10.0-693.el7.x86_64
kernel-headers-3.10.0-957.21.3.el7.x86_64

刪除老版本的linux內核,

重要的事情說三遍:

不要把正在使用的linux內核刪除了;

不要把正在使用的linux內核刪除了;

不要把正在使用的linux內核刪除了;

[root@zabbix ~]# yum remove kernel-3.10.0-693.el7.x86_64 
已加載插件:fastestmirror, langpacks
正在解決依賴關係
--> 正在檢查事務
---> 軟件包 kernel.x86_64.0.3.10.0-693.el7 將被 刪除
--> 解決依賴關係完成
base/7/x86_64                                            | 3.6 kB     00:00     
...... # 省略

  正在刪除    : kernel-3.10.0-693.el7.x86_64                                                        1/1 
  驗證中      : kernel-3.10.0-693.el7.x86_64                                                        1/1 

刪除:
  kernel.x86_64 0:3.10.0-693.el7                                                                        

完畢!

重新編譯引導文件 

[root@zabbix ~]# grub2-mkconfig -o /boot/grub2/grub.cfg    

Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.4.162-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-4.4.162-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1062.1.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1062.1.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-8422b7e99dae4e2ca28592b1bd6898ce
Found initrd image: /boot/initramfs-0-rescue-8422b7e99dae4e2ca28592b1bd6898ce.img
done

查看當前linux內核kernel 默認啓動版本

[root@zabbix ~]# grub2-editenv list 
saved_entry=CentOS Linux (4.4.162-1.el7.elrepo.x86_64) 7 (Core)
[root@zabbix ~]# 

修改當前linux內核kernel 默認啓動版本

[root@zabbix ~]# cat /boot/grub2/grub.cfg # 查看所有內核
......#內容省略
### BEGIN /etc/grub.d/10_linux ###
menuentry 'CentOS Linux (3.10.0-1062.4.1.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-1062.1.2.el7.x86_64-advanced-17dac73b-6bf2-46fe-a9f6-fdf1d11a24dd'
......#內容省略
menuentry 'CentOS Linux (4.4.162-1.el7.elrepo.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-4.4.162-1.el7.elrepo.x86_64-advanced-17dac73b-6bf2-46fe-a9f6-fdf1d11a24dd' {	
......#內容省略

[root@zabbix ~]# grub2-set-default 'CentOS Linux (4.4.162-1.el7.elrepo.x86_64) 7 (Core)'  # 設置內核默認啓動

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章