Linux 配置本地源 (Ubuntu / CentOS)
Linux local source list
A. Ubuntu
1. 本地ISO
# 首先挂载本地镜像
mount -o loop -t iso9660 ./ubuntu.iso /media/cdrom
# 手动添加ISO镜像至源列表,这样就可以在软件库中找到ISO中的所有包
apt-cdrom -m -d=/media/cdrom add
# 刷新软件库
apt update
# 完成后查看sources.list ,本地源应该在第一条,否则默认还是从网上下载
e.g.
root@ubuntu:/# mount -t iso9660 /dev/cdrom /media/cdrom/
mount: /dev/sr0 is write-protected, mounting read-only
root@ubuntu:/# sudo apt-cdrom -m -d /media/cdrom/ add
Using CD-ROM mount point /media/cdrom/
Identifying... [83cd189f3f418ae846baff8ecfba5390-2]
Scanning disc for index files...
Found 4 package indexes, 0 source indexes, 0 translation indexes and 1 signatures
Found label 'Ubuntu-Server 16.04.5 LTS _Xenial Xerus_ - Release amd64 (20180731)'
This disc is called:
'Ubuntu-Server 16.04.5 LTS _Xenial Xerus_ - Release amd64 (20180731)'
Copying package lists...gpgv: Signature made Tue 31 Jul 2018 08:39:26 AM CST using RSA key ID EFE21092
gpgv: Good signature from "Ubuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com>"
Reading Package Indexes... Done
Writing new source list
Source list entries for this disc are:
deb cdrom:[Ubuntu-Server 16.04.5 LTS _Xenial Xerus_ - Release amd64 (20180731)]/ xenial main restricted
Repeat this process for the rest of the CDs in your set.
root@ubuntu:/# vim /etc/apt/sources.list
# 此时sources.list中多出一行本地源
# deb cdrom:[Ubuntu-Server 16.04.5 LTS _Xenial Xerus_ - Release amd64 (20180731)]/ xenial main restricted
root@ubuntu:/#
root@ubuntu:/# sudo apt update
2. 制作本地源
平时apt-get install安装软件时,下载的deb文件都会存放在/var/cache/apt/archives/下,为了今后重装或给别人用 。
步骤:
# 新建离线源目录
mkdir ~/packs
# 将缓存复制到目录
cp -rv /var/cache/apt/archives/* ~/packs
# 拷贝过来发现在packs当中为文件都是root账户的,需要修改
# 修改所有者
# sudo chown -R someone.someone * $pack_dir
# 修改权限
# sudo chmod ug+rw,o+r * $pack_dir
# 建立Packages包,里面记录了packs目录下的软件包信息,包括依赖信息
dpkg-scanpackages ~/packs /dev/null |gzip > packs/Packages.gz -r
# 将~/packs复制到目标计算机,或本机的某处
vim /etc/apt/sources.list
# 添加 deb file:/// /home/someone/packs/
# 注意: packs后面有一个斜杠,全路径前面还要有空格
# 更新源
sudo apt-get update ---allow-insecure-repositories
sudo apt-get install -f
sudo apt-get xxxx --allow-unauthenticated
# 本地的源是没有签名的,直接更新ubuntu1604下的apt会提示找不到release文件,是一种不安全的源,默认是被禁用的。如果还要安装的话需要加上 --allow-unauthenticated 选项。
# N: Updating from such a repository can't be done securely, and is therefore disabled by default.
B. CentOS
1. 本地ISO
1. 首先创建挂载点
2. 然后挂载光驱
3. 移除原有源
4. 新建local.repo文件,内容如下:
```
[name]
name="local repo"
baseurl=file:///media/cdrom/
enabeld=1
gpgcheck=0
```
5. 对yum进行初始化操作
e.g.
[root@cent7 ~]# mkdir /media/cdrom
[root@cent7 ~]# mount -t iso9660 /dev/cdrom /media/cdrom
mount: /dev/sr0 is write-protected, mounting read-only
[root@cent7 ~]# cd /etc/yum.repos.d/
[root@cent7 yum.repos.d]# pwd
/etc/yum.repos.d
[root@cent7 yum.repos.d]# ls
CentOS-Base.repo CentOS-Base.repo.bak CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo epel.repo epel-testing.repo mysql-community.repo mysql-community-source.repo
[root@cent7 yum.repos.d]# mkdir bak
[root@cent7 yum.repos.d]# mv *.repo bak/
[root@cent7 yum.repos.d]# vim local.repo
写入以下内容:
[name]
name="local repo"
baseurl=file:///media/cdrom/
enabeld=1
gpgcheck=0
[root@cent7 yum.repos.d]# yum clean all # 清除缓存
Loaded plugins: fastestmirror
Cleaning repos: name
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@cent7 yum.repos.d]# yum makecache # 建立新缓存
Loaded plugins: fastestmirror
Determining fastest mirrors
name | 3.6 kB 00:00:00
(1/4): name/group_gz | 3.5 kB 00:00:00
(2/4): name/primary_db | 776 kB 00:00:00
(3/4): name/other_db | 198 kB 00:00:00
(4/4): name/filelists_db | 298 kB 00:00:00
Metadata Cache Created
[root@cent7 yum.repos.d]# yum list | wc -l # 查看可用个数
546
[root@cent7 yum.repos.d]#
Linux 配置本地源 (Ubuntu / CentOS)的更多相关文章
- linux配置本地源
yum本地源配置 标签: centosplugins网络file虚拟机linux 2011-10-09 21:40 12093人阅读 评论(1) 收藏 举报 分类: linux yum 在网上找了很 ...
- Ubuntu 配置本地源
Ubuntu 配置本地源 操作系统 Ubuntu 20.04.2 LTS 一.挂载 iso 到本地 mount -t iso9660 -o loop /dev/sr0 /media/cdrom //- ...
- Xrdp - 通过Windows的RDP连接Linux远程桌面(Ubuntu/CentOS/Redhat 7)
Xrdp - 通过Windows的RDP连接Linux远程桌面(Ubuntu/CentOS/Redhat 7) 您多久访问一次Linux桌面? 您使用什么工具来访问远程桌面? Xrdp是一个开源工具, ...
- Linux 配置yum源.
Linux 配置yum源. 环境:虚拟机中安装了RedHat ,在进行安装mariadb的时候,出现如下错误.是因为yum源的问题,需要进行配置yum源.本教程是配置本地yum源. [root@loc ...
- Linux 配置yum源(互联网)
Linux 配置yum源(互联网) 环境:操作系统Redhat 7.5 1.卸载现有的yum源 rpm -qa|grep yum|xargs rpm -e --nodeps #移除与原yum有 ...
- Linux 配置本地yum源
Linux 配置无网络状态利用yum安装软件 在有网络的情况下安装软件只需一条yum install xxx命令,例如安装gcc只需一条指令:yum install gcc 那么在没有网络的情况下该 ...
- linux替换yum源及配置本地源
linux系统安装后自带的bash源由于在国外,安装软件包的时候会非常慢,最好替换一下yum源. 关于yum源的简单介绍 yum的主要功能是更方便地添加,删除和更新rpmba ...
- linux 配置本地yum源,配置国内yum源,配置epel源
目录 一.配置本地yum源 二.配置国内yum源和epel源 一.配置本地yum源 1.挂载ISO镜像 mount -o loop /mnt/yum-iso/CentOS-7-x86_64-DVD-1 ...
- Linux配置yum源(本地源和网络源)
目录 一:配置本地yum源 二:配置网络yum源 更新源可以获取最新的软件信息,以更新您的系统 Redhat7配置源 YUM(Yellow dog Updater Modified): yum是Re ...
随机推荐
- [Swift]LeetCode265.粉刷房子 II $ Paint House II
There are a row of n houses, each house can be painted with one of the k colors. The cost of paintin ...
- HTML入门教程,多年心血总结,一看就会
笔者在武汉蚂蹄软件服务中心做软件开发多年,最近花一天时间总结出一套HTML入门级的教程,全篇没有任何废话,全部是精华,希望对你入门web开发有一定的帮助. HTML基本格式 <html> ...
- Python面向对象中的类和对象
类和对象 目标 类和对象的概念 类和对象的关系 类的设计 01. 类和对象的概念 类 和 对象 是 面向对象编程的 两个 核心概念 1.1 类 类 是对一群具有 相同 特征 或者 行为 的事物的一个统 ...
- 由浅入深的讲述Get和Post的区别
对于网上对get和post区别的长篇大论,我只想说一些干货其中最重要的是:GET和POST本质上两者没有任何区别.他们都是HTTP协议中的请求方法.底层实现都是基于TCP/IP协议.所谓区别,只是浏览 ...
- Python内置函数(8)——bytes
英文文档: class bytes([source[, encoding[, errors]]]) Return a new “bytes” object, which is an immutable ...
- 11.Flask钩子函数
在Flask中钩子函数是使用特定的装饰器的函数.为什么叫做钩子函数呢,是因为钩子函数可以在正常执行的代码中,插入一段自己想要执行的代码,那么这种函数就叫做钩子函数. before_first_requ ...
- linux-centerOs6.8安装nginx与配置
一:安装nginx 1.安装gcc(命令:yum install gcc)备注:可以输入gcc -v查询版本信息,查看是否自带安装 2.安装pcre(命令:yum install pcre-devel ...
- 四则运算4(Android版)
队员:王楗 http://home.cnblogs.com/u/wangjianly/ 结组照:
- Python进阶:迭代器与迭代器切片
2018-12-31 更新声明:切片系列文章本是分三篇写成,现已合并成一篇.合并后,修正了一些严重的错误(如自定义序列切片的部分),还对行文结构与章节衔接做了大量改动.原系列的单篇就不删除了,毕竟也是 ...
- 阿里注册中心nacos使用整合Dubbo-原创
阿里注册中心nacos是今年开源的框架,一开始以为就是个zk.后面看了图才明白他对标的竟然是consul\eureka,最重要是完美支持dubbo.我想今年开源它也是别有用意 .(目前nacos0.7 ...