官方文档写的非常好
14.5. Upgrading the System Off-line with ISO and Yum
-
Create a target directory to mount your ISO image. This directory is not automatically created when mounting, so create it before proceeding to the next step, as
root, type:mkdirmount_dirReplace mount_dir with a path to the mount directory. Typicaly, users create it as a subdirectory in the/media/directory. -
Mount the Red Hat Enterprise Linux 5 installation ISO image to the previously created target directory. As
root, type:mount-oloopiso_name mount_dirReplace iso_name with a path to your ISO image and mount_dir with a path to the target directory. Here, the-oloopoption is required to mount the file as a block device. -
Check the numeric value found on the first line of the
.discinfofile from the mount directory:head-n1mount_dir/.discinfoThe output of this command is an identification number of the ISO image, you need to know it to perform the following step. -
Create a new file in the
/etc/yum.repos.d/directory, named for instance new.repo, and add a content in the following form. Note that configuration files in this directory must have the .repo extension to function properly.[repository] mediaid=media_id name=repository_name baseurl=repository_url gpgkey=gpg_key enabled=1 gpgcheck=1
Replace media_id with the numeric value found inmount_dir/.discinfo. Set the repository name instead ofrepository_name, replace repository_url with a path to a repository directory in the mount point and gpg_key with a path to the GPG key.For example, the repository settings for Red Hat Enterprise Linux 5 Server ISO can look as follows:[rhel5-Server] mediaid=1354216429.587870 name=RHEL5-Server baseurl=file:///media/rhel5/Server gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release enabled=1 gpgcheck=1
-
Update all yum repositories including
/etc/yum.repos.d/new.repocreated in previous steps. Asroot, type:yumupdate