Linux本地挂载ISO镜像文件并自建YUM源
Linux本地挂载ISO镜像文件并自建YUM源
非著名运维
分享网络管理、Linux运维、VOIP呼叫中心运维、VOS3000平台等实战知识,推广围绕DevOps理念的自动化运维、精益运维、智能运维等优秀实践,让运维工程师更加专注于自动化。
公众号
👀 NICE TO MEET YOU 👀
点击【非著名运维】右上角找到【…】推荐给朋友哟
关注并设置我为✨星标/置顶✨爱你们哟
温馨提醒:底部「✨在看✨」点一点。戳戳点赞并分享,感谢
1.下载ISO镜像文件
CentOS-7-x86_64-DVD-2009.iso下载
2.上传刚刚我们下载的ISO镜像文件到服务器上
[root@localhost ~]# ll -h
total 5.1G
-rw-r--r-- 1 root root 4.3G May 8 15:53 CentOS-7-x86_64-DVD-1708.iso
drwxr-xr-x. 3 root root 17 Apr 6 02:27 KSF
-rw-------. 1 root root 2.1K Dec 27 03:35 anaconda-ks.cfg
-rw-r--r-- 1 root root 827M Apr 27 08:17 zk3.4.10_kafka_2.11-1.0.1_ngapmstat1.0.tar.gz
3.创建ISO镜像文件挂载目录并挂载
[root@localhost ~]# mkdir /mnt/centos7
[root@localhost ~]# mount -o loop CentOS-7-x86_64-DVD-1708.iso /mnt/centos7/
mount: /dev/loop0 is write-protected, mounting read-only
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 252G 0 252G 0% /dev
tmpfs 252G 320K 252G 1% /dev/shm
tmpfs 252G 21M 252G 1% /run
tmpfs 252G 0 252G 0% /sys/fs/cgroup
/dev/mapper/centos-root 274G 15G 259G 6% /
/dev/sdm1 1014M 151M 864M 15% /boot
tmpfs 51G 0 51G 0% /run/user/0
/dev/loop0 4.3G 4.3G 0 100% /mnt/centos7
4.备份原YUM源文件,并创建备份目录
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir repo.bak
[root@localhost yum.repos.d]# mv CentOS-* repo.bak/
[root@localhost yum.repos.d]# ll repo.bak/
total 40
-rw-r--r--. 1 root root 1664 Oct 23 2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Oct 23 2020 CentOS-CR.repo
-rw-r--r--. 1 root root 649 Oct 23 2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 630 Oct 23 2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Oct 23 2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 Oct 23 2020 CentOS-Vault.repo
-rw-r--r--. 1 root root 314 Oct 23 2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 616 Oct 23 2020 CentOS-x86_64-kernel.repo
5.创建新挂载的ISO镜像源YUM文件
[root@localhost yum.repos.d]# cat > centos7.repo << EOF
> [centos7-local]
> name=Centos7 #YUM源名称,自定义
> baseurl=file:///mnt/centos7/ #本地镜像文件路径
> enabled=1 #1表示启动YUM源,0为禁用
> gpgcheck=0 #1为检查GPG-KEY,0为不检查
> EOF
[root@localhost yum.repos.d]# cat centos7.repo
[centos7-local]
name=Centos7
baseurl=file:///mnt/centos7/
enabled=1
gpgcheck=0
6.清除YUM缓存并测试安装
[root@localhost yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: centos7-local
Cleaning up list of fastest mirrors
[root@localhost yum.repos.d]# yum makecache #缓存YUM源信息
Loaded plugins: fastestmirror
Determining fastest mirrors
centos7-local | 3.6 kB 00:00:00
(1/4): centos7-local/group_gz | 156 kB 00:00:00
(2/4): centos7-local/filelists_db | 3.1 MB 00:00:00
(3/4): centos7-local/primary_db | 3.1 MB 00:00:00
(4/4): centos7-local/other_db | 1.2 MB 00:00:00
Metadata Cache Created
[root@localhost yum.repos.d]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id repo name status
centos7-local Centos7 3894
repolist: 3894
[root@localhost yum.repos.d]# yum install net-tools
[root@localhost yum.repos.d]# yum search jdk #也可搜素
温馨提示
如果您喜欢本文,就请动动您的发财手为本文留言转发在看,想获取更多运维相关内容,请记得关注我。
“点赞+在看”双点击,开启今日暴富