linux yum 升级内核

太久的centos7 镜像,6年以前的东西了,内核还是3.10 ,最新都5.10了

 

1、 增加导入 elrepo,红帽的 企业版linux源

ELRepo 仓库是基于社区的用于企业级 Linux 仓库,提供对 RedHat Enterprise (RHEL) 和 其他基于 RHEL的 Linux 发行版(CentOS、Scientific、Fedora 等)的支持。 
ELRepo 聚焦于和硬件相关的软件包,包括文件系统驱动、显卡驱动、网络驱动、声卡驱动和摄像头驱动等。

#导入ELRepo仓库的公共密钥

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

#安装ELRepo仓库的yum源

rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
 
yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
yum --enablerepo=elrepo-kernel install kernel-ml
 

查看系统上的所有可用内核:

$ sudo awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
 

设置新的内核为grub2的默认版本

服务器上存在4 个内核,我们要使用 4.18 这个版本,可以通过 grub2-set-default 0 命令或编辑 /etc/default/grub 文件来设置

方法1、通过 grub2-set-default 0 命令设置

其中 0 是上面查询出来的可用内核

grub2-set-default 0

方法2、编辑 /etc/default/grub 文件

设置 GRUB_DEFAULT=0,通过上面查询显示的编号为 0 的内核作为默认内核:

$ vim /etc/default/grub GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" GRUB_DEFAULT=0 GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=cl/root rhgb quiet" GRUB_DISABLE_RECOVERY="true"

生成 grub 配置文件并重启

$ grub2-mkconfig -o /boot/grub2/grub.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-4.18.7-1.el7.elrepo.x86_64 Found initrd image: /boot/initramfs-4.18.7-1.el7.elrepo.x86_64.img Found linux image: /boot/vmlinuz-3.10.0-862.11.6.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-862.11.6.el7.x86_64.img Found linux image: /boot/vmlinuz-3.10.0-514.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-514.el7.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-063ec330caa04d4baae54c6902c62e54 Found initrd image: /boot/initramfs-0-rescue-063ec330caa04d4baae54c6902c62e54.img done

$ reboot
 
添加docker-ce 的源,社区版docker
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
 
 
posted @ 2021-05-08 09:52  yangxl-dev  阅读(373)  评论(0)    收藏  举报