Abstract: http://qubaoquan.blog.51cto.com/1246748/292516
Create a folder
[Root @ localhost centos] # mkdir/Media/centos
Attach a CD to a local device
[Root @ localhost centos] # Mount/dev/CDROM/Media/centos
In the/etc/yum. Repos. d/directory, there are two files
CentOS-Base.repo and CentOS-Media.repo
The CentOS-Base.repo records the address and path information of the yum source on the network.
The CentOS-Media.repo records the media and paths that can be used locally as the yum source. There is also a description:
# 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
# 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
Gpgcheck = 1
Enabled = 0
Gpgkey = file: // etc/pki/rpm-GPG-key-beta
You only need to edit the bashurl and write your own CD path.
I think the source of my CD is enough. No network source or no network is required.
Yum -- disablerepo = \ * -- enablerepo = c5-media [command]
The yum command allows the use of local media sources. The correct command is as follows (updating GCC is used as an example ):
[Root @ centos CDROM] # Yum -- disablerepo = * -- enablerepo = c5-media install gcc
Loading "installonlyn" plugin
Setting up update process
Setting up Repositories
C5-media 100% | =============================| 1.1 kb 00: 00
Reading repository metadata in from local files
Primary.xml.gz 100% | =========================| 834 kb 00: 00
######################################## ######## 2400/2400
No packages marked for update/obsoletion
For example, install GDB
[Root @ centos CDROM] # Yum -- disablerepo = * -- enablerepo = c5-media install GDB
Loading "installonlyn" plugin
Setting up install process
Setting up Repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
-- & Gt; populating transaction set with selected packages. Please wait.
--- & Gt; downloading header for GDB to pack into transaction set.
GDB-6.5-25. el5.i386. rpm 100% | =================================| 56 KB 00: 00
--- & Gt; Package GDB. i386 0: 6.5-25. EL5 set to be updated
-- & Gt; running transaction check
Dependencies resolved
========================================================== ============================================
Package arch version repository size
========================================================== ============================================
Installing:
GDB i386 6.5-25. EL5 C5-media 3.1 m
Transaction Summary
========================================================== ============================================
Install 1 package (s)
Update 0 package (s)
Remove 0 package (s)
Total download size: 3.1 m
Is this OK [Y/n]: Y
Downloading packages:
Running transaction Test
Finished transaction Test
Transaction test succeeded
Running transaction
Installing: GDB ####################### [1/1]
Installed: GDB. i386 0: 6.5-25. EL5
Complete!
[Root @ centos CDROM] #
The following errors often occur when you use yum for install.
Warning: rpmts_hdrfromfdno: Header V3 DSA Signature: nokey, key ID 1ac70ce6
The installation fails. The solution is as follows:
[Root @ localhost centos] # rpm -- import/etc/pki/rpm-GPG/RPM-GPG-KEY-CentOS-5
[Root @ localhost centos] # rpm -- import/etc/pki/rpm-GPG-key-beta