typora/note/linux/centos/centos7.9升级内核.md
2024-12-12 10:48:55 +08:00

69 lines
1.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### 1. 更新系统
```bash
yum update -y
```
### 2.添加elrepo软件源
```bash
yum install vim -y
vi /etc/yum.repos.d/elrepo.repo
# 添加以下内容
cat > /etc/yum.repos.d/elrepo.repo << EOF
[elrepo]
name=elrepo
baseurl=https://mirrors.aliyun.com/elrepo/archive/kernel/el7/x86_64
gpgcheck=0
enabled=1
EOF
```
### 3. 刷新源数据缓存
```bash
yum clean all && yum makecache
```
### 4. 安装5.4内核
#### 4.1 列出可用内核
```bash
[root@centos7 ~]# yum list kernel-lt
已加载插件fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
可安装的软件包
kernel-lt.x86_64 5.4.265-1.el7.elrepo elrepo
```
#### 安装指定内核
```bash
yum install -y kernel-lt-5.4.265
yum install -y kernel-lt-devel-5.4.265
```
### 5. 查看安装内核版本
```bash
awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
```
### 6. 设置默认内核
```bash
grub2-set-default 0
```
### 7. 重启
```bash
reboot
```