Centos 6.5 升级到Centos7指导手册

一、背景

某业务系统因建设较早,使用的OS比较过时,还是centos6.5的系统,因国产化需要,需将该系统升级到BClinux 8.6,但官方显示不支持centos 6.x升级到8,需先将centos6.5升级到centos7的最新版,即centos7.9后再升级。后结合相关实践,Centos6.5只支持升级到最高Centos7.2版本(1511版本),之后再升级到7.9;因升级跨大版本升级,且Redhat官网 6.5YUM源已过期不可用,综上,特整理记录该升级过程,以作后期参考指导,不妥之处,感谢批评指正。注意:升级到 RHEL 8 分为两个阶段。首先需要将系统从 RHEL 6 升级到 RHEL 7,然后再升级到 RHEL 8。升级前对重要数据备份,或对虚拟机做好快照,甚至整机备份。

RHEL 6 原位升级到 RHEL 8 需要以下主要步骤:

1、为 RHEL 6 系统进行准备,将 RHEL 6 系统更新到 RHEL 6.10 的最新版本。

2、对 RHEL 6 系统进行升级前评估,并解决报告的问题。

3、执行到 RHEL 7.9 的原位升级。

4、准备 RHEL 7 系统以升级到 RHEL 8,并将 RHEL 7 系统更新至 RHEL 7.9 的最新版本。

5、对 RHEL 7 系统进行升级前评估,并解决在这个阶段中发现的问题。

6、执行到 RHEL 8 的原位升级。

7、检查升级的系统状态。

❥ 资源链接从 RHEL 6 升级至 RHEL 8wikiRelease Noteskernel镜像站RHEL 6 系统升级前准备

二、6.5升级7.2前准备

1)升级前版本确认:cat /etc/redhat-release

升级步骤: Centos6.X --->Centos7.2 ----> Centos7.9

注意:7.2是支持升级的最高版本,升级其余版本将会出现Downloading failed: invalid data in .treeinfo: No section:'checksums'的错误提示;

解决单独分区挂载的/usr目录问题

bash 复制代码
mkdir /mnt/usr/
mkdir /mnt/root
mount --bind / /mnt/root
mount --bind /usr /mnt/usr
rsync -aHAXv /mnt/usr/* /mnt/root/usr/

删除/etc/fstab相关开机自动挂载配置项后,reboot重启

2)更换YUM源:

由于 CentOS 6 已停产,我们需要将 yum 指向 vault 仓库,执行以下命令:

bash 复制代码
#备份原有的
cd /etc/yum.repos.d/
mkdir repo6_backup
mv *.repo ./repo6_backup
#下载vault 仓库的repo
curl https://www.getpagespeed.com/files/centos6-eol.repo --output /etc/yum.repos.d/CentOS-Base.repo
或
wget  https://www.getpagespeed.com/files/centos6-eol.repo -O /etc/yum.repos.d/CentOS-Base.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
#因官方源不可用,故需修改配置更新源到其他镜像站
vi /etc/yum.repos.d/upgrade.repo  //如下所示
[upgrade]
name=upgrade
baseurl=https://buildlogs.centos.org/centos/6/upg/x86_64/
enable=1
gpgcheck=0

#安装升级助手
yum erase openscap -y   #由于centos 6.5自带的安全助手版本较高,卸载了装个更老的,更多参见http://www.open-scap.org/,Security Content Automation Protocol(SCAP)
yum install https://buildlogs.centos.org/centos/6/upg/x86_64/Packages/openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm
yum install redhat-upgrade-tool preupgrade-assistant-contents -y  #或者尝试以下链接
yum install ftp://ftp.pbone.net/mirror/ftp.scientificlinux.org/linux/scientific/6.5/x86_64/updates/fastbugs/openscap-1.0.8-1.el6_5.x86_64.rpm  -y   
yum install https://buildlogs.centos.org/centos/6/upg/x86_64/Packages/openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm -y

#如果提示:No package redhat-upgrade-tool available,执行
yum install https://buildlogs.centos.org/centos/6/upg/x86_64/Packages/preupgrade-assistant-1.0.2-33.0.3.el6.centos.x86_64.rpm -y
yum install https://buildlogs.centos.org/centos/6/upg/x86_64/Packages/preupgrade-assistant-contents-0.5.13-1.0.5.el6.centos.noarch.rpm -y
yum install https://buildlogs.centos.org/centos/6/upg/x86_64/Packages/preupgrade-assistant-ui-1.0.2-33.0.3.el6.centos.x86_64.rpm -y
yum install https://buildlogs.centos.org/centos/6/upg/x86_64/Packages/redhat-upgrade-tool-0.7.22-3.el6.centos.noarch.rpm -y

3)升级助力检测升级环境确认正常后update

bash 复制代码
#升级前检测,该过程会看到哪些包将受到此升级的影响
preupg -l    //该命令会耗费几分钟到几十分钟时间
preupg -s CentOS6_7  //运行模拟升级工具,不过真的升级,相当于升级检测,升级检测通过后,在线下载centos7镜像,或本地上传后使用本地镜像也可以
Preupg tool doesn't do the actual upgrade.
Please ensure you have backed up your system and/or data in the event of a failed upgrade
that would require a full re-install of the system from installation media.
Do you want to continue? y/n
y #此处输入y
Gathering logs used by preupgrade assistant:
All installed packages : 01/11 ...finished (time 00:00s)
All changed files : 02/11 ...finished (time 02:44s)
Changed config files : 03/11 ...finished (time 00:00s)
All users : 04/11 ...finished (time 00:00s)
All groups : 05/11 ...finished (time 00:00s)
Service statuses : 06/11 ...finished (time 00:00s)
All installed files : 07/11 ...finished (time 00:02s)
...
Tarball with results is stored here /root/preupgrade-results/preupg_results-210324171443.tar.gz .
The latest assessment is stored in directory /root/preupgrade .
Summary information:
We found some critical issues. In-place upgrade is not advised.
Read the file /root/preupgrade/result.html for more details.
Upload results to UI by command:
e.g. preupg -u http://127.0.0.1:8099/submit/ -r /root/preupgrade-results/preupg_results-*.tar.gz .

#根据模拟升级的检测结果进行确认和评估,存在EXTREME错误则无法进行下一步升级操作
preupg --riskcheck --verbose

#导入RPM签名证书,下面任选其一
rpm --import https://mirrors.ustc.edu.cn/epel/RPM-GPG-KEY-EPEL-7
rpm --import http://mirror.centos.org/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7
rpm --import http://vault.centos.org/centos/7.0.1406/os/x86_64/RPM-GPG-KEY-CentOS-7
#在线update,一般不满足条件,任选其一执行,建议使用清华大学的源:
centos-upgrade-tool-cli --network 7 --instrepo=http://mirror.centos.org/centos/7/os/x86_64
centos-upgrade-tool-cli --network 7 --instrepo=https://mirrors.ustc.edu.cn/centos/7/os/x86_64  #或
centos-upgrade-tool-cli --network 7 --force --instrepo=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.2.1511/os/x86_64/
centos-upgrade-tool-cli --network 7 --instrepo=http://vault.centos.org/centos/7.0.1406/os/x86_64/
...
Continue with the upgrade [Y/N]? y
...
rpm install 100% [============================================================================================]
setting up system for upgrade
Finished. Reboot to start upgrade.

#离线update
wget --no-check-certificate https://archive.kernel.org/centos-vault/7.2.1511/isos/x86_64/CentOS-7-x86_64-Everything-1511.iso  #可以用CentOS-7-x86_64-DVD-1511.iso ,只有4G
wget --no-check-certificate https://vault.centos.org/7.2.1511/isos/x86_64/CentOS-7-x86_64-Everything-1511.iso(7.2G)
md5sum     //CentOS-7-x86_64-Everything-1511.iso
dba29c59117400b111633be2bf2aaf0e  CentOS-7-x86_64-Everything-1511.iso
mout -o -loop -t iso9660 /home/CentOS-7-x86_64-Everything-1511.iso /mnt/cdrom
centos-upgrade-tool-cli --iso=/home/CentOS-7-x86_64-Everything-1511.iso  #或
centos-upgrade-tool-cli --device=/dev/cdrom   //输出类似如下:
......
setting up repos...
.treeinfo                                                                                                | 1.1 kB     00:00
getting boot p_w_picpaths...
vmlinuz-redhat-upgrade-tool                                                                              | 4.7 MB     01:38
initramfs-redhat-upgrade-tool.img                                                                        |  32 MB     14:45
setting up update...
finding updates 100% [=====================================================================================================]
(1/272): acl-2.2.51-12.el7.x86_64.rpm                                                                    |  81 kB     00:00
(2/272): attr-2.4.46-12.el7.x86_64.rpm                                                                   |  66 kB     00:00
(3/272): audit-2.3.3-4.el7.x86_64.rpm                                                                    | 223 kB     00:01
(4/272): audit-libs-2.3.3-4.el7.x86_64.rpm                                                               |  77 kB     00:00
(5/272): authconfig-6.2.8-8.el7.x86_64.rpm                                                               | 399 kB     00:08
(6/272): basesystem-10.0-7.el7.centos.noarch.rpm                                                         | 5.0 kB     00:00
(7/272): bash-4.2.45-5.el7.x86_64.rpm                                                                    | 1.0 MB     00:17
(270/272): yum-plugin-fastestmirror-1.1.31-24.el7.noarch.rpm                                             |  28 kB     00:03
(271/272): zlib-1.2.7-13.el7.x86_64.rpm                                                                  |  89 kB     00:06
(272/272): zlib-devel-1.2.7-13.el7.x86_64.rpm                                                            |  49 kB     00:01

setting up system for upgrade
Finished. Reboot to start upgrade.

#或者直接执行:
cd /etc/yum.repos.d
wget http://mirrors.aliyun.com/repo/Centos-7.repo
wget https://mirrors.aliyun.com/repo/epel-7.repo
或
mount -t iso9660 -o loop CentOS-7-x86_64-DVD-1511.iso /mnt/iso #或者
mount -t auto /dev/cdrom /mnt/iso/
vi /etc/yum.repos.d/centos7.repo  //如下

[centos7]
name=CentOS 7
baseurl=file:///mnt/iso
enabled=1
gpgcheck=0

yum clean all
yum makecache
yum update  #升级所有包同时也升级软件和系统内核

#更新lib库
ln -s /usr/lib64/libsasl2.so.3.0.0 /usr/lib64/libsasl2.so.2
ln -s /usr/lib64/libpcre.so.1.2.0 /usr/lib64/libpcre.so.0

#升级完成后重启。重启后,将使用 redhat-upgrade-tool 内核启动完成CentOS 6升级
reboot   //若是提示The requested URL returned error: 404 Not Found等错误,基本上说明当前系统不支持直接升级,恢复后重装替换吧

#验证
cat /etc/centos-release

#更新软件版本
yum upgrade

rpm -qa | grep el6  #查看系统上残留的软件包,尽量清理掉

:当preupg命令在没有其他选项的情况下运行时,它会在目录中生成result.html和preupg_results-*.tar.gz文件/root/preupgrade/;评估结果保存在/root/preupgrade-results/preupg_results-190130083547.tar.gz,进行系统升级前评估,用图形界面打开查看评估报告,解决对应问题。另,/var/log/upgrade.log文件列出了升级阶段发现的问题。利用yum check dependencies命令检查依赖错误;

4)重启后配置调整共享库:相关经验表明升级后会出现共享库导致ssh,命令执行登异常问题

三、7.2升级到7.9过程

bash 复制代码
#yum配置参考上文,这里如果想先升级到6.10,配置本地6.10的YUM
wget https://vault.centos.org/6.10/isos/x86_64/CentOS-6.10-x86_64-LiveDVD.iso
mount /dev/sr0 /mnt/
cat /etc/yum.repos.d/dev.repo

[dev]
name=dev
baseurl=file:///mnt
gpgcheck=0
enabled=1

yum clean all
yum makecache
yum update -y   #就地从centos6.5升级到6。10



#下载7.9安装包
wget https://mirrors.ustc.edu.cn/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-DVD-2009.iso

#本地挂载
mount /dev/sr0 /centos10/
#配置7.10本地yum源
cat /etc/yum.repos.d/centos10.repo

[centos10]
name=centos10
baseurl=file:///centos10/
gpgcheck=0
#6.9升级到7.10,参考上文先评估
yum install preupgrade-assistant preupgrade-assistant-ui preupgrade-assistant-el6toel7 redhat-upgrade-tool
preupg -l  //无报错后再执行升级
redhat-upgrade-tool --device /mnt/

四、过程报错处理

4.1、安装redhat-upgrade-tool时报错File contains no section headers

这是因为repo配置文件错误,缺少YUM repo头信息;解决方案:将缺少的yum头信息添加上 [centos6-upgrade],如下所示:

bash 复制代码
[centos6-upgrade]
name=CentOS-$releasever - Upgrade Tool
baseurl=http://dev.centos.org/centos/6/upg/x86_64/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

4.2、安装redhat-upgrade-tool时报错Couldn't resolve host dev.centos.org

centos官网已经停止centos6相关服务,网站dev.centos.org已经停止服务。这里我们用离线方式手动安装redhat-upgrade-tool相关的rpm包。或换成https://buildlogs.centos.org/centos/6/upg/x86_64/

4.3、模拟升级时报错:无法导入openscap相关文件

上图报错是因为openscap版本太高,需要降级;解决方案:卸载当前安装的openscap版本,下载并安装openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm,执行:

bash 复制代码
rpm -qa |grep openscap  //验证当前版本
openscap-1.2.13-2.el6.x86_64
rpm -e --nodeps openscap-1.2.13-2.el6.x86_64
wget  https://buildlogs.centos.org/centos/6/upg/x86_64/Packages/openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm
yum localinstall openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm -y  #或执行
yum install https://buildlogs.centos.org/centos/6/upg/x86_64/Packages/openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm

4.4、模拟升级的检测结果报错:X11的EXTREME问题

bash 复制代码
preupg --riskcheck --verbose   //报错如下
......
INPLACERISK: EXTREME:You have GMOME Desktop Environment session as an option in your X11 session manager. CHOME Desktop Environment as a part of the yum group'Desktop'undervent serious redesign in its user interface as well as underlying technologies in Centos 7.
TCLACERISK: EXTREME: You have kDE Desktop Envirom ent session as an option in your X11session manager. KDE Desktop Environment as a part of the yum group'KDE Desktop'undervent a redesign in its user interface as well as underlying technologies in Centos 7.
TMPLACERISK: FXTREE:The kernel driver'ncnet32'reauired to service hardware present in vour svsten is not available in Centos 7. This suggests that your systen contains hardware that is not supported in CentOS 7 release.

这是由于centos7对X11桌面环境进行了重新设计;而centos6当前安装软件没有桌面要求,选择卸载X11桌面环境。执行:yum groupremove -y "Desktop" "X Window System"

4.5、模拟升级的检测结果存在:关于pcnet32的EXTREME问题

报错信息:

INPLACERISK: EXTREME: The kernel driver 'pcnet32' required to service hardware present in your system is not available in

CentOS 7. This suggests that your system contains hardware that is not supported in CentOS 7 release.

这是因某些资源采用vmware,它提供的默认网卡类型是pcnet32,el7默认没有提供pcnet32的网卡驱动。

解决方案:在vmware指定的虚拟机存储位置找到.vmx的文件,ethernet0.virtualDev = "pcnet32" 或是别的。将其修改为:

ethernet0.virtualDev = "e1000"' (如果没有收到添加)

4.6、升级后提示库文件加载失败,报错:grep: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or director

bash 复制代码
ls -l /usr/lib64/libpcre.so*  //查看升级后centos7的相关库
 
lrwxrwxrwx 1 root root 16 3月 15 14:13 /usr/lib64/libpcre.so -> libpcre.so.1.2.0
 
lrwxrwxrwx 1 root root 16 3月 15 14:12 /usr/lib64/libpcre.so.1 -> libpcre.so.1.2.0
 
-rwxr-xr-x 1 root root 398272 11月 20 2015 /usr/lib64/libpcre.so.1.2.0

#相关实践表明,centos7中只需对libpcre.so.0做软连接指向就行,执行
ln -s /usr/lib64/libpcre.so.1.2.0 /usr/lib64/libpcre.so.0
ln -s /lib64/libpcre.so.1 /lib64/libpcre.so.0
ln -s /usr/lib64/libsasl2.so.3.0.0 /usr/lib64/libsasl2.so.2

4.7、yum update出现python问题

bash 复制代码
#挂载7的镜像

mount -t iso9660 -o loop CentOS-7-x86_64-DVD-1511.iso /mnt/iso或者
mount -t auto /dev/cdrom /mnt/iso/

#备份
mv yum.repos.d yum.repos.d_backup
mkdir yum.repos.d

#7 YUM源
vi /etc/yum.repos.d/centos7.repo  //如下

[centos7]
name=CentOS 7
baseurl=file:///mnt/iso
enabled=1
gpgcheck=0

#重装python2
yum reinstall python -y

相关资源:yum FAQ

4.8、升级后无法进行ssh登录(缺失文件libsasl2.so.2)

1)本地控制台登录后,执行:journalctl -f -u sshd,可以看到报错缺失文件libsasl2.so.2,如下所示:

libsasl2.so.2: cannot open shared object file: No such file or directory

2)yum也不能使用也是因为确实libsasl2.so.2文件,这里我们也做下软连接:

bash 复制代码
##Centos 7中是有libsasl2.so.2这个库的,只不过换了名字,进入到/usr/lib64/目录下查看
cd /usr/lib64
ls libsasl2.so.* -l  //如下所示
lrwxrwxrwx. 1 root root     17 Oct 17  2016 libsasl2.so.3 -> libsasl2.so.3.0.0
-rwxr-xr-x. 1 root root 121296 Jun 10  2014 libsasl2.so.3.0.0
#做软连接到libsasl2.so.2
ln -s libsasl2.so.3 libsasl2.so.2
ls libsasl2.so.* -l  //如下所示
lrwxrwxrwx  1 root root     13 Nov 19 18:00 libsasl2.so.2 -> libsasl2.so.3
lrwxrwxrwx. 1 root root     17 Oct 17  2016 libsasl2.so.3 -> libsasl2.so.3.0.0
-rwxr-xr-x. 1 root root 121296 Jun 10  2014 libsasl2.so.3.0.0
#重启ssh
systemctl start sshd
#更新yum源
wget http://mirrors.aliyun.com/repo/Centos-7.repo
wget https://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache

4.9、grep命令报错,缺失libpcre.so.0文件

bash 复制代码
grep   //报错如下
grep: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory
#方法同4.6,加软连接
cd /usr/lib64
ls libpcre.so*   //显示如下
libpcre.so  libpcre.so.1  libpcre.so.1.2.0
ln -s libpcre.so.1 libpcre.so.0

4.10、网卡启动失败,但是ip地址获取正常,报错:Failed to start LSB: Bring up/down networking.

造成网卡不能使用的原因是,系统后MAC地址已经更改但是在系统内部的配置文件还没有更,这就导致了真实的MAC地址与配置文件中的MAC地址不一致。Failed to start LSB: Bring up/down networking 的报错就是因为升级后真实的MAC地址与配置文件的MAC地址不相符造成的,可采用如下3种办法调试恢复,最后不要忘了重启系统。

第一种办法直接关闭NetworManager,执行:systemctl stop NetworkManager ,centos7系统没启动这个服务

第二种办法修改配置文件

/etc/udev/rules.d/70-persistent-net.rules只要70-persistent-net.rules配置文件中的MAC地址与ifcfg-xxx的MAC地址相同就可以了。但是我打开70-persistent-net.rules配置文件发现配置文件全是注释,然后就直接在ifcfg-xxx文件中添加了HWADDR=MAC 对应的MAC地址,但修改完配置文件后发现还是提示错误。vim /etc/udev/rules.d/70-persistent-net.rules 网卡中添加了也不好使

第三种办法:使用这一条命令将清除协议地址,尽然还是不管用,无奈之下重启系统,发现重启后网络服务恢复正常。

ip addr flush dev ens33/eth0 这个方法是可以成功解决问题的

4.11、YUM清理卸载openldap导致libldap-2.4.so.2: cannot open shared object file

注意:当卸载掉openldap后,出现了yum、sshd奔溃的问题;

bash 复制代码
wget http://ftp.pbone.net/mirror/ftp.scientificlinux.org/linux/scientific/6.4/x86_64/updates/fastbugs/openldap-2.4.23-32.el6_4.1.x86_64.rpm

rpm -ivh --force --nodeps openldap-2.4.23-32.el6_4.1.x86_64.rpm

五、Centos 7.9升级到BCLinux 8.6

六、附录:其他

6.1、CentOS 8中执行命令报错:Failed to set locale, defaulting to C.UTF-8

原因:

1、没有安装相应的语言包。

2、没有设置正确的语言环境。

解决方法1:

安装语言包,设置语言环境需使用命令 locale
locale -a #查看目前系统已安装的语言包
yum install glibc-langpack-zh #安装中文语言包
dnf install glibc-langpack-en #安装英文语言包,或
dnf install langpacks-en glibc-all-langpacks -y #安装英文语言包

解决方法2:

设置正确的语言环境

echo "export LC_ALL=en_US.UTF-8" >> /etc/profile

source /etc/profile #或执行:

locale -gen en_US.UTF-8

6.2、内核版本的定义:

版本性质:主分支ml(mainline),稳定版(stable),长期维护版lt(longterm)

版本命名格式为 "A.B.C":

数字 A 是内核版本号:版本号只有在代码和内核的概念有重大改变的时候才会改变,历史上有两次变化:

第一次是1994年的 1.0 版,第二次是1996年的 2.0 版,第三次是2011年的 3.0 版发布,但这次在内核的概念上并没有发生大的变化

数字 B 是内核主版本号:主版本号根据传统的奇-偶系统版本编号来分配:奇数为开发版,偶数为稳定版

数字 C 是内核次版本号:次版本号是无论在内核增加安全补丁、修复bug、实现新的特性或者驱动时都会改变

bash 复制代码
#内核升级

#yum源
wget http://www.elrepo.org/elrepo-release-6-6.el6.elrepo.noarch.rpm  #Centos 6 YUM源:
wget http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm   #Centos 7 YUM源:
rpm -import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
#查看可用的内核
yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
#安装最新主线稳定版
yum -y --enablerepo=elrepo-kernel install kernel-ml

#方式2:直接rpm安装
wget https://elrepo.org/linux/kernel/el7/x86_64/RPMS/kernel-lt-4.4.185-1.el7.elrepo.x86_64.rpm
rpm -ivh kernel-lt-4.4.185-1.el7.elrepo.x86_64.rpm

#方式3:编译安装

#升级完成,修改grub内核启动顺序,内核升级完毕后,目前内核还是默认的版本,如果此时直接执行reboot命令,重启后使用的内核版本还是默认的3.10,不会使用新的5.2.2
cat /boot/grub2/grub.cfg | grep menuentry   //查看当前内核数
awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg   //查看默认启动顺序
#在grub.conf文件中决定开机使用哪个内核版本做启动的参数是default,默认值为0,代表从最新的内核启动。代表启动的内核版本从上往下依次是0、1、2等,修改新内核的启动顺序为0:
vim /etc/default/grub

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=0    #参数default更改为0即可
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"

#重新生成内核配置
grub2-mkconfig -o /boot/grub2/grub.cfg
#或者
grub2-set-default 'CentOS Linux (3.10.0-123.9.3.el7.x86_64) 7 (Core)'
#验证
grub2-editenv list
#CentOS 8 系统更改内核启动顺序与centos 7有了一些变化
grubby --default-kernel  //查看默认启动内核
grubby --info=ALL   //查看所有内核
rubby --set-default /boot/vmlinuz-4.18.0-80.11.2.el8_0.x86_64   //cenots8设置需要设置的启动的默认的内核

#对于ubuntu
vim /etc/default/grub  #将GRUB_DEFAULT=0 修改为
GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 3.13.0-166-generic"

#更新修改后的grub
update-grub

#完成后,重启
reboot
相关推荐
AI原吾8 分钟前
探索PyAV:Python中的多媒体处理利器
开发语言·python·ai·pyav
oliveira-time18 分钟前
爬虫学习8
开发语言·javascript·爬虫·python·算法
正义的彬彬侠37 分钟前
XGBoost算法Python代码实现
python·决策树·机器学习·numpy·集成学习·boosting·xgboost
昨天今天明天好多天1 小时前
【Python】解析 XML
xml·python
侯喵喵1 小时前
从零开始 blender插件开发
python·blender
SmallBambooCode1 小时前
【人工智能】阿里云PAI平台DSW实例一键安装Python脚本
linux·人工智能·python·阿里云·debian·脚本·模型训练
工业互联网专业2 小时前
Python毕业设计选题:基于django+vue的荣誉证书管理系统
python·django·vue·毕业设计·源码·课程设计
凉开水白菜2 小时前
米家通过HomeAssistant控制笔记本电脑开关机
python·电脑·智能家居·米家
萧鼎2 小时前
Python操作系统交互:subprocess库的基本应用
python·交互·subprocess
数勋API2 小时前
银行卡归属地查询API接口如何用Python调用
开发语言·python·云计算·csdn开发云