Directory
- Linux Local Source list
- A. Ubuntu
- 1. Local ISO
- 2. Making a local source
- B. CentOS
Linux Local source ListA. Ubuntu1. Local 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.
[email protected]:/# mount-t Iso9660/dev/cdrom/media/cdrom/mount:/dev/sr0 is write-protected, mounting read-only[email protected]:/# sudo apt-cdrom-m-d/media/cdrom/addusing 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 signaturesfound label ' Ubuntu-server 16.04.5 LTS _x Enial xerus_-Release AMD64 (20180731) ' This disc is called: ' Ubuntu-server 16.04.5 LTS _xenial xerus_-Release AMD64 (20 180731) ' Copying package Lists...gpgv:signature made Tue Jul 2018 08:39:26 AM CST using RSA key ID Efe21092gpgv:good s Ignature from "Ubuntu CD Image Automatic Signing Key" <[email protected]> "Reading package Indexes ... donewriting New Source Listsource list entries for this disc are:deb cdrom:[ubuntu-server 16.04.5 LTS _xenial xerus_-Rel Ease AMD64 (20180731)]/xenial main Restrictedrepeat This process for the rest of the CDs in your set. [email protected]:/# vim/etc/apt/sources.list# at this time sources.list one more line of local source # Deb Cdrom:[ubuntu-server 16.04.5 LTS _ Xenial Xerus_-Release amd64 (20180731)]/xenial main restricted[email protected]:/# [email protected]:/# sudo apt update
2. Making a local source
Usually apt-get install installs the software, the download of the Deb file will be stored in the/var/cache/apt/archives/, in order to re-install or use for others in the future.
Steps:
# 新建离线源目录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-repositoriessudo apt-get install -fsudo 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. CentOS1. Local ISO
1. 首先创建挂载点2. 然后挂载光驱3. 移除原有源4. 新建local.repo文件,内容如下:?```[name]name="local repo"baseurl=file:///media/cdrom/enabeld=1gpgcheck=0?```5. 对yum进行初始化操作
e.g.
[[email protected] ~]# mkdir/media/cdrom[[email protected] ~]# mount-t iso9660/dev/cdrom/media/cdrommount :/dev/sr0 is write-protected, mounting read-only[[email protected] ~]# cd/etc/yum.repos.d/[[email Protected] yum.repos.d]# pwd/etc/yum.repos.d[[email protected] yum.repos.d]# Lscentos-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[ [email protected] yum.repos.d]# mkdir bak[[email protected] yum.repos.d]# mv *.repo bak/[[email Protected] yum.repos.d]# Vim Local.repo writes the following: [name] name= "local repo" baseurl=file:///media/cdrom/ Enabeld=1 gpgcheck=0[[email protected] yum.repos.d]# yum Clean all # Clear Cache loaded Plugins:fastestmirror Cleaning repos:namecleaning up Everythingmaybe-Want:rm-rf/var/cache/yum, to also frEE up space taken by orphaned data from disabled or removed reposcleaning up list of fastest mirrors[[email protected ] yum.repos.d]# Yum Makecache # Create a new cache loaded plugins:fastestmirrordetermining fastest mirrorsname | 3.6 KB 00:00:00 (quarter): 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[[email protected] yum.repos.d]# Yum List | Wc-l # View available number 546[[email protected] yum.repos.d]#
Linux configuration Local source (Ubuntu/centos)