1.mount本地CentOS光盘
#mount /dev/cd
rom /mnt/cd
rom
2.修改yum配置
#cd /etc/yum.repos.d
# cat CentOS-Media.repo
-------------------------------------------------------------------------------
# CentOS-Media.repo
#
# This repo is used to mount the default locations for a CDROM / DVD on
# CentOS-5. You can use this repo and yum to install items directly off the
# DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
# yum --enablerepo=c5-media [command]
#
# or for ONLY the media repo, do this:
#
# yum --disablerepo=\* --enablerepo=c5-media [command]
[c5-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
file:///media
/cdrom/
file:///media
/recorder/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
-------------------------------------------------------------------------------
修改该配置文件:
将baseurl指向mount的光盘
...
baseurl=file:///mnt/cd
rom/
...
3.运行安装命令安装软件包。(下面是示例安装gd-devel软件包)
[root@localhost yum.repos.d]# yum --disablerepo=\* --enablerepo=c5-media install gd-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gd-devel.i386 0:2.0.33-9.4.el5_4.2 set to be updated
--> Processing Dependency: freetype-devel for package: gd-devel
--> Processing Dependency: fontconfig-devel for package: gd-devel
--> Running transaction check
---> Package fontconfig-devel.i386 0:2.4.1-7.el5 set to be updated
---> Package freetype-devel.i386 0:2.2.1-21.el5_3 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================================
Package Arch Version Repository Size
===================================================================================================================================
Installing:
gd-devel i386 2.0.33-9.4.el5_4.2 c5-media 97 k
Installing for dependencies:
fontconfig-devel i386 2.4.1-7.el5 c5-media 168 k
freetype-devel i386 2.2.1-21.el5_3 c5-media 146 k
Transaction Summary
===================================================================================================================================
Install 3 Package(s)
Upgrade 0 Package(s)
Total download size: 412 k
Is this ok [y/N]: y
Downloading Packages:
-----------------------------------------------------------------------------------------------------------------------------------
Total 159 MB/s | 412 kB 00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : freetype-devel 1/3
Installing : fontconfig-devel 2/3
Installing : gd-devel 3/3
Installed:
gd-devel.i386 0:2.0.33-9.4.el5_4.2
Dependency Installed:
fontconfig-devel.i386 0:2.4.1-7.el5 freetype-devel.i386 0:2.2.1-21.el5_3
Complete!
[root@localhost yum.repos.d]#