Centos iso 镜像挂载离线 yum 源

准备阶段

1.查看系统版本

[root@centos73-1611 ~]# cat /etc/redhat-release   
CentOS Linux release 7.3.1611 (Core)

2.下载与系统版本一致的 iso 镜像 http://mirror.nsc.liu.se/centos-store/

配置 yum 本地源

1.准备挂载路径 mkdir /mnt/iso

2.挂载 iso 镜像

[root@centos73-1611 xqzhang]# mount CentOS-7.3-x86_64-DVD-1611.iso /mnt/iso  
mount: /dev/loop0 is write-protected, mounting read-only

3.添加本地源 vim /etc/yum.repos.d/CentOS-Media.repo(备份并删除该目录下其余的repo文件)

# CentOS-Media.repo
#
#  This repo can be used with mounted DVD media, verify the mount point for
#  CentOS-7.  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=c7-media [command]
#
# or for ONLY the media repo, do this:
#
#  yum --disablerepo=\* --enablerepo=c7-media [command]

[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
        file:///media/cdrom/
        file:///media/cdrecorder/
        file:///mnt/iso/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

增加本地源 file:///mnt/iso/,修改 enabled=1
4.重建yum缓存
yum clean all
yum makecache

测试

yum install ftp

附:

Ubuntu、麒麟系统挂载方式类似。

vim /etc/apt/sources.list

增加 deb [trusted=yes] file:///media/cdrom juniper main
挂载 mount -o loop Kylin-4.0.2-server-sp2-2000-19080414.J1-arm64.iso /media/cdrom/
更新 apt-get update
注:之前再麒麟系统测试,似乎只能挂载到 /media/cdrom/

留下你的脚步
推荐阅读