首先,将本地镜像mount到某个目录,假设有两个镜像盘dvd1.iso 和dvd2.iso
mkdir dvd1
mkdir dvd2
mount -o loop  /home/dvd1.iso  /mnt/dvd1     
mount -o loop  /home/dvd2.iso  /mnt/dvd2
rpm包的系统(例如centos,有yum命令的都是)操作如下:
centos
[root@el6-x86 ~]# ls /etc/yum.repos.d/
 CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo修改CentOS-Media.repo,
[c6-media]
 name=CentOS-$releasever - Media
 baseurl=file:///mnt/dvd1/
         file:///mnt/dvd2/
 gpgcheck=1
 enabled=1
 gpgkey=file:///mnt/dvd1/RPM-GPG-KEY-CentOS-6 #此项名称在/mnt/dvd1 下查看获取然后
1. yum clean all
2. yum makecache
如果提示Error: Cannot find a valid baseurl for repo: base, 则将CentOS-Base.repo重命名为别的名称,以跳过网络源。或者修改它
在所有网络源项下面加上 enabled=0  ,如下示例:
 [base]
 name=CentOS-$releasever - Base
 mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
 #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
 gpgcheck=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
 enabled=0#released updates 
 [updates]
 name=CentOS-$releasever - Updates
 mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
 #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
 gpgcheck=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
 enabled=0如果你的系统没有CentOS-Media.repo,只有一个.repo文件,例如CentOS-Base.repo:
那么修改它,配置本地源,示例如下:
[server1]
 name=dvd1
 baseurl=file:///mnt/dvd/
 gpgcheck=1
 enabled=1[server2]
 name=dvd2
 baseurl=file:///mnt/dvd2/
 gpgcheck=1
 enabled=1然后     yum clean all   以及   yum makecache
=如果提示:您已启用软件包 GPG 签名检查,这样很好。不过您尚未安装任何 GPG 公钥。请下载您希望安装的软件签名公钥并安装。假设公钥已下载,安装命令是:
     rpm --import public.gpg.key那就将上面的gpgcheck=1改为gpgcheck=0
-------------------------
以上centos8中,yum makecache或yum install时可能提示这样的错误:
[root@localhost ~]# yum install strace
 dvd1                                                                          0.0  B/s |   0  B     00:00    
 Failed to download metadata for repo 'server1'
 Error: Failed to download metadata for repo 'server1'解决方法:将baseurl=file:///mnt/dvd2/ 改成 baseurl=file:///mnt/dvd2/AppStream
附uek8.0 oracleLinux8.0配置示例
[root@uek80 /]# cat /etc/yum.repos.d/xsz.repo    
 [xszBaseOS]
 name=xszBaseOS
 baseurl=file:///mnt/dvd1/BaseOS
 gpgcheck=0
 enabled=1
 [xszAppStream]
 name=xszAppStream
 baseurl=file:///mnt/dvd1/AppStream
 gpgcheck=0
 enabled=1DEB包的系统(例如ubuntu,有apt-get这种命令的就是了)操作如下:
vim /etc/apt/source.list
添加
 deb file:///mnt/dvd1 eagle main
 deb file:///mnt/dvd2 eagle main
然后
apt-get   update
如果提示:无法找到文件 - /mnt/dvd1/dists/xenial/Release (2: 没有那个文件或目录)
则 find /mnt/dvd1 -name Release 看看Release文件在哪个目录。
root@info2soft-PC:~# find /mnt/dvd1/ -name Release
/mnt/dvd1/dists/eagle/main/binary-arm64/Release
/mnt/dvd1/dists/eagle/Release如上所示在eagle中,所以配置 deb file:///mnt/dvd2 eagle main
------------------------------------------------以上针对DEB的方式弃用-------
改用:
假设有 /root/ubuntu-12.04.4-server-amd64.iso
首先 mount -o loop /root/ubuntu-12.04.4-server-amd64.iso /media/cdrom
然后 apt-cdrom -m -d=/media/cdrom add
可以看到/etc/apt/sources.list中已经自动配置上了本地源
deb cdrom:[Ubuntu-Server 12.04.4 LTS _Precise Pangolin_ - Release amd64 (20140204)]/ dists/precise/main/binary-i386/
 deb cdrom:[Ubuntu-Server 12.04.4 LTS _Precise Pangolin_ - Release amd64 (20140204)]/ dists/precise/restricted/binary-i386/
 deb cdrom:[Ubuntu-Server 12.04.4 LTS _Precise Pangolin_ - Release amd64 (20140204)]/ precise main restricted(不过我这镜像只有700MB+,没有可用的软件)

(none):~ # zypper sl
 # | Enabled | Refresh | Type | Name                                | URI           
 --+---------+---------+------+-------------------------------------+---------------
 1 | Yes     | No      | YaST | SUSE Linux Enterprise Server 10 SP1 | dvd:///       
 2 | Yes     | Yes     | YaST | local-dvd1                          | file:/mnt/dvd1zypper ar file:///mnt/dvd1 local-dvd1
zypper update (这个操作最好不要进行,这个操作可能会更新一些软件包,有可能导致你的系统重启后出现未知问题, zypper install发现新源 local-dvd1时,会自动去创建cache)
CMAKE安装测试:
zypper install cmake (测试安装cmake) ,有的suse能成功,有的不能。新版本的SUSE往往能成功。自己新安装的SUSE在挂载SDK镜像后也能,原来别人装的,我添加SDK镜像本地源后,安装却找不到CMAKE。
结果只能手动查找安装:
find /mnt/dvd2 -name *cmake*
 /mnt/dvd2/suse/x86_64/cmake-2.6.2-3.20.x86_64.rpm rpm -ivh /mnt/dvd2/suse/x86_64/cmake-2.6.2-3.20.x86_64.rpm
 Preparing...                ########################################### [100%]
    1:cmake                  ########################################### [100%]附SUSE12 网络源(suse12sp5实测可用)

zypper ar https://mirror.bjtu.edu.cn/opensuse/update/leap/42.3/non-oss/ update-repo-no-oss-bjtu
 zypper ar https://mirror.bjtu.edu.cn/opensuse/update/leap/42.3/oss/ update-repo-oss-bjtu
 zypper ar https://mirror.bjtu.edu.cn/opensuse/distribution/leap/42.3/repo/oss/ dis-repo-oss-bjtu
 zypper ar https://mirror.bjtu.edu.cn/opensuse/distribution/leap/42.3/repo/non-oss/ dis-repo-non-oss-bjtuzypper refresh
提示是否拒绝,填a   (一直接受)。
常见错误:
suse12sp1:/etc/sysconfig/network # zypper -n install libcurl-devel
 Loading repository data...
 Reading installed packages...
 Resolving package dependencies...The following NEW package is going to be installed:
   libcurl-develThe following package is not supported by its vendor:
   libcurl-devel1 new package to install.
 Overall download size: 221.4 KiB. Already cached: 0 B. After the operation, additional 357.1 KiB will be used.
 Continue? [y/n/? shows all options] (y): y
 Retrieving package libcurl-devel-7.37.0-15.1.x86_64                        (1/1), 221.4 KiB (357.1 KiB unpacked)
 Media source 'file:/mnt/dvd1' does not contain the desired mediumAbort, retry, ignore? [a/r/i/? shows all options] (a): a
 Problem occured during or after installation or removal of packages:
 Installation aborted by userPlease see the above error message for a hint.
解决方法:
umount /mnt/dvd1
umount /mnt/dvd2
再交换mount 将SDK的镜像放到第一个            mount -loop /dev/sr0 /mnt/dvd2
======================
新增 suse15sp2的本地ISO镜像作为源的配置:
suse15sp2:~ # find /mnt/dvd1/ -name git-core*
 /mnt/dvd1/Module-Basesystem/x86_64/git-core-2.26.2-3.28.2.x86_64.rpm执行如下添加,我这只添加/mnt/dvd1 ,zypper install时无法找到相应的包。
zypper ar file:///mnt/dvd1/Module-Basesystem/ local-dvd1