Centos 6.5 upgrade to Centos7 guide

1. Background

Due to the early construction of a certain business system, the operating system used is relatively outdated, and it is still a centos6.5 system. Due to the need for localization, the system needs to be upgraded to BClinux 8.6, but the official display does not support the upgrade from centos 6.x to 8. Upgrade centos6.5 to the latest version of centos7, that is, centos7.9 and then upgrade. Combined with related practices, Centos6.5 only supports upgrading to the highest version of Centos7.2 (version 1511), and then upgrade to 7.9; due to the upgrade across major versions, and the 6.5YUM source on Redhat's official website has expired and is unavailable, in summary, special Organize and record the upgrade process for later reference guidance. If it is inappropriate, thanks for criticism and correction. NOTE : There are two phases to upgrading to RHEL 8. You first need to upgrade your system from RHEL 6 to RHEL 7 and then to RHEL 8. Back up important data before upgrading, or take a snapshot of the virtual machine, or even back up the whole machine.

insert image description here
An in-place upgrade from RHEL 6 to RHEL 8 requires the following major steps:

1. To prepare for the RHEL 6 system, update the RHEL 6 system to the latest version of RHEL 6.10.
2. Conduct a pre-upgrade assessment of the RHEL 6 system and resolve the reported issues.
3. Perform an in-place upgrade to RHEL 7.9.
4. Prepare the RHEL 7 system to upgrade to RHEL 8, and update the RHEL 7 system to the latest version of RHEL 7.9.
5. Conduct a pre-upgrade assessment of the RHEL 7 system and resolve issues found during this phase.
6. Perform an in-place upgrade to RHEL 8.
7. Check the status of the upgraded system.


❥ Resource links : Upgrade from RHEL 6 to RHEL 8 , wiki , Release Notes , kernel mirror site , preparations before RHEL 6 system upgrade

2. Preparations before upgrading from 6.5 to 7.2


1) Version confirmation before upgrade: cat /etc/redhat-release

Upgrade steps: Centos6.X —>Centos7.2 ----> Centos7.9

Note : 7.2 is the highest version that supports upgrades. When upgrading other versions, the error message Downloading failed: invalid data in .treeinfo: No section:'checksums' will appear;

Solve the problem of the /usr directory mounted on a separate partition

mkdir /mnt/usr/
mkdir /mnt/root
mount --bind / /mnt/root
mount --bind /usr /mnt/usr
rsync -aHAXv /mnt/usr/* /mnt/root/usr/

After deleting /etc/fstab related auto-mount configuration items after booting, reboot

2) Replace the YUM source:

Since CentOS 6 has been discontinued, we need to point yum to the vault repository, execute the following command:

#备份原有的
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) Upgrade to help detect the upgrade environment and update after confirming that it is normal

#升级前检测,该过程会看到哪些包将受到此升级的影响
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  #查看系统上残留的软件包,尽量清理掉

Note : When the preupg command is run without other options, it generates result.html and preupg_results-*.tar.gz files in the directory /root/preupgrade/; evaluation results are saved in /root/preupgrade-results/ preupg_results-190130083547.tar.gz, evaluate before the system upgrade, use the graphical interface to open and view the evaluation report, and solve the corresponding problems. In addition, the /var/log/upgrade.log file lists the problems found during the upgrade phase. Use the yum check dependencies command to check for dependency errors;

insert image description here

4) Configure and adjust the shared library after restarting: relevant experience shows that after the upgrade, the shared library will cause ssh and command execution to log in abnormally

3. The process of upgrading from 7.2 to 7.9

#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. Process error handling

4.1. An error message "File contains no section headers" is reported when installing redhat-upgrade-tool

insert image description here
This is because the repo configuration file is wrong and the YUM repo header information is missing; solution: add the missing yum header information to [centos6-upgrade], as shown below:

[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. When installing redhat-upgrade-tool, an error message "Couldn't resolve host dev.centos.org" was reported

insert image description here
The centos official website has stopped centos6-related services, and the website dev.centos.org has stopped serving. Here we manually install the rpm packages related to redhat-upgrade-tool offline. Or change to https://buildlogs.centos.org/centos/6/upg/x86_64/

4.3. An error is reported when simulating an upgrade: Unable to import openscap related files

insert image description here
The above error is reported because the openscap version is too high and needs to be downgraded; solution: uninstall the currently installed openscap version, download and install openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm, execute:

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. The test result of the simulated upgrade reports an error: X11 EXTREME problem

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.

This is because centos7 has redesigned the X11 desktop environment; while centos6 currently has no desktop requirements for the installed software, choose to uninstall the X11 desktop environment. Execution: yum groupremove -y “Desktop” “X Window System”

4.5. The detection result of the simulated upgrade exists: about the EXTREME problem of pcnet32

Error message:

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.

This is because some resources use vmware, which provides a default network card type of pcnet32, and el7 does not provide a pcnet32 network card driver by default.

Solution: Find the .vmx file in the virtual machine storage location specified by vmware, ethernet0.virtualDev = "pcnet32" or something else. Modify it to:
ethernet0.virtualDev = "e1000"' (if not received add)

4.6. After the upgrade, it prompts that the library file loading failed, and an error is reported: grep: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or director

ls -l /usr/lib64/libpcre.so*  //查看升级后centos7的相关库
 
lrwxrwxrwx 1 root root 16 315 14:13 /usr/lib64/libpcre.so -> libpcre.so.1.2.0
 
lrwxrwxrwx 1 root root 16 315 14:12 /usr/lib64/libpcre.so.1 -> libpcre.so.1.2.0
 
-rwxr-xr-x 1 root root 398272 1120 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, python problem occurs in yum update

#挂载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

Related resources: yum FAQ

4.8. Unable to ssh login after upgrade (missing file libsasl2.so.2)

1) After logging in to the local console, execute: journalctl -f -u sshd, you can see that the missing file libsasl2.so.2 is reported as an error, as shown below:

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

2) Yum can't be used because it is indeed libsasl2.so.2 file, here we also make a soft connection:

##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. The grep command reports an error, and the libpcre.so.0 file is missing

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. The network card fails to start, but the ip address is obtained normally, and an error is reported: Failed to start LSB: Bring up/down networking.

The reason why the network card cannot be used is that the MAC address has been changed after the system, but the configuration file inside the system has not been updated, which leads to the inconsistency between the real MAC address and the MAC address in the configuration file. The error of Failed to start LSB: Bring up/down networking is caused by the fact that the real MAC address after the upgrade does not match the MAC address of the configuration file. You can use the following three methods to debug and restore, and finally don’t forget to restart the system.

The first method is to close NetworManager directly, execute: systemctl stop NetworkManager, the centos7 system does not start this service

The second way to modify the configuration file

/etc/udev/rules.d/70-persistent-net.rules as long as the MAC address in the 70-persistent-net.rules configuration file is the same as the MAC address of ifcfg-xxx. But I opened the 70-persistent-net.rules configuration file and found that the configuration file is full of comments, and then directly added the MAC address corresponding to HWADDR=MAC in the ifcfg-xxx file, but after modifying the configuration file, it still prompts an error. Vim /etc/udev/rules.d/70-persistent-net.rules added to the network card is not easy to use

The third method: use this command to clear the protocol address, but it still doesn’t work. In desperation, restart the system and find that the network service returns to normal after restarting.

ip addr flush dev ens33/eth0This method can successfully solve the problem

4.11, YUM cleaning and uninstalling openldap leads to libldap-2.4.so.2: cannot open shared object file

Note: After uninstalling openldap, yum and sshd crashed;

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

5. Upgrade Centos 7.9 to BCLinux 8.6

6. Appendix: Others

6.1. An error is reported when executing the command in CentOS 8: Failed to set locale, defaulting to C.UTF-8

reason:

1. The corresponding language pack is not installed.
2. The correct language environment is not set.

Solution 1:

To install the language pack, you need to use the command locale to set the language environment
locale -a#View the language packs installed in the current system
yum install glibc-langpack-zh#Install Chinese language pack
dnf install glibc-langpack-en#Install English language pack, or
dnf install langpacks-en glibc-all-langpacks -y#Install English language pack

Solution 2:

Set the correct locale
echo “export LC_ALL=en_US.UTF-8” >> /etc/profile
source /etc/profile #Or execute:
locale -gen en_US.UTF-8

6.2. Definition of kernel version:

Version nature: main branch ml (mainline), stable version (stable), long-term maintenance version lt (longterm)
version naming format is "ABC":

The number A is the kernel version number: the version number will only change when there is a major change in the code and the concept of the kernel. There have been two changes in history: the first is
version 1.0 in 1994, and the second is 2.0 in 1996. version, the third release was version 3.0 in 2011, but this time there has been no major change in the concept of the kernel. The
number B is the main version number of the kernel: the main version number is assigned according to the traditional odd-even system version number: The odd number is the development version, and the even number is the stable
version. The number C is the minor version number of the kernel: the minor version number will change when the kernel adds security patches, fixes bugs, implements new features or drives

#内核升级

#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

Guess you like

Origin blog.csdn.net/ximenjianxue/article/details/132645265