linux 系统镜像os_iso 作为本地软件安装源

首先,将本地镜像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=1

DEB包的系统(例如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+,没有可用的软件)

suse系统之前的文章讲过。  SUSE15 vmware网络配置 本地ISO镜像 软件安装 SSH连接_evolay的专栏-CSDN博客

(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/dvd1

zypper 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实测可用)

suse linux 12 更新zypper源_rai369963的专栏-CSDN博客_suse12 源

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-bjtu

zypper 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-devel

The following package is not supported by its vendor:
  libcurl-devel

1 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 medium

Abort, retry, ignore? [a/r/i/? shows all options] (a): a
Problem occured during or after installation or removal of packages:
Installation aborted by user

Please 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值