RHEL6:配置yum本地安装源

有时候需要从光盘里安装packages.
这就需要先配置yum的repos,让它从本地光盘里找packages.

挂载RHEL6系统光盘

首先挂载RHEL6光盘。
如果是硬盘上的iso文件,比如光盘路径是/tmp/rhel6.iso 那么执行下面命令将iso挂载到/mnt

# mount -o loop /tmp/rhel6.iso /mnt

如果是光盘(或者是从虚拟机插入),执行下面命令将光盘挂载到/mnt

# mount /dev/sr0 /mnt

挂载后,应该能看到/mnt下有光盘的内容。

# ls /mnt/
EFI      EULA_pt           README                    RELEASE-NOTES-it-IT.html  RELEASE-NOTES-ru-RU.html  RPM-GPG-KEY-redhat-release
EULA     EULA_zh           RELEASE-NOTES-as-IN.html  RELEASE-NOTES-ja-JP.html  RELEASE-NOTES-si-LK.html  ScalableFileSystem
EULA_de  GPL               RELEASE-NOTES-bn-IN.html  RELEASE-NOTES-kn-IN.html  RELEASE-NOTES-ta-IN.html  Server
EULA_en  HighAvailability  RELEASE-NOTES-de-DE.html  RELEASE-NOTES-ko-KR.html  RELEASE-NOTES-te-IN.html  TRANS.TBL
EULA_es  images            RELEASE-NOTES-en-US.html  RELEASE-NOTES-ml-IN.html  RELEASE-NOTES-zh-CN.html
EULA_fr  isolinux          RELEASE-NOTES-es-ES.html  RELEASE-NOTES-mr-IN.html  RELEASE-NOTES-zh-TW.html
EULA_it  LoadBalancer      RELEASE-NOTES-fr-FR.html  RELEASE-NOTES-or-IN.html  repodata
EULA_ja  media.repo        RELEASE-NOTES-gu-IN.html  RELEASE-NOTES-pa-IN.html  ResilientStorage
EULA_ko  Packages          RELEASE-NOTES-hi-IN.html  RELEASE-NOTES-pt-BR.html  RPM-GPG-KEY-redhat-beta

配置yum repos

挂载好光盘后,配置yum的repos.
新建一个repo配置文件

# vim /etc/yum.repos.d/my.repo

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

保存。

测试

尝试安装dhcp服务

# yum install dhcp

成功配置的话能看到如下画面
yum