因为个人需要,整理的
参考:https:
操作系统:CentOS 7.2(1511)
ISO文件:CentOS-7-x86_64-Everything-1511(ps:上CentOS官网下载的Everything)
1.挂载iso文件到挂载点
$ mount -o loop /root/CentOS-7-x86_64-Everything-1511 /media/cdrom
2.查看挂载状态
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00 19G 3.3G 15G 19% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 62M 0 62M 0% /dev/shm
/root/CentOS-7-x86_64-Everything-1511 3.9G 3.9G 0 100% /media/cdrom
$ 重新挂载系统分区
$ mount -a
3.修改yum的配置文件,使用本地ISO做yum源
$ cd /etc/yum.repos.d/
$ mv CentOS-Base.repo CentOS-Base.repo.bak
$ cp CentOS-Media.repo CentOS-Media.repo.bak
$ cat CentOS-Media.repo
[c5-media]
name=CentOS-$releasever - Media
baseurl=file:///media/cdrom/ #表明yum源在/media/cdrom/目录下,其它的源(baseurl)注释掉
#baseurl=file:///media/CentOS/
# file:///media/cdrom/
# file:///media/cdrecorder/
gpgcheck=1
enabled=1 #把0改成1,启用yum
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
4.清除缓存
$ yum clean all
$ yum list
5.测试
$ yum -y install vim
6.开机自动挂载ISO镜像文件
$ 在/etc/fstab表中,添加最后的一行,将ISO文件永久挂载到系统中
$ cat /etc/fstab
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
/root/CentOS-7-x86_64-Everything-1511 /media/cdrom iso9660 loop 0 0