1. 挂载iso文件

首先要把redhat iso文件上传至系统中 ;
image.png

临时挂载

创建挂载目录并挂载iso文件

  1. mkdir /mnt
  2. mount -o loop -t iso9660 /root/rhel-8.2-X86_64-dvd.iso /mnt
  1. 挂载成功可,可通过df -hl查看挂载情况
  1. root@rhel8 ~]# df -hl | grep -v tmpfs
  2. Filesystem Size Used Avail Use% Mounted on
  3. /dev/nvme0n1p1 20G 13G 7.8G 62% /
  4. /dev/loop0 7.9G 7.9G 0 100% /mnt

永久挂载

  1. [root@rhel8 ~]# vim /etc/fstab
  2. UUID=1ddeda22-dae5-4422-a083-8f6e206cb163 / xfs defaults 0 0
  3. UUID=a86a861e-e1bb-4aed-a0e2-544431a0ecb4 swap swap defaults 0 0
  4. /root/rhel-8.2-x86_64-dvd.iso /mnt iso9660 defaults 0 0

2. 更新yum源文件

  1. [root@rhel8 ~]# vim /etc/yum.repos.d/redhat8.repo
  2. [appstream]
  3. name=redhat8
  4. baseurl=file:///mnt/AppStream
  5. enabled=1
  6. gpgcheck=0
  7. [baseos]
  8. name=baseos
  9. baseurl=file:///mnt/BaseOS
  10. enabled=1
  11. gpgcheck=0

若Redhat为7.0或者以前,需留意baseurl的路径为file:///mnt/. 我自己个人觉得是因为Redhat8.0这边版本较之前的版本多了AppStream和BaseOS的文件夹.
image.png
更新完毕后,保存退出;
清除yum缓存

  1. [root@rhel8 ~]# yum clean all
  2. Updating Subscription Management repositories.
  3. Unable to read consumer identity
  4. This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
  5. 12 files removed
  6. [root@rhel8 ~]#
  1. 更新yum缓存
  1. [root@rhel8 ~]# yum makecache
  2. Updating Subscription Management repositories.
  3. Unable to read consumer identity
  4. This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
  5. redhat8 87 MB/s | 5.8 MB 00:00
  6. baseos 116 MB/s | 2.3 MB 00:00
  7. Last metadata expiration check: 0:00:01 ago on Sun 20 Mar 2022 12:06:12 PM CST.
  8. Metadata cache created.
  9. [root@rhel8 ~]#

3. 检验yum更新源可用性

  1. [root@rhel8 ~]# yum list