• centos挂载本地镜像作为yum源


    1、安装Centos后默认的Yum源如下
    ll /etc/yum.repos.d/
     
    [root@localhost ~]# ll /etc/yum.repos.d/
    total 32
    -rw-r--r--. 1 root root 1664 Nov 23 21:16 CentOS-Base.repo
    -rw-r--r--. 1 root root 1309 Nov 23 21:16 CentOS-CR.repo
    -rw-r--r--. 1 root root 649 Nov 23 21:16 CentOS-Debuginfo.repo
    -rw-r--r--. 1 root root 314 Nov 23 21:16 CentOS-fasttrack.repo
    -rw-r--r--. 1 root root 630 Nov 23 21:16 CentOS-Media.repo
    -rw-r--r--. 1 root root 1331 Nov 23 21:16 CentOS-Sources.repo
    -rw-r--r--. 1 root root 5701 Nov 23 21:16 CentOS-Vault.repo

    2、把默认Yum源备份(可选)
     
    [root@localhost ~]# mkdir /opt/centos-yum.bak
    [root@localhost ~]# mv /etc/yum.repos.d/* /opt/centos-yum.bak/

    3、将iso镜像上传到虚机上
    mkdir /mnt/iso 放到该目录下
     
    4、然后挂载:
    mount -t iso9660 /mnt/iso/CentOS-7-x86_64-DVD-1810.iso /opt/centos
    mount -t iso9660 /mnt/iso/CentOS-7-x86_64-DVD-1810.iso /opt/centos

    5、编写repo文件并指向镜像的挂载目录
     
    # vi /etc/yum.repos.d/local.repo
    添加下面的内容:
     
    [local]
    name=local
    baseurl=file:///opt/centos
    enabled=1
    gpgcheck=0

    6、清除缓存
    # yum clean all
    # yum makecache 把Yum源缓存到本地,加快软件的搜索好安装速度
    # yum list 列出了yum包
     
    [root@localhost ~]# yum clean all
    Loaded plugins: fastestmirror
    Cleaning repos: local
    Cleaning up list of fastest mirrors
    Other repos take up 68 M of disk space (use --verbose for details)
    [root@localhost ~]# yum makecache
    Loaded plugins: fastestmirror
    Determining fastest mirrors
    local | 3.6 kB 00:00:00
    (1/4): local/group_gz | 166 kB 00:00:00
    (2/4): local/primary_db | 6.0 MB 00:00:00
    (3/4): local/filelists_db | 7.1 MB 00:00:00
    (4/4): local/other_db | 2.6 MB 00:00:00
    Metadata Cache Created
     
     
    7、查看yum仓库列表
     
    # yum repolist

    8、开机自动挂载
    在/etc/fstab表中,添加最后的一行,将iso文件永久挂载到系统中
     
     
    # vi /etc/fstab
    /mnt/iso/CentOS-7-x86_64-DVD-1810.iso /opt/centos iso9660 loop 0 0
     
    9、取消挂载(需要的时候再执行):
    卸载挂载目录: # umount /opt/centos
     
  • 相关阅读:
    Linux信号列表(zz)
    TCP状态转移图学习总结
    UNP学习笔记之四select和poll
    RSS2.0结构
    UNP学习笔记二简单的并发服务器(concurrent servers)
    js面向对象基础(zz)
    libevent introduction
    Linux下Makefile的automake生成全攻略(zz)
    UNP学习笔记之三POSIX Signal Handling
    关于网络编程(服务端)的一些笔记(zz)
  • 原文地址:https://www.cnblogs.com/jylee/p/10955434.html
Copyright © 2020-2023  润新知