RHEL6
cat <<- EOF>> /etc/yum.repos.d/local.repo
[localrepo]
name=localrepo
baseurl=file:///mnt/rhel6
enable=1
gpgcheck=0
EOF
RHEL7
cat <<- EOF>> /etc/yum.repos.d/local.repo
[localrepo]
name=localrepo
baseurl=file:///mnt/rhel7
enable=1
gpgcheck=0
EOF
RHEL8
cat << EOF > /etc/yum.repos.d/local.repo
[localrepo]
name=localreop
baseurl=file:///mnt/rhel8/BaseOS
enable=1
gpgcheck=0
[localrepo_app]
name=localrepo_app
baseurl=file:///mnt/rhel8/AppStream
enable=1
gpgcheck=0
EOF
后续操作
1 创建相应目录
mkdir /mnt/rhelX
(X为具体版本)
2 将指定镜像挂载至相应目录mount /dev/sr0 /mnt/rhelX
(X为具体版本)
3 执行yum clean all
命令清除原先yum缓存
4 执行yum makecache
命令重建yum缓存