[排错] RHEL 解决使用 yum 命令时卡住

报错代码

# yum update 
Updating Subscription Management repositories.
Unable to read consumer identity

可尝试的解决方法一:修改 /etc/yum/pluginconf.d/subscription-manager.conf 文件

# vim /etc/yum/pluginconf.d/subscription-manager.conf

将以下内容:

......
[main] 
enabled=1
......

修改为:

......
[main] 
enabled=0
......

可尝试的解决方法二:安装对应的 katello-ca-consumer-latest.noarch.rpm 软件包

(步骤略)

(补充:katello-ca-consumer-latest.noarch.rpm 软件包下载自对应的 Red Hat Satellite 服务器,补充链接:Red Hat Satellite client register

[内容] Linux 是 BIOS 启动模式还是 UEFI 启动模式的判断

内容一:Linux 判断是 BIOS 启动模式还是 UEFI 启动模式的原理

系统的的启动模式分为 BIOS 启动模式和 UEFI 启动模式两种 (截止到本文发表时)。如果 Linux 是使用的 UEFI 启动模式,则系统里会有 /sys/firmware/efi 文件,若没有此文件的话则代表系统的启动模式为 BIOS。

内容二:Linux 判断是 BIOS 启动模式还是 UEFI 启动模式的方法

# [ -d /sys/firmware/efi ] && echo 'The boot is UEFI' || echo 'The boot is BIOS'

补充:BIOS 启动模式和 UEFI 启动模式的特点

UEFI (Unified Extensible Firmware Interface) 是一种比 BIOS (Basic Input/Outpu System) 更新的启动方式,相比而言主要的区别是 UEFI (Unified Extensible Firmware Interface) 支持 Secure Boot。开启 Secure Boot 的系统在启动的时候更安全,但是某些杀毒软件会让开启 Secure Boot 的系统卡住。

[步骤] 系统升级 (从 openSUSE Leap 15.3 升级到 openSUSE Leap 15.4)

步骤一:显示现在的系统版本

# cat /etc/*release*
NAME="openSUSE Leap"
VERSION="15.3"
ID="opensuse-leap"
ID_LIKE="suse opensuse"
VERSION_ID="15.3"
PRETTY_NAME="openSUSE Leap 15.3"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:leap:15.3"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"

(注意:确保显示的系统版本是 openSUSE Leap 15.3)

步骤二:准备升级

2.1 确认已使用的软件库

# zypper ls -d
#  | Alias                     | Name                               | Enabled | GPG Check | Refresh | Priority | Type   | URI
---+---------------------------+------------------------------------+---------+-----------+---------+----------+--------+---------------------------------------------------------------------------------------------
1  | repo-non-oss              | Non-OSS Repository                                           | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/distribution/leap/15.3/repo/non-oss/
2  | repo-oss                  | Main Repository                                              | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/distribution/leap/15.3/repo/oss/
3  | repo-update               | Main Update Repository                                       | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.3/oss/
4  | repo-update-non-oss       | Update Repository (Non-Oss)                                  | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.3/non-oss/
5  | repo-backports-update     | Update repository of openSUSE Backports                      | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.3/backports/
6  | repo-sle-update           | Update repository with updates from SUSE Linux Enterprise 15 | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.3/sle/


补充:
1) 确保以上软件库已处于 Enabled 状态
2) 手动启动这些软件库的命令如下

# zypper ar -fcg http://download.opensuse.org/distribution/leap/${releasever}/repo/non-oss/ Non-OSS Repository
# zypper ar -fcg http://download.opensuse.org/distribution/leap/${releasever}/repo/oss/ Main Repository
# zypper ar -fcg http://download.opensuse.org/update/leap/${releasever}/oss/ Main Update Repository
# zypper ar -fcg http://download.opensuse.org/update/leap/${releasever}/non-oss/ Update Repository (Non-Oss)
# zypper ar -fcg http://download.opensuse.org/update/leap/${releasever}/backports/ Update repository of openSUSE Backports
# zypper ar -fcg http://download.opensuse.org/update/leap/${releasever}/sle/ Update repository with updates from SUSE Linux Enterprise 15

2.2 刷新已使用的软件库

# zypper ref

(注意:确保刷新成功,否则请检查网络)

2.3 将所有 openSUSE Leap 15.3 软件包更新到最新版本

# zypper -n update

2.4 用 releasever 变量替换所有版本号

# sed -i 's/15.3/${releasever}/g' /etc/zypp/repos.d/*.repo

步骤三:升级系统

3.1 将版本号设置为 15.4 并刷新

# zypper --releasever=15.4 refresh

3.2 提前下载并安装 openSUSE Leap 15.4 所需的软件包

# zypper --releasever=15.4 dup --download-in-advance

3.3 升级系统

# zypper --releasever=15.4 dup

3.4 重启系统

# reboot

步骤四:后续检查

4.1 显示升级后的系统版本

# cat /etc/*release*
NAME="openSUSE Leap"
VERSION="15.4"
ID="opensuse-leap"
ID_LIKE="suse opensuse"
VERSION_ID="15.4"
PRETTY_NAME="openSUSE Leap 15.4"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:leap:15.4"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"

4.2 显示升级后已使用的软件库

# zypper ls -d
#  | Alias                     | Name                                                         | Enabled | GPG Check | Refresh | Priority | Type   | URI
---+---------------------------+------------------------------------+---------+-----------+---------+----------+--------+---------------------------------------------------------------------------------------------
1  | repo-non-oss              | Non-OSS Repository                                           | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/distribution/leap/15.4/repo/non-oss/
2  | repo-oss                  | Main Repository                                              | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/distribution/leap/15.4/repo/oss/
3  | repo-update               | Main Update Repository                                       | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.4/oss/
4  | repo-update-non-oss       | Update Repository (Non-Oss)                                  | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.4/non-oss/
5  | repo-backports-update     | Update repository of openSUSE Backports                      | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.4/backports/
6  | repo-sle-update           | Update repository with updates from SUSE Linux Enterprise 15 | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/leap/15.4/sle/

[步骤] RHEL 系统的注册 (注册到 Red Hat 官网)

正文:

步骤一:清除旧有的注册信息

1.1 清除所有的旧有注册信息

# subscription-manager remove --all

1.2 取消注册

# subscription-manager unregister

1.3 清楚所有的就有数据

# subscription-manager clean

1.4 确保所有 satellite 客户端安装包已经删除

# yum remove katello-ca-consumer-*

步骤二:确保 RHEL 系统的注册网站指向 Red Hat 官网

# vim /etc/rhsm/rhsm.conf

确保部分内容如下:

......
hostname = subscription.rhsm.redhat.com
......
baseurl = https://cdn.redhat.com
......

步骤三:注册 RHEL 系统到 Red Hat 官网

3.1 非交互式

# subscription-manager register --username <username> --password <password> --auto-attach

(注意:如果完成了本文的 2.1 就不用再执行 本文的 2.2 了)

3.2 交互式注册 RHEL 系统到 Red Hat 官网

3.2.1 交互式注册 RHEL 系统到 Red Hat 官网
# subscription-manager register
3.2.2 在 Red Hat 官网上将相关订阅 (license) 分配给系统

登录 Red Hat 官网 –> Red Hat Customer Portal –> subscriptions –> systems –> <system name> –> 添加订阅

(注意:如果是使用的 Simple Content Access 模式的话,则无需这一步)

3.2.3 刷新订阅
# subscription-manager refresh
3.2.4 查看注册状态
3.2.4.1 查看订阅的消费情况
# subscription-manager list --consumed
3.2.4.2 查看注册状态
# subscription-manager status

参考文献:

https://access.redhat.com/solutions/253273

[步骤] Linux 救援模式的进入

步骤一:挂载官方镜像

(步骤略)

步骤二:登录拯救模式

2.1 选择通过光盘启动

(步骤略)

2.2 进入拯救模式

(步骤略)

2.3 登录拯救模式

rescue login:root

步骤三:在救援模式确定系统的根 “/” 目录分区

(步骤略)


补充:
1) 物理分区可以使用 lsblk 命令、fdisk -l 或 cat /proc/partitions 命令辅助确定
2) 逻辑分区还可以可以使用 pvs 命令、lvs 命令或 lvdisplay 命令辅助确定

步骤四:在救援模式将系统的分区挂载到救援模式的 /mnt 目录

4.1 在救援模式将系统的根 “/” 分区挂载到救援模式的 /mnt 目录

tty1:rescue:~ # mount <root spartition> /mnt


补充:
1) 如果是物理分区,系统的根 “/” 分区就在救援模式的 /dev/ 目录里,例如救援模式的 /dev/sda1
2) 如果是逻辑分区,Rocky Linux & RHEL 的系统根 “/” 分区就是救援模式里的 /dev// 例如救援模式里的 /dev/vg/lv,openSUSE & SLES 的系统 “/” 分区就是救援模式里的 /dev/mapper/- 例如救援模式里的 /dev/mapper/vg-lv

4.2 在救援模式将救援模式的 /dev 目录关联到救援模式的 /mnt/dev 目录

tty1:rescue:~ # mount --rbind /dev /mnt/dev


补充:
1) 此时所有对救援模式的 /mnt/dev 目录的访问都会变成对救援模式的 /dev 目录的访问
2) 步骤 4.2、步骤 4.3 和步骤 4.4 也可以用以下命令代替:

tty1:rescue:~ # for i in proc sys dev; do mount --rbind /$i /mnt/$i ; done

4.3 在救援模式将救援模式的 /proc 目录关联到救援模式的 /mnt/proc 目录

tty1:rescue:~ # mount --rbind /proc /mnt/proc


补充:
1) 此时所有对救援模式的 /mnt/proc 目录的访问都会变成对救援模式的 /proc 目录的访问
2) 步骤 4.2、步骤 4.3 和步骤 4.4 也可以用以下命令代替:

tty1:rescue:~ # for i in proc sys dev; do mount --rbind /$i /mnt/$i ; done

4.4 在救援模式将救援模式的 /sys 目录关联到救援模式的 /mnt/sys 目录

tty1:rescue:~ # mount --rbind /sys /mnt/sys


补充:
1) 此时所有对救援模式的 /mnt/sys 目录的访问都会变成对救援模式的 /sys 目录的访问
2) 步骤 4.2、步骤 4.3 和步骤 4.4 也可以用以下命令代替:

tty1:rescue:~ # for i in proc sys dev; do mount --rbind /$i /mnt/$i ; done

4.5 在救援模式将救援模式的 /run 目录关联到救援模式的 /mnt/run 目录 (选做)

tty1:rescue:~ # mount --rbind /run /mnt/run

(补充:此时所有对救援模式的 /mnt/run 目录的访问都会变成对救援模式的 /run 目录的访问)

步骤五:将当前的根 “/” 目录从救援模式的根 “/” 目录切换到系统的根 “/” 目录

5.1 将当前的根 “/” 目录从救援模式的根 “/” 目录切换到系统的根 “/” 目录

tty1:rescue:~ # chroot /mnt

(补充:这里以 /mnt 作为系统根 “/” 目录为例)

5.2 在系统模式挂载所有需要开机自动挂载的目录

bash-4.3# mount -a

5.3 在系统模式确认当前根 “/” 目录下的目录

bash-4.3# ls
bin boot dev home lib lib64 mnt opt proc root run sbin selinux srv sys tmp usr var

(补充:这里显示的是常见的 Linux 根 “/” 目录 下的目录)

步骤六:重启系统

6.1 从当前系统的根 “/” 目录切换回救援模式的根 “/” 目录

bash-4.3# exit

6.2 重启系统

tty1:rescue:~ # reboot